# PromQL

**URL:** https://discuss.prometheus.io/c/promql/6.md

[Latest](https://discuss.prometheus.io/latest.md) · [Categories](https://discuss.prometheus.io/categories.md)

---

## [About the PromQL category](https://discuss.prometheus.io/t/about-the-promql-category/17)

<div class="topic-metadata">

**Author:** [@SuperQ](https://discuss.prometheus.io/u/SuperQ)\
**Replies:** 0

</div>

Discussion about PromQL, the Prometheus query language. Share your favourite queries and ask questions to build your own.

---

## [Alert rules of increasing severity](https://discuss.prometheus.io/t/alert-rules-of-increasing-severity/3579)

<div class="topic-metadata">

**Author:** [@steverpalmer](https://discuss.prometheus.io/u/steverpalmer)\
**Replies:** 0\
**Last updated:** [August 29, 2026, 10:01am UTC](https://discuss.prometheus.io/t/alert-rules-of-increasing-severity/3579 "2026-08-29T10:01:57Z")

</div>

I’m a newbie to Prometheus, so I’m sorry if I’ve missed this in the documentation … In my “home-brew” network, Prometheus is collecting battery charge percentage, and I would like to create an alert for batteries below,…

---

## [Not showing up history job duartion in grafana panel](https://discuss.prometheus.io/t/not-showing-up-history-job-duartion-in-grafana-panel/3529)

<div class="topic-metadata">

**Author:** [@shyamal101](https://discuss.prometheus.io/u/shyamal101)\
**Replies:** 0\
**Last updated:** [May 14, 2026, 4:55pm UTC](https://discuss.prometheus.io/t/not-showing-up-history-job-duartion-in-grafana-panel/3529 "2026-05-14T16:55:11Z")

</div>

Job runs daily basis once. I need to get help on promo ql ..I wanted to see job durations in the grafana dashboard ,though I see metrics in TSDB but it is not appearing in the panel .basically I wanted to see all previ…

---

## [Alloy config issue for my access logs](https://discuss.prometheus.io/t/alloy-config-issue-for-my-access-logs/3503)

<div class="topic-metadata">

**Author:** [@gkrse](https://discuss.prometheus.io/u/gkrse)\
**Replies:** 0\
**Last updated:** [February 24, 2026, 11:51am UTC](https://discuss.prometheus.io/t/alloy-config-issue-for-my-access-logs/3503 "2026-02-24T11:51:53Z")

</div>

Hi Team, I am working on data insights for my /var/log/nginx/access.log. I tried many attempts but loki or prometheus didn’t provide me accurate data result, e.g. when I count specific API calls (sap calls) with linux…

---

## [Get accurate numbers for counter increases](https://discuss.prometheus.io/t/get-accurate-numbers-for-counter-increases/3483)

<div class="topic-metadata">

**Author:** [@waqarsky](https://discuss.prometheus.io/u/waqarsky)\
**Replies:** 1\
**Last updated:** [November 27, 2025, 11:09am UTC](https://discuss.prometheus.io/t/get-accurate-numbers-for-counter-increases/3483 "2025-11-27T11:09:07Z")

</div>

Assume that I have this counter, with the server scraping these metrics every 15 seconds. vector\_component\_sent\_events\_total{component\_id=~"sink.\*"} If the counter increases by 30. As shown in the picture below: Th…

---

## [False alerts with increase() when metric increases near the evaluation boundary - alert rule](https://discuss.prometheus.io/t/false-alerts-with-increase-when-metric-increases-near-the-evaluation-boundary-alert-rule/3451)

<div class="topic-metadata">

**Author:** [@Zapdos63](https://discuss.prometheus.io/u/Zapdos63)\
**Replies:** 0\
**Last updated:** [August 22, 2025, 9:02am UTC](https://discuss.prometheus.io/t/false-alerts-with-increase-when-metric-increases-near-the-evaluation-boundary-alert-rule/3451 "2025-08-22T09:02:49Z")

</div>

Hello, I’m facing an issue with an alerting rule that is giving false positives when metrics increase right near the evaluation boundary. Here are the details: Alerting Rule Query: ( (sum(increase(metrics\_listener\_ob…

---

## [Determining network latency between Prometheus server and a Windows endpoint](https://discuss.prometheus.io/t/determining-network-latency-between-prometheus-server-and-a-windows-endpoint/3449)

<div class="topic-metadata">

**Author:** [@jeremiahharbach](https://discuss.prometheus.io/u/jeremiahharbach)\
**Replies:** 1\
**Last updated:** [August 21, 2025, 4:53pm UTC](https://discuss.prometheus.io/t/determining-network-latency-between-prometheus-server-and-a-windows-endpoint/3449 "2025-08-21T16:53:53Z")

</div>

Our previous monitoring tool tracked ping latency (server → target). I have been asked to implement similar network latency tracking in Prometheus. I don’t think it needs to be ping/ICMP specifically but I know that co…

---

## [Prevent PromQL injection without regex-matching](https://discuss.prometheus.io/t/prevent-promql-injection-without-regex-matching/3447)

<div class="topic-metadata">

**Author:** [@wedwards](https://discuss.prometheus.io/u/wedwards)\
**Replies:** 0\
**Last updated:** [August 18, 2025, 3:57pm UTC](https://discuss.prometheus.io/t/prevent-promql-injection-without-regex-matching/3447 "2025-08-18T15:57:07Z")

</div>

Let’s say I have the following PromQL query: example\_metric{key="value"}\[60s\] Querying basics | Prometheus says: PromQL follows the same escaping rules as Go. … but it seems like quite a hassle to prevent injection…

---

## [Maximum and Minimum on Request Duration (Histograms))](https://discuss.prometheus.io/t/maximum-and-minimum-on-request-duration-histograms/3414)

<div class="topic-metadata">

**Author:** [@Tejaswini](https://discuss.prometheus.io/u/Tejaswini)\
**Replies:** 0\
**Last updated:** [June 18, 2025, 1:12pm UTC](https://discuss.prometheus.io/t/maximum-and-minimum-on-request-duration-histograms/3414 "2025-06-18T13:12:34Z")

</div>

Hi, I’m using Prometheus to monitor request durations via a histogram metric, e.g., http\_request\_duration\_seconds\_bucket. I would like to query: The minimum time taken by a request The maximum time taken by a request …

---

## [Http query\_range API maximum value](https://discuss.prometheus.io/t/http-query-range-api-maximum-value/890)

<div class="topic-metadata">

**Author:** [@raghav](https://discuss.prometheus.io/u/raghav)\
**Replies:** 1\
**Last updated:** [April 2, 2025, 10:28pm UTC](https://discuss.prometheus.io/t/http-query-range-api-maximum-value/890 "2025-04-02T22:28:16Z")

</div>

Hello All, I am trying to get maximum CPU and Memory utilization of a pod using query\_range endpoint. Query is: max by (pod) (max\_over\_time(sum by (pod)(container\_memory\_working\_set\_bytes{pod=~"pod-name-.\*", container…

---

## [Sum by () not working with label with dot in name](https://discuss.prometheus.io/t/sum-by-not-working-with-label-with-dot-in-name/3364)

<div class="topic-metadata">

**Author:** [@hlxdevops](https://discuss.prometheus.io/u/hlxdevops)\
**Replies:** 0\
**Last updated:** [March 31, 2025, 1:48pm UTC](https://discuss.prometheus.io/t/sum-by-not-working-with-label-with-dot-in-name/3364 "2025-03-31T13:48:25Z")

</div>

Hi, I am trying to understand why my PromQL query is not working as I expect. This query works as I expect and returns many results. sum by (job) (rate(traces\_span\_metrics\_duration\_milliseconds\_count{"deployment.enviro…

---

## [PromQL expression to compute difference in a counter but just 1 value for the full Range Time](https://discuss.prometheus.io/t/promql-expression-to-compute-difference-in-a-counter-but-just-1-value-for-the-full-range-time/3332)

<div class="topic-metadata">

**Author:** [@toni-moreno](https://discuss.prometheus.io/u/toni-moreno)\
**Replies:** 0\
**Last updated:** [March 13, 2025, 4:25pm UTC](https://discuss.prometheus.io/t/promql-expression-to-compute-difference-in-a-counter-but-just-1-value-for-the-full-range-time/3332 "2025-03-13T16:25:24Z")

</div>

Hello everybody. I would like to do a simple query to get just 1 number for each serie, the original metric is a counter, the result should be the last value minus the first value when the last value is greater than t…

---

## [Help with GitLab CI Pipeline Failure Alert - Fetching Failed Job Names & Pipeline ID](https://discuss.prometheus.io/t/help-with-gitlab-ci-pipeline-failure-alert-fetching-failed-job-names-pipeline-id/3289)

<div class="topic-metadata">

**Author:** [@nandini561](https://discuss.prometheus.io/u/nandini561)\
**Replies:** 0\
**Last updated:** [February 13, 2025, 7:58pm UTC](https://discuss.prometheus.io/t/help-with-gitlab-ci-pipeline-failure-alert-fetching-failed-job-names-pipeline-id/3289 "2025-02-13T19:58:53Z")

</div>

Hello everyone, I am working on setting up GitLab CI pipeline failure alerts in Slack using Prometheus and Alertmanager. My goal is to include the following details in the alert: Failed job count (:white\_check\_mark:Wo…

---

## [How to verify CPU Usage and Memory Usage Data from Prometheus data with cluster](https://discuss.prometheus.io/t/how-to-verify-cpu-usage-and-memory-usage-data-from-prometheus-data-with-cluster/3282)

<div class="topic-metadata">

**Author:** [@akash](https://discuss.prometheus.io/u/akash)\
**Replies:** 0\
**Last updated:** [February 8, 2025, 12:16pm UTC](https://discuss.prometheus.io/t/how-to-verify-cpu-usage-and-memory-usage-data-from-prometheus-data-with-cluster/3282 "2025-02-08T12:16:53Z")

</div>

Hi Team, I am new to Prometheus I have written PromQL to calculate cpu and memory usage when it is more than 80% CPU Usage Expression sum(rate(container\_cpu\_usage\_seconds\_total{container~=“”}\[5m\])) by (pod) / sum(kub…

---

## [Query to get number of series by dropping labels](https://discuss.prometheus.io/t/query-to-get-number-of-series-by-dropping-labels/3280)

<div class="topic-metadata">

**Author:** [@zfgao](https://discuss.prometheus.io/u/zfgao)\
**Replies:** 0\
**Last updated:** [February 7, 2025, 4:42pm UTC](https://discuss.prometheus.io/t/query-to-get-number-of-series-by-dropping-labels/3280 "2025-02-07T16:42:02Z")

</div>

HI, We have a Prometheus, saw 400k total series for my metric name from UI report . We saw several labels with a few hundred of values. Several of them such as msIndex is not used, not import. We think that if we drop t…

---

## [How to make the alert stay for long time?](https://discuss.prometheus.io/t/how-to-make-the-alert-stay-for-long-time/3248)

<div class="topic-metadata">

**Author:** [@Josthi](https://discuss.prometheus.io/u/Josthi)\
**Replies:** 0\
**Last updated:** [January 13, 2025, 11:28pm UTC](https://discuss.prometheus.io/t/how-to-make-the-alert-stay-for-long-time/3248 "2025-01-13T23:28:33Z")

</div>

Hi All, I have tried to the use the property “keep\_firing\_for” but when I deploy the alert I can’t see the configuration in the Prometheus UI. Any ideas?

---

## [Create label based on another queries value](https://discuss.prometheus.io/t/create-label-based-on-another-queries-value/3228)

<div class="topic-metadata">

**Author:** [@fue36](https://discuss.prometheus.io/u/fue36)\
**Replies:** 0\
**Last updated:** [December 27, 2024, 6:21pm UTC](https://discuss.prometheus.io/t/create-label-based-on-another-queries-value/3228 "2024-12-27T18:21:34Z")

</div>

The following Prometheus query bsnAPIfLoadChannelUtilization{bsnAPIfSlotId="0",job="cisco\_wlc\_9800",bsnAPName=~"(AP1)"}' generates the following labels and values: bsnAPIfLoadChannelUtilization{bsnAPIfSlotId="0", bsnAP…

---

## [Performance issues and limit exceeded while calculating percentile](https://discuss.prometheus.io/t/performance-issues-and-limit-exceeded-while-calculating-percentile/3200)

<div class="topic-metadata">

**Author:** [@ReinanHS](https://discuss.prometheus.io/u/ReinanHS)\
**Replies:** 0\
**Last updated:** [November 21, 2024, 7:41pm UTC](https://discuss.prometheus.io/t/performance-issues-and-limit-exceeded-while-calculating-percentile/3200 "2024-11-21T19:41:00Z")

</div>

Hello, community! I’m building a Grafana dashboard to monitor the latency of requests made to a specific API. The metrics are being collected via the Google Cloud Managed Service for Prometheus and accessed in Grafana u…

---

## [Timestamp of last metric change](https://discuss.prometheus.io/t/timestamp-of-last-metric-change/108)

<div class="topic-metadata">

**Author:** [@yanick](https://discuss.prometheus.io/u/yanick)\
**Replies:** 2\
**Last updated:** [October 30, 2024, 10:40am UTC](https://discuss.prometheus.io/t/timestamp-of-last-metric-change/108 "2024-10-30T10:40:52Z")

</div>

Hi all, I am using Grafana and prometheus and I am trying to get the timestamp at which a given metric last had it’s value changed. Based on information found here : https://stackoverflow.com/questions/54148451/get-time…

---

## [Aggregation query returns empty result when one of the label match dont have the data](https://discuss.prometheus.io/t/aggregation-query-returns-empty-result-when-one-of-the-label-match-dont-have-the-data/3170)

<div class="topic-metadata">

**Author:** [@BrivinTech](https://discuss.prometheus.io/u/BrivinTech)\
**Replies:** 1\
**Last updated:** [October 22, 2024, 1:41pm UTC](https://discuss.prometheus.io/t/aggregation-query-returns-empty-result-when-one-of-the-label-match-dont-have-the-data/3170 "2024-10-22T13:41:54Z")

</div>

I have a lot of series of metrics in the prometheus server. example, metric1 {name=“test”} 10 , metric2{name=“ex”} 15 and metric2{name=“ex2”} 20… when i do the promQL like below sum by (name) sum\_over\_time(metric1…

---

## [Updating an old grafana dashboard](https://discuss.prometheus.io/t/updating-an-old-grafana-dashboard/3158)

<div class="topic-metadata">

**Author:** [@CanadaBri](https://discuss.prometheus.io/u/CanadaBri)\
**Replies:** 1\
**Last updated:** [October 10, 2024, 1:46pm UTC](https://discuss.prometheus.io/t/updating-an-old-grafana-dashboard/3158 "2024-10-10T13:46:49Z")

</div>

Hello, I am trying to update an old grafana dashboard, but the new queries are not returning data, although checking the metrics indicates there is data. I am not using wmi\_exporter - I have changed that to windows\_exp…

---

## [Idelta and counters](https://discuss.prometheus.io/t/idelta-and-counters/3152)

<div class="topic-metadata">

**Author:** [@shabba133](https://discuss.prometheus.io/u/shabba133)\
**Replies:** 0\
**Last updated:** [October 3, 2024, 2:01pm UTC](https://discuss.prometheus.io/t/idelta-and-counters/3152 "2024-10-03T14:01:58Z")

</div>

Hi folks There’s a throwaway line in the docs for idelta (https://prometheus.io/docs/prometheus/latest/querying/functions/#idelta) which says… idelta should only be used with gauges. My question is (and forgive me i…

---

## [How can I add label "PromQL Query Result" that has no label](https://discuss.prometheus.io/t/how-can-i-add-label-promql-query-result-that-has-no-label/2416)

<div class="topic-metadata">

**Author:** [@samuel.kwon](https://discuss.prometheus.io/u/samuel.kwon)\
**Replies:** 0\
**Last updated:** [September 23, 2024, 7:36am UTC](https://discuss.prometheus.io/t/how-can-i-add-label-promql-query-result-that-has-no-label/2416 "2024-09-23T07:36:14Z")

</div>

Hi, I’m new in PromQL I have lots of VMs, almost 300. each VM has prometheus label named “team” (1) I add each team’s VMs cpu usage(team A, team B, team C, …) (2) I add all VM’s cpu usage(team A+team B+team C+team D+…) …

---

## [How to calculate the time a service has been up using promql?](https://discuss.prometheus.io/t/how-to-calculate-the-time-a-service-has-been-up-using-promql/2379)

<div class="topic-metadata">

**Author:** [@epodegrid](https://discuss.prometheus.io/u/epodegrid)\
**Replies:** 0\
**Last updated:** [August 20, 2024, 9:45am UTC](https://discuss.prometheus.io/t/how-to-calculate-the-time-a-service-has-been-up-using-promql/2379 "2024-08-20T09:45:25Z")

</div>

Hello! I have a service that returns status 1 if the application is up, or status 0 if the application is down. I’m trying to have a graph in grafana that shows the the total time the application is online at a stretch.…

---

## [Limit the number of results in a range vector?](https://discuss.prometheus.io/t/limit-the-number-of-results-in-a-range-vector/2367)

<div class="topic-metadata">

**Author:** [@crodie](https://discuss.prometheus.io/u/crodie)\
**Replies:** 0\
**Last updated:** [August 1, 2024, 11:14pm UTC](https://discuss.prometheus.io/t/limit-the-number-of-results-in-a-range-vector/2367 "2024-08-01T23:14:17Z")

</div>

Hello, I am trying to limit the results returned in range vector. I tried using topk to limit my return but it is returning more than n specified. I found this on the web: This is because it returns top N time series…

---

## [Energy Stats query](https://discuss.prometheus.io/t/energy-stats-query/2341)

<div class="topic-metadata">

**Author:** [@tukane](https://discuss.prometheus.io/u/tukane)\
**Replies:** 0\
**Last updated:** [July 8, 2024, 7:08am UTC](https://discuss.prometheus.io/t/energy-stats-query/2341 "2024-07-08T07:08:15Z")

</div>

Hi, I’m trying to build an energy dashboard with Grafana, but have problems with writing the correct PromQL queries. My energy meter reports the total used energy in kWh sensor\_energy\_kwh{entity=“sensor.power\_consumpti…

---

## [Why can't prometheus show range vector output in range query](https://discuss.prometheus.io/t/why-cant-prometheus-show-range-vector-output-in-range-query/2334)

<div class="topic-metadata">

**Author:** [@savannahar68](https://discuss.prometheus.io/u/savannahar68)\
**Replies:** 0\
**Last updated:** [July 4, 2024, 4:20pm UTC](https://discuss.prometheus.io/t/why-cant-prometheus-show-range-vector-output-in-range-query/2334 "2024-07-04T16:20:06Z")

</div>

Hi everyone, I’ve observed that the output of a Range Vector in an Instant Query (Table view) and an Instant Vector in a Range Query (Graph view) produces the same data. Given this similarity in response, I’m curious to…

---

## [Understanding Range Duration with Prometheus Range Queries](https://discuss.prometheus.io/t/understanding-range-duration-with-prometheus-range-queries/2330)

<div class="topic-metadata">

**Author:** [@savannahar68](https://discuss.prometheus.io/u/savannahar68)\
**Replies:** 0\
**Last updated:** [July 4, 2024, 6:28am UTC](https://discuss.prometheus.io/t/understanding-range-duration-with-prometheus-range-queries/2330 "2024-07-04T06:28:19Z")

</div>

Hello Prometheus Community, I have a question regarding evaluating range vectors within a range query. Specifically, I’m trying to understand how Prometheus processes the range vector in conjunction with the given start…

---

## [Nodata to Zero values query](https://discuss.prometheus.io/t/nodata-to-zero-values-query/2320)

<div class="topic-metadata">

**Author:** [@abhilash](https://discuss.prometheus.io/u/abhilash)\
**Replies:** 0\
**Last updated:** [June 26, 2024, 4:59am UTC](https://discuss.prometheus.io/t/nodata-to-zero-values-query/2320 "2024-06-26T04:59:04Z")

</div>

Topic: Handling Missing HAProxy Logs in Prometheus Across Multiple Clusters Context: I’m currently working on monitoring HAProxy logs using Loki and Prometheus. I’ve created a recording rule in Loki to count the logs: …

---

## [Increment of a counter metrics in the last hour divided by 5 mins](https://discuss.prometheus.io/t/increment-of-a-counter-metrics-in-the-last-hour-divided-by-5-mins/2299)

<div class="topic-metadata">

**Author:** [@enchandan](https://discuss.prometheus.io/u/enchandan)\
**Replies:** 0\
**Last updated:** [June 12, 2024, 8:21am UTC](https://discuss.prometheus.io/t/increment-of-a-counter-metrics-in-the-last-hour-divided-by-5-mins/2299 "2024-06-12T08:21:10Z")

</div>

Hello community, I have a counter metrics say api\_msg\_count which keeps on increasing based on incoming no. of messages to the api. I want to show this increase of no. of messages on a graph. It should be for the last …

[Next page](https://discuss.prometheus.io/c/promql/6.md?page=1)
