Hello, using influxv2 with telegraf to monitor windows servers.
Trying to get my head around how to do alerting based on the provided query.
This is what I have so far…
This is query 1 where it fetches the “state” of the service which when running = 4
from(bucket: “telegraf”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r[“_measurement”] == “win_services”)
|> filter(fn: (r) => r[“_field”] == “state”)
|> filter(fn: (r) => r[“service_name”] == “SplunkForwarder”)
|> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)
|> yield(name: “mean”)
Query 2 - this pulls back the startup type of the service = this should be value 2
from(bucket: “telegraf”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r[“_measurement”] == “win_services”)
|> filter(fn: (r) => r[“_field”] == “startup_mode” and r._value == “2”)
|> filter(fn: (r) => r[“service_name”] == “SplunkForwarder”)
|> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)
|> yield(name: “mean”)
The above queries work ok but show both values in the graph and if the alert is triggered it shows the service that is stopped but also ALL the services that have the startup value of 2
Ideally I would like it just to state the Non running service
I tried to use pivot() from the below article with no success as it didnt seem to pull back any data
from(bucket: “telegraf”)
|> range(start: v.timeRangeStart, stop: v.timeRangeStop)
|> filter(fn: (r) => r[“_measurement”] == “win_services” and r._field =~ “state”|“startup_mode”/ )
|> pivot(rowKey:[“_time”], columnKey: [“_field”], valueColumn: “_value”)
|> filter(fn: (r) => r.state > 1 and r.startup_mode == 2)
|> filter(fn: (r) => r[“service_name”] == “SplunkForwarder”)
|> aggregateWindow(every: v.windowPeriod, fn: mean, createEmpty: false)
|> yield(name: “mean”)
Can anyone point me in the right direction for this, I feel like i am close … but forever chasing the proverbial cigar…
Any help would be greatly appreciated