[英]Sum over unix timestamps in grafana prometheus
Lets say I have my_val
for a value in prometheus, that is recorded when I use a gpu instance.假设我有
my_val
作为 prometheus 中的一个值,这是在我使用 gpu 实例时记录的。 I want to sum up how many hours or gpu usage I had in the past week.我想总结一下我过去一周的使用时间或 gpu。 I can call
timestamp(myval{instance="$instance"})
which will return a vector with timestamps, but I cannot call sum(idelta)
over them because it is an instant vector for some reason.我可以调用
timestamp(myval{instance="$instance"})
,它将返回一个带有时间戳的向量,但我不能调用sum(idelta)
,因为出于某种原因它是一个即时向量。
Grafana also messes with the amount of data requested based on how far I am zooming. Grafana 还会根据我缩放的距离来处理请求的数据量。
How do I create a reliable call for every datapoint如何为每个数据点创建可靠的调用
Try the following query:尝试以下查询:
count_over_time(my_val[7d]) * <scrape_interval> / 3600
Where <scrape_interval>
is scrape interval in seconds set in Prometheus config file for the target that exports my_val
metric.其中
<scrape_interval>
是在 Prometheus 配置文件中为导出my_val
指标的目标设置的以秒为单位的抓取间隔。 This query assumes that my_val
doesn't contain data points when gpu instance wasn't used.此查询假定
my_val
在未使用 gpu 实例时不包含数据点。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.