Skip to content

Grafana container setup

Introduction

Using Grafana, you can craft stunning dashboards. For instance, I leverage it to visualize data from Home Assistant sensors. In my setup, I’ve configured data sources for both MariaDB and InfluxDB.

Setup

  1. Create the folders needed by the container

    Run the following commands inside your home folder:

    # Open your terminal application
    cd ~
    mkdir -p grafana/data
    cd grafana
  2. Create the script needed to run the container

    Save the following script as grafana_run.sh:

    grafana_run.sh
    # To create this script use your text editor application, for example Nano
    IDu=$(id -u $(logname)) # Saves the logged in user id in the IDu variable
    docker run -d \
    --user $IDu \
    --name=grafana \
    --hostname=grafana \
    -p 3000:3000 \
    -v $PWD/data:/var/lib/grafana \
    -e GF_ANALYTICS_REPORTING_ENABLED=false \
    -e GF_INSTALL_PLUGINS=grafana-clock-panel,grafana-simple-json-datasource,grafana-googlesheets-datasource \
    -e TZ=Europe/Amsterdam \
    --restart unless-stopped \
    grafana/grafana
    # IMPORTANT: Please read the instructions below
    Instructions:
    • Optional Replace docker with podman if needed
    • Required Replace port number 3000 (on the left side of :) with a port number that is available if needed.
    • Optional Replace $PWD/data with the location of your data if needed. This can be a fileserver mount
    • Optional Remove -e GF_ANALYTICS_REPORTING_ENABLED=false if you want to enable analytics
    • Optional Change -e GF_INSTALL_PLUGINS=grafana-clock-panel,grafana-simple-json-datasource,grafana-googlesheets-datasource to add or remove plugins you want to install
    • Required Replace Europe/Amsterdam with your own timezone
  3. Run the script to create the container

    Run the following command:

    # Open your terminal application
    sudo sh grafana_run.sh

    The image grafana/grafana is automatically pulled and the container is created.

  4. Check the results

    If needed you can check if the container is running properly.

    Now you can log into Grafana with username admin and password admin by opening a web browser and going to: http://localhost:3000. Replace localhost with the relevant IP address or FQDN if needed, and adjust the port if you changed it earlier.

    The next steps would be:

    • Change the password
    • Configure your data sources

Favorites

Comments

    No comments found for this note.

    Join the discussion for this note on Github. Comments appear on this page instantly.

    Copyright 2021- Fiction Becomes Fact