DEV Community

Discussion on: Install Grafana/InfluxDB/Telegraf using Docker Compose

 
project42 profile image
Project-42

Sorry, I did this a while ago and I think I was testing more things because some of the parameters looks like are no really needed

have a look to this tutorial to undertand what I tried to do but with docker instead of doing it directly in the system:

lkhill.com/telegraf-influx-grafana...

I guess you could use "localhost" instead the IP.
In my system, I wanted to monitor the rest of the "192.168.0.0" network, so I created the "monitoring network" so the containers had access to the rest of that network. Hope that makes sense
Checking other implementations, looks like is not really necessary, but it depends of what you want to make with it.
Check this compose file github.com/guessi/docker-compose-g...

No need for user/passwords in the docker compose file.
Looks like you can just use this:

  influxdb:
    image: influxdb
    container_name: influxdb
    restart: always
    ports:
      - 8086:8086
      - 8082:8082
      - 8083:8083
      - 8089:8089/udp
    networks:
      - monitoring
    volumes:
      - influxdb-volume:/vol01/Docker/monitoring
    #environment:
      #- INFLUXDB_DB=telegraf
      #- INFLUXDB_USER=telegraf

      #- INFLUXDB_ADMIN_ENABLED=true
      #- INFLUXDB_ADMIN_USER=admin
      #- INFLUXDB_ADMIN_PASSWORD=Welcome1

And this in the telegraf.conf file:

[[outputs.influxdb]]
urls = ["http://192.168.0.110:8086"]
database = "telegraf"

Have a look to the influxdb login policy:
docs.influxdata.com/influxdb/v1.8/...

If you have logging set in your telegraf.conf file, you can see the logs to see what errors can see.
For example, I changed the password to incorrect one and this is what you can see:

server → docker exec -it telegraf bash
root@795542fcbc9d:/# grep -i influx /var/log/telegraf/telegraf.log
2020-09-05T10:22:50Z I! Loaded outputs: influxdb
2020-09-05T10:22:50Z D! [agent] Attempting connection to [outputs.influxdb]
2020-09-05T10:22:51Z D! [agent] Successfully connected to outputs.influxdb
[...]
2020-09-05T11:40:03Z D! [outputs.influxdb] Wrote batch of 35 metrics in 17.422285ms
2020-09-05T11:40:03Z D! [outputs.influxdb] Buffer fullness: 0 / 10000 metrics
2020-09-05T11:40:13Z D! [outputs.influxdb] Wrote batch of 35 metrics in 11.678203ms
2020-09-05T11:40:13Z D! [outputs.influxdb] Buffer fullness: 0 / 10000 metrics
2020-09-05T11:40:23Z D! [outputs.influxdb] Wrote batch of 35 metrics in 11.370412ms
2020-09-05T11:40:23Z D! [outputs.influxdb] Buffer fullness: 0 / 10000 metrics
2020-09-05T11:40:33Z D! [outputs.influxdb] Wrote batch of 35 metrics in 19.247827ms
2020-09-05T11:40:33Z D! [outputs.influxdb] Buffer fullness: 0 / 10000 metrics
root@795542fcbc9d:/#