Grafana Agent: Recommended healthcheck command for Docker container

Question about Grafana Agent (latest docker container):

What is the recommended way to check the health of a Grafana Agent docker container? I’m using a Docker container’s internal healthcheck, so it has to be a command that is possible within the Docker container.

I figure it also should be determinative of whether the container is operating as expected. With containers that depend on open ports, I could do a nc -zv localhost:PORT and make sure that the port was open. Or in a container that had curl, I could always curl against the known endpoint.

The Grafana Agent image is pretty small, however, and does not have these. Currently, since I am mounting a config file, I am testing for the presence of that file, which is fine, but I was wondering if there was a recommended way for this.

:wave: Needing it to be runnable within the container definitely adds some constraints to what’s possible here. We do have a ready/health API, but it’s pretty minimal; as long as the HTTP API server is listening, it returns 200. With that in mind, your netcat command is pretty similar.

Checking that the API is listening might be your best route here. It would verify at least that the configuration file was loaded and correct.

More advanced health checks are probably better suited to Prometheus alerting; if you have a consistent label set for the container you can configure meta-monitoring alerts for it.

Hope this helps!

1 Like