So I’m monitoring the last modified date of an important file (don’t ask), if it hasn’t updated for more than 48 hours then I’d like to get an alert. Or if that can’t be done then alert if there is a change.
I can’t work out how I’d create this. I’ve created many alerts before though.
I’m using Telegraf’s filestat plugin to send to InfluxDB the displaying here.
You can see Axis Y is the modified date and over the past 2 days the file has been modified around 6am (hard to see I know). The Axis X is a bit useless as it’s show a date, but it’s not really related to muh.
This is the table view which I’m using too, but you can’t alert on this:
If you can (and are willing to) change from InfluxQL to Flux, this is pretty straightforward:
store the LastModifiedDate as a timestamp
create new column using map() function that calculates the value of CurrentTime - LastModifiedDate, where both of these values are a timestamp in milliseconds (see below)
once the above query is working, paste into Grafana and set alert condition to be when the value in the new column > 172,800,000 Milliseconds
something like this:
currentTime = system.time()
|> map(fn: (r) => ({ r with uint(v: r._currentTime) - uint(LastModifiedDate)}))