1
votes

Firstly I ran a influxdb container by docker client . And now I want to run a telegraf container which collects the containers' datas and the hypervisor host' data like cpu\mem\diskio and so on . But I failed , the docker logs show that I can't map the custom telegraf.conf to the container's /etc/telegraf/telegraf.conf .

BASIC INFO :

  1. docker version : 1.13.1
  2. centos version : centos7
  3. kernel version : 3.10.0-957.12.2.el7.x86_64

COMMANDS I tried :

  1. Influxdb : docker network create influxdb docker run -d -p 8086:8086 -p 8083:8083 --name=influxdb --net=influxdb docker.io/influxdb

  2. Telegraf : docker run -d --name=telegraf --net=influxdb \ -e HOST_PROC=/host/proc \ -v /proc:/host/proc:ro \ -v /var/run/docker.sock:/var/run/docker.sock \ -v /root/telegraf.conf:/etc/telegraf/telegraf.conf:ro \ telegraf

[root@localhost ~]# docker logs telegraf 2019-05-19T03:05:17Z I! Starting Telegraf 1.10.4 2019-05-19T03:05:17Z E! [telegraf] Error running agent: No config file specified, and could not find one in $TELEGRAF_CONFIG_PATH, /root/.telegraf/telegraf.conf, or /etc/telegraf/telegraf.conf

1

1 Answers

0
votes

You can try this docker-compose.yaml

version: '3'
services:
  influxdb:
    image: influxdb:1.7.8
    container_name: influxdb
    volumes:
      # Mount for influxdb data directory
      - ./monitoring/influxdb:/var/lib/influxdb
      # Mount for influxdb configuration
      - ./monitoring/influxdb/config/:/etc/influxdb/
    ports:
      - "8086:8086"
      - "8082:8082"
      - "8089:8089/udp"

  telegraf:
    image: telegraf:1.12.2
    container_name: telegraf
    environment:
      HOST_MOUNT_PREFIX: "/hostfs"
      HOST_PROC: "/hostfs/proc"
      HOST_SYS: "/hostfs/sys"
      HOST_ETC: "/hostfs/etc"
    volumes:
      # Mount for telegraf configuration
      - ./monitoring/telegraf/:/etc/telegraf/
      - /:/hostfs:ro
      - /var/run/docker.sock:/var/run/docker.sock
    depends_on:
      - influxdb

  chronograf:
    image: chronograf:1.7.14
    container_name: chronograf
    environment:
      RESOURCES_PATH: "/usr/share/chronograf/resources"
    volumes:
      # Mount for chronograf database
      - ./monitoring/chronograf/data/:/var/lib/chronograf/
    ports:
      - "8890:8888"
    depends_on:
      - influxdb
      - telegraf

here you can find how configure telegraf plugins to get information about your system