Jump to content

[VIDEO GUIDE] Using Telegraf to Monitor Unraid


Recommended Posts

Posted (edited)

All the guides I've come by were outdated, this took a bit to figure out, but I got everything mostly working. I'd love any suggestions to improve this setup if y'all have any.

 

Assumptions

This assumes you already have Grafana and InfluxDB 2 setup. These are super simple to setup just by searching the applications in the Unraid UI. Generally, these don't require any special configurations or changes.

 

Add your configuration

Before we add our Telegraf container we need to add our configuration. In this example we are placing it the default directory for Docker configurations on Unraid. Change anything here to better fit your setup. When working with my appdata directory in Unraid I generally use the Dynamix File Manager it's an awesome tool that makes navigating shares in the Unraid UI easy.

 

First download the telegraf.conf file located in my repository and make any changes you'd like. Most everything the configuration should work as-is* Unraid, but you will need to edit the outputs plugin information to properly send data to your InfluxDB 2 bucket. Note: Use a new bucket specifically for this Unraid instance.

*I'm still trying to figure out how to get smart monitoring to work.

 

[[outputs.influxdb_v2]]
  urls = ["http://ip:8086"]
  token = "yourtoken"
  organization = "yourorg"
  bucket = "unraidbucket"

 

In your appdata directory on Unraid make a new folder called telegraf. Within your telegraf folder upload the edited telegraf.conf file. The file path will look like this if you're following the default Unraid setup. 

 

/mnt/user/appdata/telegraf/telegraf.conf

 

Setting up the container

Use the official Telegraf container from the Applications page. We will be using the golift/telegraf in replacment of the office image as it includes some packages needed for full monitoring of the hardware.

 

Change the following

Repository: golift/telegraf

Registry URL: https://hub.docker.com/golift/telegraf

 

This container provides a telegraf docker image with added tools for monitoring disks, sensors, and IPMI. This exists because the base telegraf Docker image makes it very difficult to monitor some system metrics. Applications added: smartctl (smartmontools), ipmitool, nvme-cli, sensors (lm-sensors), mtr (mtr-tiny), sudo. Sudoers entries are added for smartctl, ipmitool and nvme.

 

Add the following

Extra Parameters: /bin/bash -c "/entrypoint.sh telegraf"

Extra Argument: --user telegraf:$(stat -c '%g' /var/run/docker.sock)

 

Start and verify

Other than these adjustments everything should be able to be left as is included in the template. Check over everything and click on apply. Go to your Docker page in Unraid and check to see if the container is running. Check the log files to ensure there are no issues and that all the plugins are properly active.

 

If there are no issues, we check to see if the data is being properly exported to InfluxDB 2. Head over to your dashboard and open the bucket you created for Unraid. It should look like the picture below. Go through the data make sure nothing is missing. In my installation I have 7 tags for Docker data under the _messurements ID and another tag for every plugin I have enabled.

 

unraid-data-preview.png?raw=true

 

Grafana Dashboard

This guide is part of a larger video where I highlight the entire setup the embedded video starts at 26:52, when I add the data source in Grafana and use an awesome dashboard to monitor Unraid.

 

Unraid System Dashboard V2 (InfluxQL) - 7233

 

 

Edited by TechHut
  • Like 1
Link to comment
  • TechHut changed the title to [VIDEO GUIDE] Using Telegraf to Monitor Unraid

Thanks for sharing.

 

Seems the Docker UI isn't running the correct docker run comman:

Command execution

docker run
  -d
  --name='telegraf'
  --net='host'
  -e TZ="America/Los_Angeles"
  -e HOST_OS="Unraid"
  -e HOST_HOSTNAME="[REDACTED]"
  -e HOST_CONTAINERNAME="telegraf"
  -e 'HOST_PROC'='/rootfs/proc'
  -e 'HOST_SYS'='/rootfs/sys'
  -e 'HOST_ETC'='/rootfs/etc'
  -e 'HOST_MOUNT_PREFIX'='/rootfs'
  -l net.unraid.docker.managed=dockerman
  -l net.unraid.docker.icon='https://github.com/atribe/unRAID-docker/raw/master/icons/telegraf.png'
  -v '/var/run/utmp':'/var/run/utmp':'ro'
  -v '/var/run/docker.sock':'/var/run/docker.sock':'ro'
  -v '/':'/rootfs':'ro'
  -v '/sys':'/rootfs/sys':'ro'
  -v '/etc':'/rootfs/etc':'ro'
  -v '/proc':'/rootfs/proc':'ro'
  -v '/mnt/user/appdata/telegraf/telegraf.conf':'/etc/telegraf/telegraf.conf':'rw'
  -v '/run/udev':'/run/udev':'ro' /bin/bash
  -c "/entrypoint.sh telegraf" 'golift/telegraf'
  --user telegraf:$(stat
  -c '%g' /var/run/docker.sock)

