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.
Next, you need to make the Telegraf image available to your Docker instance. Launch Docker, then navigate to the “Registry” tab. Search for “Telegraf”
Select the “telegraf” package, then click “Download”. Select “latest” from the “Choose a Tag” dialog, then click “Select”.
Navigate to the “Image” tab, and you’ll now see “telegraf:latest” available.
Select the “telegraf:latest” package and click “Launch” to create a new container using the image.
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.
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.
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.
On the “Network” tab, check the box to “Use the same network as the Docker Host”.
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.
Navigate to the “Container” tab, and we should now see our new “Telegraf” instance running.
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.
If you’re using SNMP, navigate to the mibs folder we defined (in my case “docker\telegraf\configuration\”) and place your mib files here.
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.
Clicking the “Details” button will launch the container’s details dialog showing resource usage and other tools available to manage the container.
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.
You now have a fully functional Telegraf instance using minimal resources on Synology DSM.