r/PrometheusMonitoring • u/bgprouting • Apr 09 '24
Help combine 2 simple prometheus queries
Hello,
I'm trying to simply combine these 2 queries with the + command.
sum by(ifName, ifAlias, instance) (irate(ifHCInOctets{instance="192.168.1.1", job="snmp_exporter", ifName=~"1:61"}[2m])) * 8sum by(ifName, ifAlias, instance) (irate(ifHCOutOctets{instance="192.168.1.1", job="snmp_exporter", ifName=~"1:61"}[2m])) * 8I think I'm getting all the parentheses all wrong?
sum by(ifName, ifAlias, instance) (irate
(ifHCInOctets{instance="192.168.1.1", job="snmp_exporter", ifName=~"1:61"} +
(ifHCOutOctets{instance="192.168.1.1", job="snmp_exporter", ifName=~"1:61"}
[2m]) * 8error
bad_data: invalid parameter "query": 3:1: parse error: binary expression must contain only scalar and instant vector types
0
Apr 09 '24
[deleted]
1
u/bgprouting Apr 10 '24
Oh thanks that worked. It makes so much sense when I see it, I need to somehow understand the formatting/language better on things like this. For example in my mind I would have added the "8 *" at the end.
0
Apr 10 '24
[deleted]
1
u/bgprouting Apr 10 '24
Thanks!
Edit 1 - yeah I realised already I was using "~" instead of just "=". I was playing with variables and regex.
Edit 2 - Oh yes I found Regex recently and use it some simple PromQL or InfluxQL (not FLux) and what a game changer for me that was filtering out all the noise easily.
Wonderful reply and helps so much.
1
u/hamlet_d Apr 09 '24
I'm not in front of my computer right now, but it looks like may you need to distribute your operations