Skip to content

Setting up a test Grafana in Docker

Jerry Lundström edited this page Nov 2, 2022 · 4 revisions

This wiki was submitted by a user and is currently out of date, if anyone want to update it let me know! /@jelu


When it is too much hassle to run the InfluxDB/Grafana on a local machine, one can opt for a Docker deployment. I've found that wasn't too hard to do. The following is done on a CentOS8 host with docker-ce and docker-compose installed. Instructions to install them on CentOS8 is found in the internet.

For the InfluxDB/Grafana I have followed the instructions from Alexey Nizhegolenko.

The setup is done in the docker-compose.yaml file:

services:
  grafana:
    image: grafana/grafana
    container_name: grafana
    restart: always
    ports:
      - 3000:3000
    networks:
      - monitoring
    volumes:
      - /vol/dns/monitor/volumes/grafana-data:/var/lib/grafana
  influxdb:
    image: influxdb
    container_name: influxdb
    restart: always
    ports:
      - 8086:8086
    networks:
      - monitoring
    volumes:
      - /vol/dns/monitor/volumes/influxdb-data:/var/lib/influxdb
networks:
  monitoring:

And now it's getting real simple. Start the containers...:

$ docker-compose up -d

Create the DSC database in the influxdb instance:

$ docker exec -ti influxdb sh
# influx -execute "create database dsc"
# exit

Install the Grafana piechart panel in the grafana instance:

$ docker exec -ti grafana sh
/usr/share/grafana $ grafana-cli plugins install grafana-piechart-panel
/usr/share/grafana $ exit

Restart the enviroment to activate the Grafana plugin.

$ docker-compose restart

When you go to http://localhost:3000 you can login to the dashboard of Grafana. Use admin/admin and you are forced to enter a new password. From now on you can follow the instructions of Jerry for adding the datasource and the dashboards using the json files (download them, you can add them with your browser).

You will also need to install dsc-datatool and setup IANA DNS parameters along with MaxMind databases, see the full guide for those instructions.

And the the Jerry magic continues:

SERVER="your-server-change-it"
NODE="your-node-change-it"
XML="your-xml-file-change-it"
dsc-datatool \
  --server "$SERVER" \
  --node "$NODE" \
  --output ";InfluxDB;file=influx.txt;dml=1;database=dsc" \
  --transform ";Labler;*;yaml=$HOME/labler.yaml" \
  --transform ";ReRanger;rcode_vs_replylen;range=/64;pad_to=5" \
  --transform ";ReRanger;qtype_vs_qnamelen;range=/16;pad_to=3" \
  --transform ";ReRanger;client_port_range;key=low;range=/2048;pad_to=5" \
  --transform ";ReRanger;edns_bufsiz,priming_queries;key=low;range=/512;pad_to=5;allow_invalid_keys=1" \
  --transform ";ReRanger;priming_responses;key=low;range=/128;pad_to=4" \
  --transform ";NetRemap;client_subnet,client_subnet2,client_addr_vs_rcode,ipv6_rsn_abusers;net=8" \
  --generator client_subnet_country \
  --generator ";client_subnet_authority;fetch=yes" \
  --xml "$XML"

And now import the time series based influx.txt into the influxdb instance:

$ docker exec -ti influxdb sh
# cd /var/lib/influxdb/data
# influx -import -path=influx.txt