DEV Community

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

Collapse
 
jt196 profile image
jt196 • Edited

Dude there's some weird formatting going on in the docker-compose file. I'm fairly new to it so could be wrong, the Telegraf ENV section has non-standard (maybe CLI?) formatting:

environment:
      HOST_PROC: /rootfs/proc
      HOST_SYS: /rootfs/sys
      HOST_ETC: /rootfs/etc

Shouldn't it be:

    environment:
      - HOST_PROC=/rootfs/proc
      - HOST_SYS=/rootfs/sys
      - HOST_ETC=/rootfs/etc

I tried adding these with other standard variables and the basically got eaten up into the final line. Or I got error codes.

Collapse
 
project42 profile image
Project-42

I think it depends of your version (I'm not expert either :) )

You can set the docker composer "syntax version" you want to use .
The files I have in the post works as long as you use that version, but is true that if you don't specify "version 2" you may have issues... I know because I have same problems you mentioned trying other stuff... :)

Have a look here to see how to set it up
docs.docker.com/compose/compose-fi...

This is the system I use:

vault in /vol01/Docker/monitoring ○ → docker-compose --version
docker-compose version 1.21.0, build unknown
vault in /vol01/Docker/monitoring ○ → docker --version
Docker version 19.03.8, build afacb8b7f0
vault in /vol01/Docker/monitoring ○ → head -1 /etc/*rel*
PRETTY_NAME="Debian GNU/Linux 10 (buster)"

I just tried to start grafana again and seems that I made a mistake adding this at the end:

volumes:
  grafana-volume:
    external: true
  influxdb-volume:
    external: true

I just changed to false so you dont have to have the volumens created previously.. but not sure if that is the issue you are having.. sorry

volumes:
  grafana-volume:
    external: false
  influxdb-volume:
    external: false
15:02:39 |=| vault in /vol01/Docker/monitoring ○ → docker-compose up -d
Creating volume "monitoring_grafana-volume" with default driver
Creating volume "monitoring_influxdb-volume" with default driver
Creating grafana  ... done
Creating influxdb ... done
Creating telegraf ... done

15:02:43 |=| vault in /vol01/Docker/monitoring ○ → 

let me know the errors and see if I can help :)

Collapse
 
boiddude profile image
boiddude

If you don't have a host IP what would you use instead. I am having an issue with telegraf being able to put any information into influx. Any ideas? I am using a docker-compose file. Also you set a user of telegraf but no password. It shouldn't use admin's password by default. How would you set the telegraf user password in docker-compose? Thanks for any help you can offer. I tried substituting localhost in for the ip address but that didn't work.

Thread Thread
 
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:/#