How can I use Prometheus to monitor the status of a docker container to see if it is up or down?

42 Views Asked by At

I currently use prometheus and cadvisor to monitor containers, I currently have a container named timesheet, how can I determine if the state of this container is up or down?enter image description here

1

There are 1 best solutions below

0
Rodrigo Moraes On

You can use the cadvisor metric called container_last_seen. If the metric is present at the query time the container is up, if not the container is down. The PromQL query to detect if a container is up or down would be: absent(container_last_seen{container="MY_CONTAINER"}).

A good source of common queries for alerts in container environment using Prometheus is: https://samber.github.io/awesome-prometheus-alerts/rules#rule-docker-containers-1-2

Take a look there, you will get a lot of good results.