bated
bated

Reputation: 960

Charting the sum of two Prometheus data source values in Grafana

I am trying to create a chart in Grafana with Prometheus data source which includes a series indicating the total size of the young gen memory used on a java 8 jvm. Below is the formula I have used to sum the values together:

(jvm_memory_pool_bytes_used{job="jmx",instance=~"my-jboss-server:10191",pool="PS Eden Space"}
+ 
jvm_memory_pool_bytes_used{job="jmx",instance=~"my-jboss-server:10191",pool="PS Survivor Space"})

I am able to chart the individual values for PS Survivor Space and PS Eden Space but as soon as I try to add them together, there is no data returned.

Below is some sample data which is returned:

jvm_memory_pool_bytes_used{pool="PS Eden Space",} 5.83346368E8
jvm_memory_pool_bytes_used{pool="PS Survivor Space",} 8.5090432E7

Upvotes: 0

Views: 1448

Answers (1)

Stefan R
Stefan R

Reputation: 755

You can use the sum() function. It would probably look something like

sum(jvm_memory_pool_bytes_used{pool=~"PS Eden Space|PS Survivor Space", [other labels]})

For more info check Prometheus Querying Basics.

Upvotes: 1

Related Questions