Moving Telegraf to Synology-Hosted Docker

In a previous post, I walked through the process of configuring Telegraf to run on a Virtual Machine hosted on my Synology DS1817+. While I quite liked the idea of running a virtual machine, with a complete OS available for configuration and installation of anything I might need, I also wanted to explore a thinner deployment of Telegraf using less resources and operating more like a service than a VM I would need to patch and maintain. Enter Docker.

The Synology DSM platform natively supports Docker through the Package Center. Simply search for and install “Docker” if you haven’t already.

1.png

Next, you need to make the Telegraf image available to your Docker instance. Launch Docker, then navigate to the “Registry” tab. Search for “Telegraf”

2.png

Select the “telegraf” package, then click “Download”. Select “latest” from the “Choose a Tag” dialog, then click “Select”.

3.png

Navigate to the “Image” tab, and you’ll now see “telegraf:latest” available.

4.png

Select the “telegraf:latest” package and click “Launch” to create a new container using the image.

5.png

Enter a name for your container (ie: Telegraf), and check the box to “Enable resource limitation”. While the Synology DS1817+ I’m running has a decent amount of horsepower, I want to prevent the container from consuming any more than we know it needs. Telegraf itself consumes very little resources, and one of the advantage of using a Docker container over a full blown VM is the ability to use less resources. In my case, I set the CPU Priority to “Low”, and set a 256 MB memory limit.

6.png

Click the “Advanced Settings” button. On the “Advanced Settings” tab, check the “Enable auto-restart” box, and optionally select if you want a shortcut on your desktop.

7.png

Navigate to the “Volume” tab, and use the “Add Folder” button to define the following folders on your Synology to mount points on your container. This allows you to manage Telegraf’s configuration without directly accessing the container itself.

8.png

On the “Network” tab, check the box to “Use the same network as the Docker Host”.

9.png

Click “Apply” to close the “Advanced Settings” dialog, then “Next” on the “Create Container” dialog. Confirm the information in the summary, leave the “Run this container after the wizard is finished” box checked, and click “Apply” to provision the container.

10.png

Navigate to the “Container” tab, and we should now see our new “Telegraf” instance running.

11.png

Open “File Station” and navigate to the folder we defined for our Telegraf configuration files (in my case “docker\telegraf\configuration\”) and place your telegraf.conf file here.

12.png

If you’re using SNMP, navigate to the mibs folder we defined (in my case “docker\telegraf\configuration\”) and place your mib files here.

13.png

If needed, refer to the original article for steps to create Telegraf configuration files for SNMP.

With our configuration and supporting mibs all now available to the container, simply select the container, and navigation to “Action” > “Restart” to reboot the container and pick up the new Telegraf config.

14.png

Clicking the “Details” button will launch the container’s details dialog showing resource usage and other tools available to manage the container.

15.png

Click the “Log” tab, or view the Telegraf log in “docker\telegraf\logs\” to confirm that your telegraf.conf has been successfully loaded without any errors.

16.png

You now have a fully functional Telegraf instance using minimal resources on Synology DSM.