LogQL Statement for connection visibilty in Grafana based on connection status in the logfile

  • What Grafana version and what operating system are you using?

grafana:latest docker image / linux

  • What are you trying to achieve?

Hi all, i have some systems that write me an okay into the logfile every 20 seconds. based on the timestamp and the system name i want to display the system name and a green background within grafana. if no further okay is written into the logfile after 20 seconds, i want the background of the system name to be displayed in red in the grafana dashboard. can anyone tell me if this is possible? and how should the LogQL statement look like?

  • How are you trying to achieve it?

I start creating a dashboard and put this query: rate({host=“$host”, system=~“.+”}[20s]
But is not working as aspected. I really don’t know how to continue.

  • What happened?

I see my system label with green background with the rate, but instead of the rate I want to see how long the system is connected to my system.

  • What did you expect to happen?

To see green backgroung when okay is written in the log and when after 20s will not come the okay inside the logfile that he switch the background to red and shows me the time he is not connected to my server.

  • Can you copy/paste the configuration(s) that you are having problems with?

rate({host=“$host”, system=~“.+”}[20s]

  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.

  • Did you follow any online instructions? If so, what is the URL?

I did not found some instruction for this usecase.