prometheusgrafanainfluxdb

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.


Solution

  • 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.