For the singlestat panel, you can just sum the two metrics and then add them together. Here is an example with two different metrics:

sum(prometheus_local_storage_memory_series) + sum(counters_logins)

Recommended reading, just in case you are doing anything with rates as well: https://www.robustperception.io/rate-then-sum-never-sum-then-rate/

Answer from Daniel Lee on Stack Overflow
Top answer
1 of 2
17

This is the expected behavior when using a binary operator: both side must have a matching label set to be taken into account.

If you want to be able to aggregate both side and get the single one, you first must get the union of different metrics using the __name__ label:

 sum by(__name__,type)(metric_a{job=~"provision-dev"}) or on(__name__) sum by(__name__,type)(metric_b{job=~"provision-dev"})

You can cascade the aggregation operator:

sum by (type) (sum by (__name__,type)(metric_a{job=~"provision-dev"}) or on(__name__) sum by(__name__,type)(metric_b{job=~"provision-dev"}))

Finally, you can also compact everything into:

sum by (type) ({__name__=~"metric_a|metric_b",job=~"provision-dev"})
2 of 2
10

The following PromQL query should sum metric_a and metric_b by type:

(sum(metric_a) by (type) + sum(metric_b) by (type))
or
(sum(metric_a) by (type) unless sum(metric_b) by (type))
or
(sum(metric_b) by (type) unless sum(metric_a) by (type))

How it works:

  • The sum(metric_a) by (type) + sum(metric_b) by (type) sums time series with matching type label values on both sides of + according to matching rules
  • The sum(metric_a) by (type) unless sum(metric_b) by (type) returns sum(metric_a) by (type) results for type label values missing in sum(metric_b) by (type). See docs about unless operator.
  • The sum(metric_b) by (type) unless sum(metric_a) by (type) returns sum(metric_a) by (type) results for type label values missing in sum(metric_a) by (type).

Then results from these three queries are joined with or operator.

This query is equivalent to the query proposed by Michael: sum({__name__=~"metric_a|metric_b"}) by (type) .

P.S. This query can be simplified further when using MetricsQL:

sum(metric_a, metric_b) by (type)

This query works, since sum() function in MetricsQL accepts and sums arbitrary number of arguments.

Discussions

Sum two metrics from two different prometheus datasources in a single graph
Have prometheus server setup for each Geographic Region like North America, Europe, Asia, etc. Want to setup a global prometheus dashboard which shows summation of metrics from all regions. I know about the mixed datasource mode on Grafana which allows you to graph multiple metrics from different ... More on community.grafana.com
🌐 community.grafana.com
1
1
June 22, 2020
Visualizing two metrics on the same graph
does this means that the best way to display metrics is not by using prometheus itself but attaching to grafana and using grafana capabilities ? Yes, the expression browser doesn't have that feature. It's meant more for ad-hoc work. Also i saw robustperception post on how to check if ssh is responding or not ; is there a way to see which process name is listening to a given port ? sudo netstat -nlpt More on reddit.com
🌐 r/PrometheusMonitoring
6
5
January 11, 2017
How to combine two metrics into one in Prometheus
Use a recording rule to summarize them when scraping them instead of summing them at query time. The recording rule will yield a new metric for this use. More on reddit.com
🌐 r/PrometheusMonitoring
1
2
September 18, 2023
Prometheus - How to “join” two metrics and calculate the difference?
How would I join metrics by their similar labels and calculate the difference? Example I have metric for tracking the inventory from two systems. I have the numbers push to the same metric but use labels to identify whe… More on community.grafana.com
🌐 community.grafana.com
3
0
May 11, 2020
🌐
Google Groups
groups.google.com › g › prometheus-users › c › Lx3ATbPE7yg
add two metric values PromQL
sum by(resource_group, resource_name) ( virtual_machine_instance_up ) using "or" seems to be what you need · > Which again works great, but the results aren't exactly what I hoped for. > Only those vectors are listed from *virtual_machine_instance_up*, which > have a matching vector in *alertmanager_silence_info*. > > Next I tried incorporating "vector(0)" in the above query, which is my goto > "metric" for cases where the underlying metric doesn't produce any value.
🌐
Prometheus
prometheus.io › docs › prometheus › latest › querying › examples
Query examples | Prometheus
sum by (app, proc) ( instance_memory_limit_bytes - instance_memory_usage_bytes ) / 1024 / 1024 · If the same fictional cluster scheduler exposed CPU usage metrics like the following for every instance:
🌐
Better Stack
betterstack.com › community › questions › how-to-join-two-metric-in-one-prometheus-query
How Can I 'Join' Two Metrics in a Prometheus Query? | Better Stack Community
If both metrics share common labels (like method), you can join them based on those labels: ... This query sums up the total requests and the total response times for each HTTP method and then multiplies them based on the shared method label.
🌐
Last9
last9.io › blog › query-multiple-metrics-in-prometheus
Easily Query Multiple Metrics in Prometheus | Last9
February 21, 2026 - Prometheus offers powerful functions specifically designed for working with multiple metrics: These logical operators help combine or filter metrics: ... This returns instances where both API and database services are running, helping identify critical infrastructure dependencies. ... This alerts when a critical metric disappears completely, providing immediate notification of service outages or monitoring gaps. histogram_quantile(0.95, sum(rate(http_request_duration_seconds_bucket[5m])) by (le, service)) / on(service) group_left node_cpu_utilization
🌐
SigNoz
signoz.io › guides › how can i 'join' two metrics in a prometheus query? - joining metrics in promql
How can I 'join' two metrics in a Prometheus query? - Joining Metrics in PromQL | SigNoz
July 24, 2024 - Joining two metrics in a Prometheus ... behavior. This process involves using PromQL (Prometheus Query Language) to combine metrics based on their labels and apply operations to the resulting data....
🌐
Grafana
community.grafana.com › prometheus
Sum two metrics from two different prometheus datasources in a single graph - Prometheus - Grafana Labs Community Forums
June 22, 2020 - Have prometheus server setup for each Geographic Region like North America, Europe, Asia, etc. Want to setup a global prometheus dashboard which shows summation of metrics from all regions. I know about the mixed datasource mode on Grafana which allows you to graph multiple metrics from different datasources.
Find elsewhere
🌐
Yannick Pereira-Reis
ypereirareis.github.io › blog › 2020 › 02 › 21 › how-to-join-prometheus-metrics-by-label-with-promql
How to join Prometheus metrics by label with PromQL – Yannick Pereira-Reis
sum(node_disk_bytes_read * on(instance) group_left(node_name) node_meta{}) by (node_name) on(instance) => this is how to JOIN on label instance. group_left(node_name) node_meta{} => means, keep the label node_name from metric node_meta in the result.
🌐
Reddit
reddit.com › r/prometheusmonitoring › visualizing two metrics on the same graph
r/PrometheusMonitoring on Reddit: Visualizing two metrics on the same graph
January 11, 2017 -

Hello, i've been testing prometheus 1.4.1 and i've been wondering if it is possible to put two different metrics (for example memory used and memory free) on the same graph.

I've been looking for a way to do that but so far no luck; does this means that the best way to display metrics is not by using prometheus itself but attaching to grafana and using grafana capabilities ?

Also i saw robustperception post on how to check if ssh is responding or not ; is there a way - using prometheus - to see which process name is listening to a given port (this for sanity check purpose)?

edit: corrected one question

🌐
Atatus
atatus.com › blog › how-to-join-two-metrics-in-prometheus
How to Join two metrics in Prometheus?
August 12, 2025 - Here's a simple explanation of how these operations can help: Addition (+): This operation helps in combining the values of two metrics. You can sum metrics to get the total count or combined rate of something over multiple series.
🌐
GitHub
github.com › prometheus › prometheus › discussions › 10601
How to get max value of two metrics? · prometheus/prometheus · Discussion #10601
April 15, 2022 - Proposal I have two metrics sum(yottadb_pod_network_receive_bps{region_name!=""}) by (region_name) sum(yottadb_pod_network_transmit_bps{region_name!=""}) by (region_name) How to get the max value o...
Author: prometheus
🌐
Reddit
reddit.com › r/prometheusmonitoring › how to combine two metrics into one in prometheus
r/PrometheusMonitoring on Reddit: How to combine two metrics into one in Prometheus
September 18, 2023 -

