querying multiple metrics using sum by

35 views
Skip to first unread message

amit kumar

unread,
Oct 11, 2023, 3:05:20 AM10/11/23
to Prometheus Users
i have 3 metrics
metrics_1 , metrics_2 , metrics_3  all are of type histogram i want to write a query that gives the sum of all these metrics filtered by some label label_1
i have written this expression
(sum by (label_1)(metrics_1{label_1=~".+"} or vector(0)))+(sum by (label_1)(metrics_2{label_1=~".+"} or vector(0))) + (sum by (label_1)(metrics_3{label_1=~".+"} or vector(0)))
the issue i am facing is suppose metrics_1 is null and other have some valid data  then the whole expression is giving output as zero , what i am expecting is it should add the other 2 metrics and take metrics_1  as 0 and give the overall sum.
eg : 
metrics_1 = null
metrics_2 = 10
metrics_3 = 14
result = 24 (expected) but actual == 0
i read some blog that suggested to use coalesce ,fillna but both of these function is supported in my case
any help how can i deal with this ??
or is there any other way i can achieve my goal?
Reply all
Reply to author
Forward
0 new messages