promql

Grafana - Single stat after big counter reset

人盡茶涼 提交于 2021-02-11 17:01:51
问题 We use Grafana + Prometheus to monitor our infrastructure and recently we added some business focused metrics and I've been having issues with one of the counters we track. It's a session time counter. Basically, each time a session ends, we increase that counter by the time the user spent in that session. So if an user spends 2m using the software, the counter will be incremented by 120000 ms. For a few days that approach worked perfectly fine, but since yesterday when we had a big

PromQL avg_over_time for non-zero values

泪湿孤枕 提交于 2021-02-11 08:42:08
问题 I am trying to get avg_over_time value from gauge metric, but I would want average only from the non-zero values of the metric (or values higher than zero, to be exact). Example: avg_over_time(foo[2d] > 0) But I alwas get parse error: binary expression must contain only scalar and instant vector types I tried setting up recording rule expr: foo > 0 But unfortunately with the same result. Is this possible in PromQL? 回答1: You can use a sub-query with Prometheus version above 2.7: avg_over_time(

PromQL avg_over_time for non-zero values

眉间皱痕 提交于 2021-02-11 08:41:51
问题 I am trying to get avg_over_time value from gauge metric, but I would want average only from the non-zero values of the metric (or values higher than zero, to be exact). Example: avg_over_time(foo[2d] > 0) But I alwas get parse error: binary expression must contain only scalar and instant vector types I tried setting up recording rule expr: foo > 0 But unfortunately with the same result. Is this possible in PromQL? 回答1: You can use a sub-query with Prometheus version above 2.7: avg_over_time(

Prometheus query to count unique labels over a timeframe

冷暖自知 提交于 2021-02-08 19:53:10
问题 I need to count the number of unique labelsets for a prometheus metric over a given timeframe. For example, "How many unique labelsets have a value of 1 at some point during the past 7 days." I've investigated using count and count_over_time but count only operates on instant vectors meaning I can get the number of unique labelsets for an instance in time, but not in aggregate over a timeframe. count_over_time returns the number of values which isn't useful since I need to know the number of

Prometheus query to count unique labels over a timeframe

不羁岁月 提交于 2021-02-08 19:52:45
问题 I need to count the number of unique labelsets for a prometheus metric over a given timeframe. For example, "How many unique labelsets have a value of 1 at some point during the past 7 days." I've investigated using count and count_over_time but count only operates on instant vectors meaning I can get the number of unique labelsets for an instance in time, but not in aggregate over a timeframe. count_over_time returns the number of values which isn't useful since I need to know the number of

When to use sum_over_time vs increase Promql Grafana

白昼怎懂夜的黑 提交于 2021-01-28 20:27:43
问题 I am a little unclear on when to exactly use increase and when to use sum_over_time in order to calculate a periodic collection of data in Grafana. I want to calculate the total percentage of availability of my system. Thanks. 回答1: The "increase" function calculates how much a counter increased in the specified interval. The "sum_over_time" function calculates the sum of all values in the specified interval. Suppose you have the following data series in the specified interval: 5, 5, 5, 5, 6,

Prometheus return no data when calculating a ratio of two metrics

倖福魔咒の 提交于 2020-12-29 13:15:08
问题 I want to calculate a ratio of two metrics, but I get no data... I have some metrics like: fs_bytes{filesystem="/var",instance="localhost:9108",job="graphite",metric="Used"} 50.0 fs_bytes{filesystem="/var",instance="localhost:9108",job="graphite",metric="Total"} 100.0 When I try to do any operation (device, multiply, add, subtract) like: fs_bytes{instance="localhost:9108",metric="Used"} / fs_bytes{instance="localhost:9108",metric="Total"} Prometheus returned: no data When I query each metric

Prometheus return no data when calculating a ratio of two metrics

旧城冷巷雨未停 提交于 2020-12-29 13:09:25
问题 I want to calculate a ratio of two metrics, but I get no data... I have some metrics like: fs_bytes{filesystem="/var",instance="localhost:9108",job="graphite",metric="Used"} 50.0 fs_bytes{filesystem="/var",instance="localhost:9108",job="graphite",metric="Total"} 100.0 When I try to do any operation (device, multiply, add, subtract) like: fs_bytes{instance="localhost:9108",metric="Used"} / fs_bytes{instance="localhost:9108",metric="Total"} Prometheus returned: no data When I query each metric

Prometheus return no data when calculating a ratio of two metrics

人走茶凉 提交于 2020-12-29 13:09:17
问题 I want to calculate a ratio of two metrics, but I get no data... I have some metrics like: fs_bytes{filesystem="/var",instance="localhost:9108",job="graphite",metric="Used"} 50.0 fs_bytes{filesystem="/var",instance="localhost:9108",job="graphite",metric="Total"} 100.0 When I try to do any operation (device, multiply, add, subtract) like: fs_bytes{instance="localhost:9108",metric="Used"} / fs_bytes{instance="localhost:9108",metric="Total"} Prometheus returned: no data When I query each metric

PromQL query to find the duration of each firing alert

给你一囗甜甜゛ 提交于 2020-12-15 06:09:34
问题 I am creating a Grafana dashboard to see the total alert count for each firing alert and the duration ( means it should capture how long alerts have been firing state). PromQL query used to capture the total alert count is as follows, count by (alertname,customerName) (changes(customer_ALERTS[24h])) Idea is to add two more column in the Grafana table panel having the alert count and the duration Now i need to get the query to capture the duration for each alerts. Can somebody please share