I am new to Prometheus metrics and I still struggle to see the right way to do things.

I recently discovered that the job I created had one target that was reading two instances metrics. That means that I had two sequences merged into one and the counter was going up and down.

After a question at Stackoverflow I changed the job to

- job_name: 'example'
    scrape_interval: 30s
    params:
      -instance: ['372c43937e6acd56073246ffdf0e95597480cdba24688cc331d77a8c3c07e1a9','be007691832f4002a86cf0148768a3b039304e9b1fa7ae91a032b0beddc152b2']
    static_configs:
      - targets: ['example.com']
    metrics_path: /metrics
    scheme: https

That way I get two sequences of metrics within the same job name.

Is there anything that can group these two sequences into one?

I know that I can query the Prometheus with a sum and combine them in every query, but I would like to simplify this and query them as a single sequence.

🌐
Grafana
community.grafana.com › prometheus
Prometheus - How to “join” two metrics and calculate the difference? - Prometheus - Grafana Labs Community Forums
May 11, 2020 - How would I join metrics by their similar labels and calculate the difference? Example I have metric for tracking the inventory from two systems. I have the numbers push to the same metric but use labels to identify where the metric came from. inventory_quantities{sku="ABC", system="warehouse1"} value = 5 inventory_quantities{sku="ABC", system="warehouse2"} value = 15 I want to join on the SKU and calculate the difference between the two.
🌐
OneUptime
oneuptime.com › home › blog › how to join two metrics in prometheus query
How to Join Two Metrics in Prometheus Query
December 17, 2025 - groups: - name: enriched-metrics ...source="limits.cpu", type="hard"}) Joining metrics in Prometheus requires understanding vector matching and label cardinality....
🌐
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 - Metric results are aggregated over a metric label and processed by an aggregation operator like sum(). PromQL has twelve built in aggregation operators that allow you to perform statistics and data manipulation.
🌐
Google Groups
groups.google.com › g › prometheus-users › c › 8zOfnnfhr8c
Combing two metrics to get a new one. (Calculate a ratio by comparing two metrics arithmetically)
sum( sum(irate(http_status_codes{host=~".*mysite.*",code="429"}[1m])) / sum(irate(http_status_codes{host=~".*mysite.*",code="200"}[1m])) ) I want to calculate a ratio of the number of 429's to 200's. ... Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message ... You would want to use a recording_rule for this expression. https://prometheus.io/docs/prometheus/latest/configuration/recording_rules/ I believe you would want a recording rule for the rate of 429s, the rate of 200s, and then if you'd like.
🌐
Google Groups
groups.google.com › g › prometheus-users › c › 59VKF1kHmhU
How to query Multiple Metric with PromQL
Have you tried using the "or" operator to combine these two queries? On Wed, 2019-09-11 at 02:36 -0700, Mạnh Nguyễn Tiến wrote: > I have many Query Request using PromQL like: > - Collect disk read rate: sum by (instance) > (irate(node_disk_read_bytes_total[2m])) / 1024 / 1024 · > - Collect CPU Available: (avg by(instance) > (irate(node_cpu_seconds_total{mode="idle"}[5m])) * 100) > If just with metrics, I can do it using operator "|": > http://Prometheus_IP_Address/api/v1/query?query={__name__=~”node_memory_Buffers_bytes|node_cpu_seconds_total”,instance=”Node_Exporter_IPAddress”} > > But with PromQL I cannot.
🌐
Stack Overflow
stackoverflow.com › questions › 58677398 › how-to-add-two-prometheus-metrics-together › 58677449
How to add two prometheus metrics together - Stack Overflow
But from reading https://prome... metrics with the same dimensional labels, we can apply binary operators to them and elements on both sides with the same ......
🌐
Prometheus
prometheus.io › docs › prometheus › latest › querying › operators
Operators | Prometheus
sum(v) sums up sample values in v in the same way as the + binary operator does between two values. All sample values being aggregated into a single resulting vector element must either be float samples or histogram samples. An aggregation of a mix of both is invalid, resulting in the removal ...