It's even easier
sum by (group) (my_metric)
Answer from uamanager on Stack Overflow Top answer 1 of 3
74
It's even easier
sum by (group) (my_metric)
2 of 3
57
Yes, you can you use label replace to group all the misc together:
sum by (new_group) (
label_replace(
label_replace(my_metric, "new_group", "$1", "group", ".+"),
"new_group", "misc", "group", "misc group.+"
)
)
The inner label_replace copies all values from group into new_group, the outer overwrites those which match "misc group.+" with "misc", and we then sum by the "new_group" label. The reason for using a new label is the series would no longer be unique if we just overwrote the "group" label, and the sum wouldn't work.
How do I group data together based on a label?
Hi all. I’m trying to make a bar-gauge that shows per-CPU-core load using node_exporter. I’ve found that node_cpu_seconds_total{mode!=“idle”} gives me the data for all non-idle processes, but it also outputs all seven categories of load individually, per core, of which I have 32. More on community.grafana.com
grafana - How can I group values by label in Prometheus query? - Stack Overflow
This is my metric data sync_unit_type {region="krg"} 1731441289. Value is datetime represented as seconds (Unix time). There are different regions, also values are updated constantly ever... More on stackoverflow.com
Grafana & Prometheus how to group values by label after regex applied? - Stack Overflow
I've been trying to create a query that displays the average latency of each path on my application, while using Promql on Grafana: sum by(path) (rate(http_server_latency_milliseconds_sum[$ More on stackoverflow.com
How to display graph by group and instance?
I have a stack of Grafana, prometheus and Node executor. In prometheus I have labels instance and group. Where my instance query all ip and my group segragate this IP’s to their respective environments(projects). Now here is the trivial question. When i try to create a template in grafana ... More on community.grafana.com
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 ...
What is the job label in Prometheus?
The job label identifies the target being scraped. It’s automatically assigned by Prometheus and helps group metrics by application, service, or source as defined in the scrape configuration.
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 ...
Grafana
community.grafana.com › prometheus
Count and group by day based on label value - Prometheus - Grafana Labs Community Forums
March 30, 2023 - What Grafana version and what operating system are you using? Grafana v9.1.4 What are you trying to achieve? I’m collecting metrics about log files with filestat_exporter, and i would like to have graphic with the count of rotated logs per day based on values of the label path. file_stat_size_bytes{fqdn=~“$fqdn”,path=~“/var/log/mylog-[0-9].*.log”} so the path label has values like this: /var/log/mylog-2023-03-18.0.log /var/log/mylog-2023-03-18.1.log /var/log/mylog-2023-03-18.2.log ...
Grafana
community.grafana.com › time series panel
How do I group data together based on a label? - Time Series Panel - Grafana Labs Community Forums
November 13, 2020 - Hi all. I’m trying to make a bar-gauge that shows per-CPU-core load using node_exporter. I’ve found that node_cpu_seconds_total{mode!=“idle”} gives me the data for all non-idle processes, but it also outputs all seven categories of load individually, per core, of which I have 32.
Stack Overflow
stackoverflow.com › questions › 79181729 › how-can-i-group-values-by-label-in-prometheus-query
grafana - How can I group values by label in Prometheus query? - Stack Overflow
max by (region) (sync_unit_type{job="main (prod)", region=~"$Region"} * 1000) (multiplying by 1000 as Grafana expects milliseconds) I already configured $Region dashboard variable, so I can filter out values by specific region. ... What is the actual question here? Query seems fine, grouping is already done.
Stack Overflow
stackoverflow.com › questions › 79318554 › grafana-prometheus-how-to-group-values-by-label-after-regex-applied
Grafana & Prometheus how to group values by label after regex applied? - Stack Overflow
Since you are dealing with division, you'll need to handle label grouping inside promql, not Grafana. For that you can use label_replace around each rate two times. ... Hm, even one label_replace per each part should be enough: sum by(new_path) ...
Last9
last9.io › blog › prometheus-group-by-label
Prometheus Group By Label: Advanced Aggregation Techniques for Monitoring | Last9
June 12, 2026 - Each added label multiplies your time series count. That impacts performance, storage, and readability. Example: 3 services × 2 environments × 3 regions = 18 time series Just grouping by service = 3 time series · If your queries are slow or your dashboards feel noisy, this is often the reason. Start with the coarsest view that answers your question, and refine only when needed. ... For a breakdown of useful Prometheus functions like rate(), increase(), and quantile(), this blog covers it well.
Grafana
community.grafana.com › t › how-to-display-graph-by-group-and-instance › 3593
How to display graph by group and instance? - Grafana Labs Community Forums
November 3, 2017 - I have a stack of Grafana, prometheus and Node executor. In prometheus I have labels instance and group. Where my instance query all ip and my group segragate this IP’s to their respective environments(projects). Now here is the trivial question. When i try to create a template in grafana - datasource:prometheus query: label_values(node_boot_time,instance) => it displays IP only in preview.
Grafana
community.grafana.com › prometheus
Group by option in query for prometheus - #3 by valyala - Prometheus - Grafana Labs Community Forums
February 15, 2022 - Small correction to the answer above - the metric must be wrapped into aggregate function. For example, sum(metric) by (label).
Grafana
grafana.com › blog › how-to-extract-label-values-from-prometheus-metrics-in-grafana
How to extract label values from Prometheus metrics in Grafana | Grafana Labs
February 24, 2023 - In this blog post, we’ll show you how to visualize labels and extract value from your Prometheus metrics in Grafana. Continue reading to find out how, and check out this finished simple dashboard available on Grafana Play so you can follow along or tinker with it yourself. Let’s start with a Prometheus data source.
Grafana
community.grafana.com › prometheus
Grafana table with sum of two prometheus labels, first label as row and second as column - Prometheus - Grafana Labs Community Forums
August 24, 2022 - I have the following Prometheus query with a gauge metric: sum by (service, status) (service_results_total) The metric is more granular and has other labels, that’s why aggregation is needed. I’d like to generate a table where the service label is the row and the status label is the column ...
SigNoz
signoz.io › guides › how to write prometheus queries to return label values
How to Write Prometheus Queries to Return Label Values | SigNoz
July 25, 2024 - This query returns the total number of HTTP requests grouped by the method label. Regular expressions are powerful tools for label queries. To select all metrics where the endpoint label starts with /api: ... When performing operations on metrics ...
Google Groups
groups.google.com › g › prometheus-developers › c › oK_bx8rHmZs
hi how do i get all labels list in prometheus?
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message ... Just want to follow up with some more information.. For selecting dynamically {__name__=~".+"} will get all of your metrics. sum by(__name__) ({__name__=~".+"}) will get just their names without extra label/redundancy cruft. Additionally, to enable the filtering the original poster seems to desire I think he will need multiple Grafana Template Variables.
Reddit
reddit.com › r/prometheusmonitoring › prometheus group by wildcard substring of label
r/PrometheusMonitoring on Reddit: Prometheus group by wildcard substring of label
May 18, 2024 - groups: - name: registration-availability rules: - record: slo:sli_error:ratio_rate5m expr: |- (avg_over_time( ( ( (sum(rate( fastapi_responses_total{ app_name=~".*registration-api.*", status_code!~"5.."}[5m] )) ) / on(app_name) group_right() (sum(rate( fastapi_responses_total{ app_name=~".*registration-api.*"}[5m]) )) ) OR on() vector(0))[5m:60s]) ) labels: slo_id: registration-availability slo_service: registration slo: availability - name: checkout-availability rules: - record: slo:sli_error:ratio_rate5m expr: |- (avg_over_time( ( ( (sum(rate( fastapi_responses_total{ app_name=~".*checkout-api.*", status_code!~"5.."}[5m] )) ) / on(app_name) group_right() (sum(rate( fastapi_responses_total{ app_name=~".*checkout-api.*"}[5m]) )) ) OR on() vector(0))[5m:60s]) ) labels: slo_id: checkout-availability slo_service: checkout slo: availability
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]))) Assuming this metric contains one time series per running instance, you could count the number of running instances per application like this: ... If we are exploring some metrics for their labels, to e.g.