Hi,
this is the continuation of topic shwoint switch port status in flux
Using two queries (8 more to go), I have currently the correct output for a switch port status.
See summary of former topic below.
Summary
Query A
|> 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:
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 how it currently shows 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.
My target configuration should form a table looking like this:
In order to achieve this I want to add a row ‘title’ below the Metric.
like this:
Ports UP 9
Ports Down 43
I could use the override fields but both queries return a field with the name _value:
unfortunately the same is true when I want to override fields returned by query:
So either I need a solution to add a custom ‘Display Name’ (I assume) in order to get the distinct rows I’m looking for, or a way to change the representation of the table in general.
I hope anyone faced similar problems and knows how to help in this case.
take care
mateo