docker: invalid reference format.
See 'docker run --help'.

The command failed.

 

Edited by StylishQuoter
Link to comment
  • 2 weeks later...

Thanks for the guide! Like others most of what's available out there at this moment is out of date, including the all-in-one container (GUS) which no longer works.

 

I did resolve a few speed-bumps in the instructions; including how to resolve the invalid reference format error as mentioned above, along with getting SMART monitoring working.

 

So for this one (which I ran into as well):

 

docker: invalid reference format.
See 'docker run --help'.

The command failed.

 

I watched TechHut's video alongside the instructions, the video had it correct but the instructions just have them flipped.

 

Original instructions were:

Add the following
Extra Parameters: /bin/bash -c "/entrypoint.sh telegraf"
Extra Argument: --user telegraf:$(stat -c '%g' /var/run/docker.sock)

 

It should be (or at least worked for me):

Add the following
Extra Parameters: --user telegraf:$(stat -c '%g' /var/run/docker.sock)
Post Argument: /bin/bash -c "/entrypoint.sh telegraf"

 

And for SMART queries and telemetry to work, I looked up some documentation and within the 'telegraph.conf' file, I had to add "use_sudo = true" which I discovered from a Reddit post.  Though I now get HDD disk temps and SMART information, the historical view for temperature over 6 hours isn't working for me ("Drive SMART Temps - Last 6 hours", still trying to figure that out.

[[inputs.smart]]
  attributes = true
  use_sudo = true

 

Edited by Photek
  • Like 1
Link to comment
  • 3 weeks later...

I'm having two issues getting Telegraf to run:

 

I'm getting the following error when starting the container:
"2024-08-06T16:15:59Z E! [telegraf] Error running agent: could not initialize input inputs.smart: smartctl not found: verify that smartctl is installed and it is in your PATH (or specified in config): provided path does not exist: []"

 

Seems like the golift/telegraf container no longer exists.  I get a 404 when trying to visit the Docker Hub page (https://hub.docker.com/golift/telegraf)

Link to comment
1 hour ago, drsparks68 said:

I'm having two issues getting Telegraf to run:

 

I'm getting the following error when starting the container:
"2024-08-06T16:15:59Z E! [telegraf] Error running agent: could not initialize input inputs.smart: smartctl not found: verify that smartctl is installed and it is in your PATH (or specified in config): provided path does not exist: []"

 

Seems like the golift/telegraf container no longer exists.  I get a 404 when trying to visit the Docker Hub page (https://hub.docker.com/golift/telegraf)

Seems like the docker hub URL for the telegraf container changed: https://hub.docker.com/r/golift/telegraf

  • Like 1
Link to comment
  • 3 weeks later...

Thanks for including these corrections and the sudo=true. Everything got up and running for me smoothly.

 

 

On 7/22/2024 at 8:40 AM, Photek said:

Thanks for the guide! Like others most of what's available out there at this moment is out of date, including the all-in-one container (GUS) which no longer works.

 

I did resolve a few speed-bumps in the instructions; including how to resolve the invalid reference format error as mentioned above, along with getting SMART monitoring working.

 

So for this one (which I ran into as well):

 

docker: invalid reference format.
See 'docker run --help'.

The command failed.

 

I watched TechHut's video alongside the instructions, the video had it correct but the instructions just have them flipped.

 

Original instructions were:

Add the following
Extra Parameters: /bin/bash -c "/entrypoint.sh telegraf"
Extra Argument: --user telegraf:$(stat -c '%g' /var/run/docker.sock)

 

It should be (or at least worked for me):

Add the following
Extra Parameters: --user telegraf:$(stat -c '%g' /var/run/docker.sock)
Post Argument: /bin/bash -c "/entrypoint.sh telegraf"

 

And for SMART queries and telemetry to work, I looked up some documentation and within the 'telegraph.conf' file, I had to add "use_sudo = true" which I discovered from a Reddit post.  Though I now get HDD disk temps and SMART information, the historical view for temperature over 6 hours isn't working for me ("Drive SMART Temps - Last 6 hours", still trying to figure that out.

[[inputs.smart]]
  attributes = true
  use_sudo = true

 

 

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...