I have Telegraf running for telemetry streaming via GRPC, with the following telegraf.conf configuration:
`[agent]
logtarget = "file"
logfile = "/var/log/telegraf/telegraf-core.log"
debug = true
quiet = true
round_interval = false
metric_batch_size = 1000000
metric_buffer_limit = 1000000
[[inputs.jti_openconfig_telemetry]]
servers = ["x.x.x.x:50051","x.x.x.x:50051"]
sample_frequency = "5000ms"
username = "xxxx"
password = "xxxx"
client_id = "Telegraf"
sensors = [
"interfaces_oper_state /interfaces/interface/state/oper-status"
]`
The database I’m using is Prometheus, with the following configuration:
`[[outputs.prometheus_client]]
listen = ":9200"`
This setup results in the following enumeration response:
interfaces_oper_state__component_id{device="x.x.x.x", host="grafana-poc", instance="x.x.x.x:9200", interfaces_interface__name="name", interfaces_interface_state_oper_status="UP", job="job", location="example", path="sensor_1011:/interfaces/interface/state/oper-status/:/interfaces/interface/state/oper-status/:mib2d", system_id="example"} 65535.
I want to create an alert based on the interfaces_interface_state_oper_status. To achieve this, I am using the [[processors.enum]] processor with the following configuration:
`[[processors.enum]]
[[processors.enum.mapping]]
field = "/interfaces/interface/state/oper-status"
dest = "status_code"
[processors.enum.mapping.value_mappings]
"UP" = 0
"DOWN" = 1
"TESTING" = 2
"UNKNOWN" = 3
"DORMANT" = 4
"NOT_PRESENT" = 5
"LOWER_LAYER_DOWN" = 6`
This results in the following metric:
interfaces_oper_state_status_code{device="x.x.x.x", host="grafana-poc", instance="x:9200", interfaces_interface__name="name", interfaces_interface_state_oper_status="UP", job="Job", location="location", path="sensor_1011:/interfaces/interface/state/oper-status/:/interfaces/interface/state/oper-status/:mib2d", system_id="example"} 0.
This configuration works as expected; when I create a visualization in Grafana and shut down an interface, the value changes from 0 to 1.
However, when I try to create an alert based on this metric using the changes(interfaces_oper_state_status_code[$__interval]) function, I always get a value of 0 (I tested it with all interval values), even when I shut down or bring up an interface.
Although the value of interfaces_oper_state_status_code changes, the changes() function does not seem to work as intended.
I have tried other functions, like rate, delta, increase.
Since interfaces_oper_state_status_code changes in the right way when I bring up or shut down an interface, I am expecting that the result of changes(interfaces_oper_state_status_code[$__interval] would also work.
user26695486 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.