Skip to content

Instantly share code, notes, and snippets.

@krishofmans
Last active February 16, 2017 20:31
Show Gist options
  • Select an option

  • Save krishofmans/85c8b4e6997a435d5b4e1219b2bd09e4 to your computer and use it in GitHub Desktop.

Select an option

Save krishofmans/85c8b4e6997a435d5b4e1219b2bd09e4 to your computer and use it in GitHub Desktop.
Setup basic grafana/influxdb/telegraf environment to play with

Create a software defined network that we will use to let the containers communicate with eachother

docker network create statnet --attachable

Create a volume container for grafana's configuration + grafana instance

docker run -d -v /var/lib/grafana --name grafana-storage busybox:latest

docker create \
--name=grafana \
-p 3000:3000 \
--volumes-from grafana-storage \
-e "GF_SECURITY_ADMIN_PASSWORD=hunter2" \
--network=statnet \
grafana/grafana

Create volumes for influx data + basic configuration file

mkdir -p ~/docker/volumes/influxdb/conf
mkdir -p ~/docker/volumes/influxdb/db

docker run --rm influxdb influxd config > ~/docker/volumes/influxdb/conf/influxdb.conf

update config to enable admin ui, cmd-f, search admin, set boolean to true

Create database instances

docker create \
--name influxdb \
-e PUID=1000 -e PGID=1000 \
-p 8083:8083 -p 8086:8086 \
-v ~/docker/volumes/influxdb/conf/influxdb.conf:/etc/influxdb/influxdb.conf:ro \
-v ~/docker/volumes/influxdb/db:/var/lib/influxdb \
--network=statnet \
influxdb -config /etc/influxdb/influxdb.conf

Setup telegraf, this will feed data that we can show in grafana later

mkdir -p ~/docker/volumes/telegraf/

docker run --rm telegraf -sample-config > ~/docker/volumes/telegraf/telegraf.conf

Open the telegraf config file and search for outputs.influxdb, change the link to point to the name of the influxdb container:

# Configuration for influxdb server to send metrics to
[[outputs.influxdb]]
  urls = ["http://influxdb:8086"] # required, change from localhost to influxdb, docker will make it know the dns named based on the container name
  database = "telegraf" # required
  precision = "s"

Then run telegraf

docker run \
--name telegraf \
--restart=always \
--net=container:influxdb \
-v ~/docker/volumes/telegraf/telegraf.conf:/etc/telegraf/telegraf.conf:ro \
--network=statnet \
nuntz/telegraf-snmp

It should by default sent data from the local machine like cpu/memory stats to influx, and the dashboard can be created here: http://localhost:3000/

In case things fail, and retry :)

docker rm -f grafana
docker rm -f influxdb
docker rm -f telegraf
@tcoopman
Copy link

docker start influxdb

http://localhost:8083/

docker start grafana

http://localhost:3000/login

login: admin
pass: hunter2

@krishofmans
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment