🌐
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(). For example:
🌐
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 - The by() modifier groups metrics by a specified set of labels. For example, if you're monitoring HTTP requests across different endpoints and instances, you might want to group the metrics by instance or job.
🌐
Coralogix
coralogix.com › home › promql tutorial: 5 tricks to become a prometheus god
PromQL Tutorial: Basic Concepts & Examples - Coralogix
June 3, 2025 - Aggregation is a great way to construct powerful PromQL queries. 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.
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 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 ...
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 ...
🌐
Promlabs
promlabs.com › promql-cheat-sheet
PromLabs | PromQL Cheat Sheet
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 ...
🌐
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:
🌐
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.
🌐
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, r.timestamps, r.values FROM ( (SELECT time_series_id, array_agg(timestamp ORDER BY timestamp) AS timestamps, array_agg(value ORDER BY timestamp) 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, since it doesn’t take into account time ranges and down-sampling, which are automatically handled by /query_range API for PromQL with start, end and step args.
🌐
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 - For instance, if you want to count the total requests grouped by both method and status, you can do: ... This query returns the total number of requests for each combination of HTTP method and status. If you want to aggregate metrics while ignoring certain labels, you can use the without keyword. For example, if you want to sum total requests but ignore the instance label, you can write:
Find elsewhere
🌐
Robust Perception
robustperception.io › using-the-group-aggregator-in-promql
Using the group() aggregator in PromQL – Robust Perception | Prometheus Monitoring Experts
August 10, 2020 - count without(cpu) ( group without(mode) (node_cpu_seconds_total) ) Finally, as the value is 1 you could also use sum for the outer aggregation similarly to how you could for info metrics. Have PromQL questions?
🌐
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.
🌐
Grafana
grafana.com › blog › 2021 › 08 › 04 › how-to-use-promql-joins-for-more-effective-queries-of-prometheus-metrics-at-scale
How to use PromQL joins for more effective queries of Prometheus metrics at scale | Grafana Labs
August 5, 2021 - groups: - name: slo_metric expr: count by (reference_label) ((api_response_latency * on (labelone,labeltwo) group_left(reference_label) sli_info > 100) This would work for every metric with those label names and associated mappings.
🌐
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
🌐
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 - This query calculates the average rate of POST HTTP requests over the last 5 minutes, grouped by the job label. PromQL queries can become resource-intensive, particularly when dealing with a high cardinality dataset or long time ranges.
🌐
Roosterschicken
roosterschicken.ca › gasai › promql-group-by
promql group by
November 12, 2024 - Prometheus, the open-source monitoring and alerting system, utilizes PromQL (Prometheus Query Language) for powerful data querying. One of its key functionalities is the group_by function, which allows you to aggregate time series data based on specific labels.
🌐
Greptime
greptime.com › home › blog › introduction to promql for cloud-native observability and time series data analysis
Introduction to PromQL for Cloud-Native Observability and Time Series Data Analysis | Greptime
February 14, 2023 - For example, if we want to query cities where the average noise is greater than 100 dB for the past month. ... SELECT city, AVG(noise) as avg_noise FROM city_env_noise_total GROUP BY city, DATE(timestamp) HAVING AVG(noise) > 100;
🌐
Webscale
webscale.com › home › blog › prometheus querying – breaking down promql
PromQL Querying: group_left, Joins, and Working Examples
June 8, 2026 - Working PromQL examples for group_left, ignoring, and label matching. Written by SREs running Prometheus in production at commerce scale.
🌐
DoHost
dohost.us › home › 2025 › september › 27 › advanced querying: using labels and grouping in promql
Advanced Querying: Using Labels and Grouping in PromQL - DoHost
September 27, 2025 - Think of `by` as “group keeping only these labels” and `without` as “group ignoring these labels”. Use `rate` for steadily increasing counters and `irate` for more volatile counters that might reset frequently. `irate` can give you more accurate results in such scenarios because it only looks at the last two data points. Yes, you can use multiple aggregation operators in a single PromQL query.
🌐
Prometheus
prometheus.io › docs › prometheus › latest › querying › basics
Querying basics | Prometheus
Other programs can fetch the result of a PromQL expression via the HTTP API. This document is a Prometheus basic language reference. For learning, it may be easier to start with a couple of examples. The value of a sample at a given timestamp returned by PromQL may be a float or a native histogram.
🌐
Iximiuz
iximiuz.com › en › posts › prometheus-vector-matching
Prometheus Cheat Sheet - How to Join Multiple Metrics (Vector Matching)
November 30, 2021 - PromQL comes with 15 binary operators that can be divided into three groups by operation type: