Darius Nein
Darius Nein

Reputation: 31

How do I monitor whether a docker container is running with Grafana?

I have the following setup:

All of these are running in a docker stack.

Since I have some more docker containers running game servers etc., I would like to have a dashboard showing which of my servers are up and which of them are down.

I have tried many Google links, Youtube videos etc. but they all show how to create dashboards of aggregated data like CPU consumption per node etc. which I know how to set up.

Really the only thing I need is a panel showing UP or DOWN for different containers and I have not been able to find anything like that.

Solution

Figured it out (in case anyone runs into the same issue):

  1. Create a new Stat panel
  2. Select Prometheus and write the following query: time() - container_last_seen{name="CONTAINER_NAME"}
  3. Set the format to "Table", I had two Panels otherwise
  4. Create ranged value mappings with <60 -> Up and >60 -> Down

There are most likely better solutions but this is what I came up with after some more research.

Upvotes: 0

Views: 6083

Answers (2)

Maxime
Maxime

Reputation: 11

  • I used the following query: time() - container_last_seen{name="CONTAINER_NAME"}

  • With the condition: WHEN last() of A IS ABOVE 30

  • With range time : FROM : now-1min TO :now

A short time range, to avoid errors in case of updated containers... it works well

screen

Upvotes: 0

Darius Nein
Darius Nein

Reputation: 31

Solution

Figured it out (in case anyone runs into the same issue):

  1. Create a new Stat panel
  2. Select Prometheus and write the following query: time() - container_last_seen{name="CONTAINER_NAME"}
  3. Set the format to "Table", I had two Panels otherwise
  4. Create ranged value mappings with <60 -> Up and >60 -> Down

There are most likely better solutions but this is what I came up with after some more research.

Upvotes: 3

Related Questions