Kiefer Networks

View Original

Linking Plex Data Into Grafana

Do you wish Plex had a super cool dashboard that showed you “all the things” in one place? Do you have an underutilized Synology NAS? Do you have some A LOT free time? If those 3 answers are yes, you should read this.

The End Goal

A couple of things before we get started. I don’t like to have to jump to a bunch of web tabs so I will do my best to compile all of the data into one page. I have included some links to resources I used to complete this project. Also, I am using a DS1621+ with 4GB of RAM. I would recommend this as the absolute baseline for running docker on your NAS. All of these services combined are pretty small but it never hurts to have more resources! This is also an x86 machine with an AMD processor so ARM your way through this at your own risk! I would be interested in knowing if it works though!

Layout of Services

Setting up Docker on Synology

The first order of business is to install Docker on your Synology NAS. You can find this in the app store on the Synology desktop. Resource: linuxhint.com

  1. Open Package manager.

  2. Search for Docker.

  3. Click Install.

  4. Select a volume to install in and then click Next.

  5. Make sure “run after installation” is checked and click apply.

  6. Open Docker from the Synology app tray or from the package manager.

Downloading from the Docker Registry

  1. Once you are in docker click on the registry tab.

  2. Search and download the following images:

    1. grafana/grafana (latest)

    2. influxdb (version 1.8… not Latest)

    3. tautulli/tautulli (latest)

    4. telegraf (latest or alpine)

    5. boerderij/varken (latest)

Setting Up InfluxDB in Docker

Resource: gh2home.nl

  1. Set up an InfluxDB folder in your environment ex. /volume1/docker/influxdb

  2. Go to the Images page in Docker.

  3. Click on the Influxdb 1.8 image and then click launch at the top of the page.

  4. Run the container with the bridged network configuration and continue. (this should be the default)

  5. Give it a special name or leave it default.

  6. Enable auto-restart and then continue to the next page.

  7. In folder mapping, add a folder from your choice of destination in your NAS (step 1) and then mouth the path to “‘/var/lib/influxdb” and continue.

  8. Verify settings and make sure the check box for “Run container when wizard is finished” is checked.

  9. Click apply

  10. Go to the container page in docker to verify it is running

Setting Up Grafana in Docker

Resource: mariushosting.com

  1. Set up a Grafana folder in your environment ex. /volume1/docker/grafana

  2. Open up the control panel in your Synology.

  3. Go to the task scheduler tab on the left.

  4. Create a new task as a user-defined script.

  • General: Install Grafana, User: Root, Enabled = true

  • Schedule: Run on the following date -> do not repeat

  • Task settings: email if you want, for the User-Defined Script section:

    • docker run -d --name=grafana \

      -p 3010:3000 \

      -v /docker/grafana:/var/lib/grafana \

      --restart always \

      grafana/grafana

      chown -R 472:472 /volume1/docker/grafana

6. Close the window and click ok on the red button if prompted.

7. Select the new line item in the task list, then click run.

8. Then click yes.

9. Browse to http://hostname:3010 and you should see the Grafna login page.

Setting up Varken in Docker

Resource: Varken wiki

  1. Set up a Varken folder in your environment ex. /volume1/docker/varken

  2. Open up the control panel in your Synology.

  3. Go to the task scheduler tab on the left.

  4. Create a new task as a user-defined script.

  5. Script Settings:

    1. General: Install Varken, User: Root, Enabled = true

    2. Schedule: Run on the folling date -> do not repeat

    3. Task settings: email if you want, for the User-Defined Script section:

      1. docker run -d \

        --name=varken \

        -v /docker/varken:/config \

        -e TZ=America/Chicago \

        boerderij/varken:latest

  6. Close the script and agree to any warnings.

  7. Click the new task in the list and click “run”.

Setting Up Telegraf in Docker

