🌐
Medium
medium.com › @suchitasharma1106 › a-comprehensive-guide-to-grouping-and-functions-in-promql-cc3c438be320
A Comprehensive Guide to Grouping and Functions in PromQL | by Suchita Sharma | Medium
October 7, 2024 - It allows you to summarize or categorize metrics based on their labels. There are two types of grouping: Without Grouping (without()): Removes certain labels from the aggregation. By Grouping (by()): Aggregates data based on specified labels.
Discussions

Group by option in query for prometheus
Is there a way to do a group by query on Prometheus database like there’s for Graphite databases? More on community.grafana.com
🌐 community.grafana.com
2
0
June 15, 2017
Prometheus Query - Group by values and return a count - Stack Overflow
I have a metric that returns a few unique values for each timeseries. (This is from Prometheus Blackbox Exporter). See example below How can I group these by value and return a count. The followin... More on stackoverflow.com
🌐 stackoverflow.com
promql - Group by measure values returned by aggregation - Stack Overflow
I am taking maximum value of a measure (stage) by group (instance) and then I want to show by maximum stage, what is the number of instances. In SQL, this would be: select max_stage, count(*) from ( More on stackoverflow.com
🌐 stackoverflow.com
March 17, 2022
prometheus - Group by time and aggregate in PromQL/MetricsQL - Stack Overflow
I have a metric say x, of type gauge, And the values are reported every 5m. Now I want to make a query such that, I get sum of values in each hour in a day. Exmaple: from 3PM to 5PM, the gauge valu... More on stackoverflow.com
🌐 stackoverflow.com
People also ask

How to use group by in PromQL?
Place the by clause after an aggregation function like sum(), avg(), or count(). For example: sum(http_requests_total) by (service, region) This aggregates the metric and groups results by service and region.
🌐
last9.io
last9.io › blog › prometheus-group-by-label
Prometheus Group By Label: Advanced Aggregation Techniques for ...
How do I use the "group by" function to aggregate metrics by label in Prometheus?
Combine aggregation and grouping like this: sum(rate(http_requests_total[5m])) by (service) This gives the request rate per service by summing over time.
🌐
last9.io
last9.io › blog › prometheus-group-by-label
Prometheus Group By Label: Advanced Aggregation Techniques for ...
How do I use the "group by" function with labels in Prometheus queries?
Apply by (label) after an aggregation function. For example: avg(cpu_usage_seconds_total) by (service) This gives the average CPU usage grouped by service.
🌐
last9.io
last9.io › blog › prometheus-group-by-label
Prometheus Group By Label: Advanced Aggregation Techniques for ...
🌐
Coralogix
coralogix.com › home › promql tutorial: 5 tricks to become a prometheus god
PromQL Tutorial: Basic Concepts & Examples - Coralogix
June 3, 2025 - If you’re familiar with SQL, you’ll remember that GROUP BY allows you to group results by a field (e.g country or city) and apply an aggregate function, such as AVG() or COUNT(), to values of another field.
🌐
Last9
last9.io › blog › prometheus-group-by-label
Prometheus Group By Label: Advanced Aggregation Techniques for Monitoring | Last9
June 12, 2026 - How to use group by in PromQL? Place the by clause after an aggregation function like sum(), avg(), or count().
🌐
Promlabs
promlabs.com › promql-cheat-sheet
PromLabs | PromQL Cheat Sheet
Go get our self-paced in-depth PromQL training! Select latest sample for series with a given metric name: ... Available aggregation operators: sum(), min(), max(), avg(), stddev(), stdvar(), count(), count_values(), group(), bottomk(), topk(), quantile() ... Only keep series from the left-hand side whose sample values are larger than their right-hand-side matches: ... histogram_quantile( 0.9, sum by(le, path, method) ( rate(demo_api_request_duration_seconds_bucket[5m]) ) )
🌐
Robust Perception
robustperception.io › using-the-group-aggregator-in-promql
Using the group() aggregator in PromQL – Robust Perception | Prometheus Monitoring Experts
August 10, 2020 - This is where group comes in. group always produces 1 as a the value of the aggregation group, but more importantly signifies for anyone reading the PromQL expression that it is the aggregation's label handling that is what's important rather than the numeric result:
🌐
Prometheus
prometheus.io › docs › prometheus › latest › querying › examples
Query examples | Prometheus
...we could get the top 3 CPU users grouped by application (app) and process type (proc) like this:
Find elsewhere
🌐
Grafana
community.grafana.com › prometheus
Group by option in query for prometheus - Prometheus - Grafana Labs Community Forums
June 15, 2017 - Is there a way to do a group by query on Prometheus database like there’s for Graphite databases?
🌐
SigNoz
signoz.io › guides › how to group labels in prometheus queries - a practical guide
How to Group Labels in Prometheus Queries - A Practical Guide | SigNoz
July 24, 2024 - Prometheus Query Language (PromQL) offers powerful tools for label grouping. The primary method involves using the group() operator along with the by clause. ... This query groups all CPU metrics, retaining only the "instance" label.
🌐
Better Stack
betterstack.com › community › questions › how-can-group-labels-in-prometheus-query
How Can I Group Labels in a Prometheus Query? | Better Stack Community
August 5, 2025 - Grouping labels in a Prometheus ... across different dimensions. You can use the by clause in Prometheus Query Language (PromQL) to group your results according to one or more labels....
🌐
Medium
valyala.medium.com › promql-tutorial-for-beginners-9ab455142085
PromQL tutorial for beginners and humans | by Aliaksandr Valialkin | Medium
September 15, 2023 - SELECT ts.metric_name_plus_tags, ... AS values FROM metrics WHERE time_series_id IN ( SELECT id FROM time_series WHERE metric_name = 'node_network_receive_bytes_total' ) GROUP BY time_series_id ) ) AS r JOIN time_series AS ts ON (r.time_series_id = ts.id) Easy, isn’t it? :) The SQL must be even more complex in order to be on par with the one-word PromQL query above, ...
🌐
Prometheus
prometheus.io › docs › prometheus › latest › querying › operators
Operators | Prometheus
limit_ratio(r, v) (sample a ... --enable-feature=promql-experimental-functions) group(v) (all values in the resulting vector are 1) ... These operators can either be used to aggregate over all label dimensions or preserve distinct dimensions by including a without or ...
🌐
Google Groups
groups.google.com › g › prometheus-users › c › VmYTkQhO5Kg
PromQL: multiple queries with dependent values
October 13, 2022 - The correct value is 10: 5 `instance`'s x 2 `service`'s · > Let's say 16 is the correct answer for group="group-a" and service="exporter-redis-6379". Perhaps you didn't show the full set of "up" metrics. In which case, I'd first try to build an "up" query which gives the expected answer 16 on the right-hand side. Maybe something like this: > > count by (service, group) (up{service=~"exporter-redis-.*"}) >
🌐
Logz.io
logz.io › home › blog › how to › an intro to promql: basic concepts & examples
An Intro to PromQL: Basic Concepts & Examples | Logz.io
September 2, 2023 - Similarly, PromQL lets you group multiple labels together, then sorting according to those groupings. If you want a more thorough intro to installation and configuration, check out our recent Prometheus tutorial for system and Docker metrics. To be clear, there are two kinds of “types” in Prometheus. There are the metric types of metrics and the data types of PromQL expressions. ... Counters give the absolute value of something, such as prometheus_http_requests_total or prometheus_sd_consul_rpc_duration_seconds_count.
🌐
GitHub
github.com › prometheus › prometheus › discussions › 12205
Promql group by label for absent or absent_over_time · prometheus/prometheus · Discussion #12205
So the way I'm filling value with 0 is by doing · sum without() (up{service="service1"}) or (0 * absent(up{service="service1"})) This works if I specify service label, but I have many services, I want to have 0 filled for all of them, but absent or absent_over_time does not support group by label, which means (sum without() (up) or (0 * absent(up))) just doesn't work.
Author: prometheus
🌐
DevOps.dev
blog.devops.dev › advanced-promql-understanding-optimizing-and-logical-grouping-of-queries-11220e80ba0d
Advanced PromQL: Understanding, Optimizing, and Logical Grouping of Queries | by Ashutosh Singh | DevOps.dev
July 20, 2023 - Logical grouping allows you to ... on label values. This is particularly useful when dealing with multi-dimensional data. ... In this query, we’re summing up the rate of HTTP requests over the last 5 minutes. However, we’re not just getting a single sum. The by (job, instance) part means we’re getting a separate sum for each unique combination of job and instance labels. This gives us a more granular view of our data. ... This is just a small subset of what PromQL ...
🌐
GitHub
github.com › jitendra-1217 › promql.cheat.sheet
GitHub - jitendra-1217/promql.cheat.sheet: PromQL cheat sheet - Usage and examples of basics, aggregations & functions · GitHub
→ min, max The min and max aggregators return the minimum or maximum value within a group as the value of the group. → topk Returns the K time series with the biggest values · topk without(device, fstype, mountpoint)(K, node_filesystem_size_bytes)
Author: jitendra-1217