Hey,
it turns out adding the limitation in the query itself sanitizes the data returned in the panel. So it shows the true value.
I don’t get that bc query inspector shows no differences in the values inserted for the variable, but here we are.
i.e. I have added two queries that return the states of the switch ports I need to see:
Query A:
Summary
|> range(start: -1m)
|> filter(fn: (r) =>
r._measurement == "InterfaceTable" and
r.agent_host == "${ip}" and
r.ifIndex =~ /${port:pipe}/ and
r._field == "ifOperStatus"
)
|> filter(fn: (r) => int(v: r.ifIndex) <= 52)
|> duplicate(column: "_value", as: "PortUP")
|> group(columns: ["PortUP"])
|> toString()
|> filter(fn: (r) => r._value == "1")
|> count()
Query B:
Summary
from(bucket: "tigstack")
|> range(start: -1m)
|> filter(fn: (r) =>
r._measurement == "InterfaceTable" and
r.agent_host == "${ip}" and
r.ifIndex =~ /${port:pipe}/ and
r._field == "ifOperStatus"
)
|> filter(fn: (r) => int(v: r.ifIndex) <= 52)
|> duplicate(column: "_value", as: "PortDown")
|> group(columns: ["PortDown"])
|> toString()
|> filter(fn: (r) => r._value == "2")
|> count()
Here’s the view in grafana
I used the transformation “merge tables/series” for getting both queries to be shown in the same panel.
Now a new problem arises that will be posted in a new topic:
Hint: I need the rows to have a custom text.
Ports UP 9
Ports Down 43
So here is the new topic:
Showing Switch Port Status in a single table using multiple queries