Install InfluxDB

  • Create network for dockers, it's better you create network for the dockers, then you can access docker with name
docker network create IoT
  • Create /data and /data/influx dir for docker volume
mkdir /data
mkdir /data/influx
  • Start influxDB with docker, The official docker image here
docker run -p 8086:8086 \
    -v /data/influx/influxdb:/var/lib/influxdb \
    -v /data/influx/influxdb2:/var/lib/influxdb2 \
    -v /data/influx/influxdb2-config:/etc/influxdb2 \
    -v /data/influx/influxdb.conf:/etc/influxdb/influxdb.conf \
    -e DOCKER_INFLUXDB_INIT_USERNAME=admin \
    -e DOCKER_INFLUXDB_INIT_PASSWORD=ConST \
    -e DOCKER_INFLUXDB_INIT_ORG=ConST \
    -e DOCKER_INFLUXDB_INIT_BUCKET=bucket \
    -e DOCKER_INFLUXDB_INIT_ADMIN_TOKEN=123 \
    --network=IoT \
    -d \
    --restart always \
    --name influx \
    influxdb
  • Now access https://ourdark.org:8086

Install telegraf

  • Create telegraf dir
mkdir /data/telegraf
  • Switch to /data/telegraf folder
cd /data/telegraf
  • Before you can mount local config file to telegraf, make sure there is telegraf.conf exists
docker run --rm telegraf telegraf config > telegraf.conf

       telegraf.conf is auto generated under /data/telegraf/ folder, then edit the config you want, mine will like this.

vim telegraf.conf
# Configuration
[agent]
  interval = "10s"
  round_interval = true
  metric_batch_size = 1000
  metric_buffer_limit = 10000
  collection_jitter = "0s"
  flush_interval = "10s"
  flush_jitter = "0s"
  precision = ""
  hostname = ""
  omit_hostname = false
[[outputs.influxdb_v2]]
  urls = ["http://link1.const.cc:8086"]
  token = "yDLG7pUZbX5uCTMf6Qnopd62yOkhazUMeRco3sP3m6syHnn0nGS1xyj-vA3f7YinUYWH6J5pwH7_YMOu0HaKiQ=="
  organization = "ConST"
  bucket = "Default"
[[inputs.cpu]]
  percpu = true
  totalcpu = true
  collect_cpu_time = false
  report_active = false
[[inputs.disk]]
  ignore_fs = ["tmpfs", "devtmpfs", "devfs", "iso9660", "overlay", "aufs", "squashfs"]
[[inputs.diskio]]
[[inputs.mem]]
[[inputs.net]]
[[inputs.processes]]
[[inputs.swap]]
[[inputs.system]]

       You can get information from https://ourdark.org:8086, navigate to data->telegraf, then create configuration with system plugin

  • Now you can start telegraf docker
docker run -v $PWD/telegraf.conf:/etc/telegraf/telegraf.conf:ro \
    --restart always \
    --name=telegraf \
    -d  \
    telegraf

      It should say "connected" after a little while, the system monitor dashboard will auto created and loaded.