Resource: docker.com

  1. Set up a Telegraf folder in your environment ex. /volume1/docker/telegraf

  2. Open up the control panel in your Synology.

  3. Go to the task scheduler tab on the left.

  4. Create a new task as a user-defined script.

  5. Script Settings:

    1. General: Install telegraf, User: Root, Enabled = true

    2. Schedule: Run on the folling date -> do not repeat

    3. Task settings: email if you want, for the User-Defined Script section:

      1. sudo docker run -d \

        --name=telegraf \

        --net=host \

        --pid=host \

        --restart always \

        --volume /docker/telegraf/config/telegraf.conf:/etc/telegraf/telegraf.conf:ro \

        --volume /var/run/docker.sock:/var/run/docker.sock:ro \

        --volume /sys:/host/sys:ro \

        --volume /proc:/host/proc:ro \

        --volume /etc:/host/etc:ro \

        -e "HOST_PROC=/host/proc" \

        -e "HOST_SYS=/host/sys" \

        -e "HOST_ETC=/host/etc" \

        telegraf:alpine

  6. Close the script and agree to any warnings.

  7. Click the new task in the list and click “run”.

    NOTE: If the script fails, you may need to create the following as a blank file:

    • /volume1/docker/telegraf/config/telegraf.conf

Setting up Tautulli in Docker

  1. Set up a Tautulli folder in your environment ex. /volume1/docker/tautulli

  2. Browse to the Image section in Docker and click on the Tautulli image then click Launch.

  3. Use the bridged network mode

  4. Give it a name, allow it to restart, and allow the requested ports.

  5. Continue to the folder mapping.

    1. docker/tautulli/config is mapped to /config

  6. Allow to run after wizard completion and close the window.

  7. The Synology Web Station app should open now. If it does not, go to the Synology desktop start menu and search for it then open.

  8. Go to the Web Services Portal and then click create.

  9. Select “package server portal”

  10. Select docker and then click next.

    1. Service: Docker Tautulli *

    2. Type: port based

    3. Uncheck 80/443

    4. Check HTTP and enter port 8181

  11. Click apply.

  12. Browse to http://hostname:8181

  13. Follow prompts to set up with your Plex instance.

  14. Generate an API key for use later.

Setting up InfluxDB

  1. Open the Docker app on the Synology desktop web page.

  2. Click on the InfluxDB container in the containers tab.

  3. Click details.

  4. Click the terminal tab at the top.

  5. Click the “create” button at the top left of the window.

  6. In the new terminal session, with your own data, enter this command:

    1. influx user create -n johndoe -p PaSsWoRd -o example-org

  7. Close the window.

Get Maps API Key

  1. Go to MaxMind and make an account or sign in.

  2. Under “Account” click on “Manage License Keys”.

  3. Generate a new key and save it in a safe place.

Setting up Varken

  1. Stop the Docker container in the Docker app on the Synology desktop.

  2. Using VS Code or a similar code editing tool, open;

    1. /volume1/docker/varken/varken.ini

  3. Enter your Influxdb credentials, IP/Hostname, and port number.

  4. Enter any credentials to other applications you may want to stream into Influx.

  5. Enter your MaxMind license key.

  6. Enter your API key for Tautulli and the url of the Tautulli server.

  7. Save and close the file.

Setting up Grafana

  1. Go to your Grafana instance (http://hostname:3010).

  2. Set up your local account (Default login is admin:admin).

  3. Go to the settings and import your InfluxDB database.

    1. Settings -> Datasources

    2. Click “Add Data Source” and then choose InfluxDB

      1. Name: Telegraf

      2. URL: http://hostname:8086

      3. Access: Server

      4. Database: telegraf

      5. User: admin

      6. Password: whatever you set

      7. HTTP method: Get

    3. Save and test.

  4. Go to the settings again, we will be importing a second database

    1. Settings -> Datasources

    2. Click “Add Data Source” and choose InfluxDB.

      1. Name: Varken

      2. URL: http://hostname:8086

      3. Access: Server

      4. Database: varken

      5. User: admin

      6. Password: whatever you set

      7. HTTP method: Get

    3. Save and test.

  5. Now we will import a premade dashboard or you can feel free to make your own.

    1. In Grafana, go to dashborads -> browse.

    2. Click import on the right.

    3. Enter ID 9558 and click load (Resource: Grafana.com)

    4. In the dashboard, link the proper data sources to the proper attributes.

    5. Edit away at the dashboard!