Summing 2 series

Hello,

the following statement calculates the throughput in bps for a couple of ports of a switch monitored via snmp (derivative is necessary because the counter is a never decreasing one). How could I sum up the throughput of two or more ports?

Thanks.

from(bucket: “bucket1”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == “snmp-ifcounters”)
|> filter(fn: (r) => r["_field"] == “ifHCOutOctets”)
|> filter(fn: (r) => r[“agent_host”] == “switch1” and (r[“ifName”] == “Te1/0/20” or r[“ifName”] == “Te1/0/21”))
|> derivative(unit: 1s, nonNegative: true)
|> map(fn: (r) => ({ r with _value: r._value * 8.0 }))

Take a look at the group() function . Since you are interested in summing across these interfaces, the default grouping doesn’t allow that . It might be as simple as adding this to the end of your flux query.

|> group(columns: [ "_start", "_stop"])

Doco reference:

https://docs.influxdata.com/influxdb/cloud/query-data/flux/group-data/

1 Like