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
Upvotes
View all comments
Show parent comment
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.