Display Enums in a State Timeline Panel

This blog post states that it’s possible to use enums in the State Timeline panel since Grafana 10.3. However I cannot get it running with my Prometheus Enum data. Unfortunately I cannot find any other resources how this needs to be used, the video only really shortly shows the usage of static JSON data as an input.

My data looks like this (example taken from a discussion about this same topic in the windows_exporter issues):

# HELP windows_service_state The state of the service (State)
# TYPE windows_service_state gauge
windows_service_state{name="w32time",state="continue pending"} 0
windows_service_state{name="w32time",state="pause pending"} 0
windows_service_state{name="w32time",state="paused"} 0
windows_service_state{name="w32time",state="running"} 1
windows_service_state{name="w32time",state="start pending"} 0
windows_service_state{name="w32time",state="stop pending"} 0
windows_service_state{name="w32time",state="stopped"} 0
windows_service_state{name="w32time",state="unknown"} 0
windows_service_state{name="w3svc",state="continue pending"} 0
windows_service_state{name="w3svc",state="pause pending"} 0
windows_service_state{name="w3svc",state="paused"} 0
windows_service_state{name="w3svc",state="running"} 1
windows_service_state{name="w3svc",state="start pending"} 0
windows_service_state{name="w3svc",state="stop pending"} 0
windows_service_state{name="w3svc",state="stopped"} 0
windows_service_state{name="w3svc",state="unknown"} 0

I would like the panel to show two rows: w32time and w3svc. The color of the timeline should change according to the state the service is in: running would be green, stopped would be red etc.

I can’t add more than 2 links. Here’s the link to the discussion in windows_exporter GitHub issues: LINK

I also found a similar question on Stackoverflow (also about windows_exporter service state metric), but the one answer does not really work for me. It always ends in Data does not have a time field.

Hello @monsdarnbagrid welcome to grafana community , i try you issue and implement in my localhost grafana , please confirm is this your requirement??

The expected result would be to have the service names on the left (e.g. postgresql-x64-15) and the states in one line (first showing running, then switching to stopped).

You can use a table visualization to display the last state of the service. This is my personal recommendation.

I could as a workaround, but as always these have tradeoffs: E.g. then I would not be able to see whether there were any outages over the past 6 hours.

The State Timeline widget is the right visulization to show state over time. It just seems to happen that it does not support states/enums in Otel/Prometheus format (or at least it isn’t documented very well).

Perhaps I should open a feature request in the Grafana Issue tracker for this?

1 Like

1 Like