Hi everyone,
I’m working on a switch overview dashboard using snmp for getting desired metrics using a dashboard template from grafana switch overview
There are curerntly metrics from 8 switches with varying port numbers. In order to leave all the VLANs out I filtered by using a regex on the total number of port in the port variable:
The variable:
import "influxdata/influxdb/schema"
schema.tagValues(
bucket: "tigstack",
tag: "ifIndex"
)
// and the attached regex:
(5[0-4]|[1-4][0-9]|0?[1-9])
The following query takes in a selected switch and iterates over all the ports in order to return the status:
Summary
from(bucket: "tigstack")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) =>
r._measurement == "InterfaceTable" and
r.agent_host == "${ip}" and
r.ifIndex == "${port}" and
r._field == "ifOperStatus"
)
|> aggregateWindow(every:1m, fn: last , createEmpty: false)
|> yield(name: "last")
But here’s the crux:
The values for non-existent ports are returned with null which is then displayed as N/A (which is intended), but for this and other specific queries I need to eliminate this representation. More on that in the Summary below.
Summary
This is another representation using the ifLastChange field:
This is the associated query:
from(bucket: "tigstack")
|> range(start:-1m)
|> filter(fn: (r) =>
r._measurement == "InterfaceTable" and
r.agent_host == "${ip}" and
r.ifIndex == "${port}" and
r._field == "ifLastChange")
|> aggregateWindow(every:1h, fn: last , createEmpty: false)
|> yield(name: "last")
And the same for the field ifSpeed:
from(bucket: "tigstack")
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r["_measurement"] == "InterfaceTable")
|> filter(fn: (r) => r["_field"] == "ifSpeed")
|> filter(fn: (r) => r["ifIndex"] == "${port}")
|> filter(fn: (r) => r["agent_host"] == "${ip}")
|> aggregateWindow(every: 1m, fn: mean, createEmpty: false)
|> yield(name: "mean")
Is there a way to selectively not show the null values in my queries for the respective fields?
take care
mateo