How could I create a metric "hour" that returns[0..23] depending on the hour of day?

Hi there,

I’ve been trying to create alerts depending on the time of day, and came across this workaround:

  • Add the following query to your metric: hour() , that returns the hour of the day (0-23). You can make it hidden in the graph.
  • Add an extra AND condition to your alert, so it’s only alerting if the hour() query is between the range you want (eg: office hours).

How could I create a metric “hour” that returns[0…23] depending on the hour of day?(I didn’t ask on the issue not to pollute people’s mailbox who subscribed to it)

versions:

Grafana   7.0
InfluxDB  1.7.10
1 Like