How do you monitor varnish cache inside a docker container?

I have found many tools on Google relating to this but we are focusing only on nagios and new relic.


Varnish is monitored with what they call VSM. It's a file in your container. If you bind mount the folder where the files is, you can share the same folder / files in other containers that will be able to read it, and thus will be able to monitor your varnish instance. See the note about VSM and containers in varnish docs. I have been able to launch a varnishstat with statistics in a container with varnish in the image, but no varnish running, like this:

docker run --rm -it \
       --entrypoint=/bin/sh \
       -v /var/lib/docker/overlay2/$hash/merged/usr/local/var/varnish/$hostname:/varnish \
      emgag/varnish:5.1.3 varnishstat -N /varnish/_.vsm
| improve this answer | |

You could install a Nagios agent inside the container, but this means you have to add the newly config to the Nagios master, or use consul or other service discovery tool, and connect that with Nagios, so for every new container it will automatically add it to the Nagios. Be sure to export the nagios HTTP port not the administration one.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.