What Grafana version and what operating system are you using?
Grafana-12.0.0 .. as docker container on a Debian-12.11 host
What are you trying to achieve?
I read data into prometheus by using the windows_exporter.
I want to create a panel that displays one line per windows instance, showing the state of one service (metric “windows_service_state”) in a color.
How are you trying to achieve it?
I try to use “Time Series” or “State timeline” visualization.
I try to group/filter the states via thresholds.
I defined the variable $instance to match “label_values(windows_os_hostname,instance)”
I defined thresholds to match the various states like “Running” “Stopped”, etc
queries
For example I try to use these queries:
windows_service_state{name=~"postgresql-x64-1*.*"} * on (instance,name) group_left(display_name) windows_service_info
What happened?
Either I get problems with the State timeline because my data seems not to have a timestamp.
Or I get one line per status, but not one line per instance.
Is the state a label? If so, what is the convention? Does it expose 0 value whenever the state is not occurring and state 1 of state is occurring (e.g. windows_service_state{job="windows-exporter",name="postgresql-x64-*", instance="1", state="Running"} 1 and windows_service_state{job="windows-exporter",name="postgresql-x64-*", instance="1", state="Stopped"} 0 would mean the instance 1 would be running?
Do you use the variable $instance inside the queries (it’s not enough to define a variable, you should also use it).
I see in the docs that the current state of the instance has value 1, so your query should end with == 1 (that will filter out all the states that the instance is not in). As for the Data does not have time field - I think it’s quite hard for prometheus data not to have a timestamp (at least I think). Do you use some transformations (the tab next to the query)? Can you share the screen of the query (like the entire query editor, there are a couple of settings but they also shouldn’t cause such an error).
“Data does not have a time field” can happen when either a) the data returned is missing a timestamp that state timeline can understand, or b) no data was returned at all for the panel query. In your case it’s likely the latter. If you hit the “Table View” toggle while in panel edit mode and it says “No Data”, that confirms that.
Based on your screenshots, I’m guessing the instance you have selected in your variable (192.168.1.51:9182) isn’t actually running postgres, as this instance isn’t present in the list shown in the second screenshot. If you want this dashboard to only display the servers that actually run postgres, you can change your variable query from windows_os_hostname to windows_service_state and add a label filter of name=“postgresql-x64-10”, so that your panel query will always match.
However, state timeline connects missing values by default, so if an instance was offline for a period of time (as mine was between 1100h-1135h), it’s not going to reflect that properly. Easily fixed by setting a disconnect threshold appropriate to your scrape interval: