Skip to content
DΓ©nes Csala edited this page Nov 10, 2024 · 1 revision

Grafana

  • Navigate to your server's Grafana address (e.g. grafana.myserv.er). Here you should see a barebones Grafana running. In order to create dashboards, you will to access the login page at grafana.myserv.er/login. The default login is admin/admin - change this to something of your choice.
  • Navigate to grafana.myserv.er/dashboards and set up a folder to house all of your dashboards - such as GEM Romania. Remember this folder name, as you will need it later for the Jupyter notebook.
  • Now you will need to import the 6 dashboards of the website: 3 languages in 2 themes each.
    • In the jupyter folder you will find 3 .json files, import these one by one, preserving the dashboard IDs and always importing into your Grafana folder that you have just created. After they have been imported, create one copy of each, and add -light at the end of their IDs upon import. You should end up with 6 dashboards in total: HU, RO, EN, HU-light, RO-light, EN-light. You may, of course, change this structure - but then make sure you take that into account in Jupyter, too.
  • Next you will need to create an API key for you to be able to control Grafana through python from Jupyter.
    • Navigate to grafana.myserv.er/org/apikeys and generate an Editor role key.
  • Now you should have some dashboards nicely showing up - although not quite styled the correct way yet. We will fix that in a minute. First, we will need to find out what is the build string of your Grafana installation.
    • Back in the terminal either enter the grafana container and run 'find /usr/share/grafana/public/build -type f -name "*.css"`
    • Alternatively, you can directly: docker exec -it grafana find /usr/share/grafana/public/build -type f -name "*.css"
    • You should see two .css files listed, with a build string between dark (light) and .css. Copy this.
  • Next we need to insert the correct build string into Grafana's index.html.
    • In your folder structure, edit the file html/style/grafana/index.html
      • In line 31 replace build string in the .css file path with yours
      • In lines 267-271 replace build string in the .js file paths with yours
      • In lines 196-203 replace href attributes of the links with your site's address
      • (These instructions are valid for Grafana v7.0, they may change for later versions)
    • Next, edit the file html/style/grafana/style.sh
      • In lines 1-2 replace build string in the .css file paths with yours
  • Then, run the following commands to install the custom CSS styles into your dashboard:
    • chmod -x html/style/grafana/style.sh
    • bash html/style/grafana/style.sh
  • Now your dahsboards look pretty - but they still hold no data..

Jupyter

Navigate to your server's Jupyter address (jupyter.myserv.er) and log in with the Jupyter password you have set up in the Dockerfile. Then a Jupyter Lab interface will start. Navigate into the work folder.

  • Create a folder named auth
    • Here you will need to create 4 files:
      • influx.txt - containing only your InfluxDB admin password string access token
      • mapbox.txt - containing your Mapbox API key
      • grafana.txt - containing only your Grafana API key
      • sheet.txt - containing only your Google Sheet ID (if applicable)
  • Start the formatter.ipynb and run the first 7 cells - until the InfluxDB databases are created.

InfluxDB

Initiate the Inflxud Next task is to set up the the InflxuDB as a data source in Grafana.

  • Navigate to grafana.myserv.er/datasources and click on a new InfluxdDB data source.
    • Name it InfluxDB
    • url should be http://influxdb:8086 - i.e. it connects to your InfluxDB instance through the Docker backend.
    • Organization is roeim
    • Database is base
    • User is admin
    • Password is your InfluxDB admin password access token
    • Click on Save & Test at the bottom of the page
  • Repeat the steps above for another InfluxDB data source, named InfluxDB-long, with Database equal to long.

Data update

Back to the Jupyter, you should be able to run the rest of the cells to achieve a full data update of the site. At the end of the operation, all panels in Grafana should show correct values. The last thing you will need to do is to set up the default dashboard Grafana will show you upon login:

  • On the Grafana homepage, you will see a dashboard list. Star one or or more of the dashboards.
  • In the grafana.myserv.er/org set the Home Dashboard to your preferred dashboard.

It is worth mentioning that by default, all dashboards are updated using the Jupyter script taking the HU dashboard as the reference. You may change this in the Grafana section of the formatter.ipynb Jupyter notebook.

πŸ‘©β€πŸš€ HAVE FUN!

This is all you need to be up and running with a full setup of your GEM. You may, however, want to read further about πŸ‘‰ 4. Update.

Clone this wiki locally