🌐
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: topk(3, sum by (app, proc) (rate(instance_cpu_time_ns[5m])))
Discussions

Sum values grup by instance
Hi all, I’ve some templates to show data. One of this is reporting the sum of all instances calculating the percent as follow: sum(purefa_array_space_used_bytes)/sum(purefa_array_space_capacity_bytes) It reports the total percent of the used space of all systems, one single value Due the ... More on community.grafana.com
🌐 community.grafana.com
2
0
March 16, 2022
Division of a grouped sum in prometheus - Stack Overflow
When querying a prometheus metric, I would like to group the sum and divide the grouped results on a second metric. While the simple grouped sum function works: sum by(somefield) (gauge_metric) ... More on stackoverflow.com
🌐 stackoverflow.com
April 1, 2020
Group data by year/month/day in prometheus - Stack Overflow
As the title says, I am looking for a way to get the maximum value of a time series, which resets daily. After this task is achieved I would like to create a sum over those values to get a value per More on stackoverflow.com
🌐 stackoverflow.com
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
People also ask

What is the difference between group by and sum by in Prometheus?
group by defines which labels to keep when aggregating data. sum by combines the sum() aggregation function with group by to add up matching time series while retaining only the specified labels.
🌐
last9.io
last9.io › blog › prometheus-group-by-label
Prometheus Group By Label: Advanced Aggregation Techniques for ...
How can I group labels in a Prometheus query?
Use by (label1, label2) to retain specific labels or without (label) to exclude one or more. For example: sum(cpu_usage) by (region) sum(memory_usage) without (instance)
🌐
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 ...
🌐
Last9
last9.io › blog › prometheus-group-by-label
Prometheus Group By Label: Advanced Aggregation Techniques for Monitoring | Last9
June 12, 2026 - In Prometheus, group by is an operator ... just defines how data should be grouped. On the other hand, sum by (...) combines the sum() aggregation function with group by....
🌐
Grafana
community.grafana.com › prometheus
Sum values grup by instance - Prometheus - Grafana Labs Community Forums
March 16, 2022 - Hi all, I’ve some templates to show data. One of this is reporting the sum of all instances calculating the percent as follow: sum(purefa_array_space_used_bytes)/sum(purefa_array_space_capacity_bytes) It reports the total percent of the used space of all systems, one single value Due the ...
🌐
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 - If you want to count the total number of requests grouped by the method label (e.g., GET, POST), you can use: ... This query sums the total requests and groups the result by the method label, giving you the total number of requests for each ...
🌐
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 - PromQL (Prometheus Query Language) is a powerful query language used to extract and analyze metrics from time-series data stored in Prometheus. It’s designed for use in monitoring and alerting systems, allowing users to query and aggregate metrics effectively. In this blog, we’ll cover grouping in PromQL, explore the core functions, and look at various ways to combine them to build insightful queries. Grouping in PromQL helps in aggregating data across multiple dimensions. It allows you to summarize or categorize metrics based on their labels.
🌐
Coralogix
coralogix.com › home › promql tutorial: 5 tricks to become a prometheus god
PromQL Tutorial: 5 Tricks to Become a Prometheus God
June 3, 2025 - For the next step, we need to get the pod labels, “pod” and “label_app”. We can do this with the query: group(kube_pod_labels{label_app=~”redash-*”}) by (label_app, pod)
Find elsewhere
🌐
Prometheus
prometheus.io › docs › prometheus › latest › querying › functions
Query functions | Prometheus
The quantile is calculated for each label combination in http_request_duration_seconds. To aggregate, use the sum() aggregator around the rate() function. Since the le label is required by histogram_quantile() to deal with classic histograms, it has to be included in the by clause.
🌐
Promlabs
promlabs.com › promql-cheat-sheet
PromLabs | PromQL Cheat Sheet
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 - 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? Contact us. Published by Brian Brazil in Posts · Tags: node exporter, prometheus, promql ·
🌐
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 - Proper label grouping significantly improves query performance and data visualization. group() drops specified labels without modifying values, while sum() aggregates values across the grouped labels.
🌐
Prometheus
prometheus.io › docs › prometheus › latest › querying › operators
Operators | Prometheus
If the metric memory_consumption_bytes ... in the total memory consumption in all applications, we could simply write: ... avg(v) divides the sum of v by the number of aggregated samples in the same way as the / binary operator....
🌐
Google Groups
groups.google.com › g › prometheus-users › c › 8m7tkdB_8sk
Sum over time without instance
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message · to Prometheus Users · Thanks! I didn't know by or without would work like that, so now I know. :) fantastic. This is now I think a working query: round(sum(max by (serverId, clusterId) (increase(server_statistics_total{statistic="failed", serverId=~"$serverId"}[$__range])) > 0)) Do you think that is as accurate as possible with a gauge and multiple metric providers?
🌐
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?
🌐
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
sum by(instance)(rate(prometheus_tsdb_compaction_duration_seconds_sum[5m])) / sum by(instance)(rate(prometheus_tsdb_compaction_duration_seconds_count[5m]))
Author: jitendra-1217
🌐
Sambaiz
sambaiz.net › en › article › 491
Get and aggregate metrics with PromQL - sambaiz-net
June 9, 2024 - sum(prometheus_http_requests_total) sum_over_time(prometheus_http_requests_total[5m]) rate(v range-vector) returns the average increment per second of a monotonically increasing counter, caring about resets of the value.
🌐
Google Groups
groups.google.com › g › prometheus-developers › c › pul4HF4OS0E
Is it possible to sum a metric by day?
sum_over_time(your_recorded_rule[1y]) to get separate sums over each day (although you probably want to record an · increase(your_series) for that to be of any use). Probably not worth it, though. :o) ... -- You received this message because you are subscribed to a topic in the Google Groups "Prometheus Developers" group.
🌐
Fiberplane
fiberplane.com › blog › why-are-prometheus-queries-hard
Why are Prometheus queries hard? | Fiberplane Blog
July 4, 2023 - When querying our data, we often care about some of those label dimensions and not others. In PromQL, sum by (label1, label2,…) groups the time series by the labels you specify and uses the sum function to merge series together (similar to ...