Returns the hours of the day in the specified time zone.
String identifier or alias for a time zone, such as |
|tsExpression||Optional expression to which you want to apply this function.|
hour() standard time function returns the hours within a day for the specified time zone, represented as decimal values on a 24-hour clock. For example, 12am is represented as 0.000; 2pm is represented as 14.000; 2:15pm is represented as 14.250; and 2:32pm is represented as 14.533.
The returned values are plotted against the corresponding hours of the day shown in the time zone that is currently set for the dashboard.
hour() automatically adjusts its return values for daylight savings time.
hour() is particularly useful when you want to define an alert that fires only during specific times of day. For example, you could use an expression such as
between(hour("US/Pacific"), 22,8) in an alert condition to ensure that the alert fires only between 10pm and 8am Pacific Time.
Example 1: Showing Hours
hour("Europe/Vienna") lets you compare times in your dashboard’s current time zone with times in another time zone. In this example, we can find 12 noon in the current time zone (along the x-axis) and see that it is 21.00 (9:00pm) in the Europe/Vienna time zone (along the y-axis).
Example 2: Defining an Alert that Fires in Particular Hours
Here we include
between(hour("Europe/London"),22,8) in a conditional expression to define an alert that fires when the CPU load average rises above 1.5 between the hours of 10pm and 8am in the Europe/London time zone.