Collect ntpq metrics with docker container


I have telegraf running in docker container. How can I collect ntpq metrics.

I’m getting following error in container:
Error in plugin [inputs.ntpq]: exec: “ntpq”: executable file not found in $PATH


The “ntpq” plugin requires the “ntpq” executable, as per the documentation.

When you are running Telegraf inside a docker container, only Telegraf and the files it needs to run are part of the container. If you are using the Telegraf container available on the Docker Hub, “ntpq” executable is not installed in the container.

You will need to build a new container which includes the “ntpq” executable and make sure its location is included in the PATH.


What can I do if I want to monitor container’s host ntpq metrics?


According to the ntpq documentation:

ntpq uses NTP mode 6 packets to communicate with the NTP server, and hence can be used to query any compatible server on the network which permits it

You’ll need to make sure that your container has network access to that port on the host.