Telegraf.d Multiple configurations are invalid

docker build telegraf However, multiple configurations do not take effect
############ docker compose ################

telegraf:
    image: telegraf:latest
    container_name: telegraf
    links:
      - influxdb
    volumes:
      - /Users/apple/vdss_volume/telegraf/telegraf.d:/etc/telegraf/telegraf.d
      - /Users/apple/vdss_volume/localtime:/etc/localtime:ro
      - /Users/apple/vdss_volume/telegraf/logs:/var/log

    deploy:
      resources:
        limits:
          cpus: '0.20'
          memory: 1024M

    restart: unless-stopped

    logging:
      driver: "json-file"
      options:
        max-size: "100m"

############################### telegraf  log   ###########################
2021-12-02T12:00:58Z E! [outputs.influxdb] When writing to [http://localhost:8086]: failed doing req: Post "http://localhost:8086/write?db=telegraf": dial tcp 127.0.0.1:8086: connect: connection refused
2021-12-02T12:00:58Z E! [agent] Error writing to outputs.influxdb: could not write any address
2021-12-02T12:01:08Z E! [outputs.influxdb] When writing to [http://localhost:8086]: failed doing req: Post "http://localhost:8086/write?db=telegraf": dial tcp 127.0.0.1:8086: connect: connection refused
2021-12-02T12:01:08Z E! [agent] Error writing to outputs.influxdb: could not write any address
2021-12-02T12:01:18Z E! [outputs.influxdb] When writing to [http://localhost:8086]: failed doing req: Post "http://localhost:8086/write?db=telegraf": dial tcp 127.0.0.1:8086: connect: connection refused
2021-12-02T12:01:18Z E! [agent] Error writing to outputs.influxdb: could not write any address
2021-12-02T12:01:28Z E! [outputs.influxdb] When writing to [http://localhost:8086]: failed doing req: Post "http://localhost:8086/write?db=telegraf": dial tcp 127.0.0.1:8086: connect: connection refused
2021-12-02T12:01:28Z E! [agent] Error writing to outputs.influxdb: could not write any address
2021-12-02T12:01:38Z E! [outputs.influxdb] When writing to [http://localhost:8086]: failed doing req: Post "http://localhost:8086/write?db=telegraf": dial tcp 127.0.0.1:8086: connect: connection refused
2021-12-02T12:01:38Z E! [agent] Error writing to outputs.influxdb: could not write any address
2021-12-02T12:01:48Z E! [outputs.influxdb] When writing to [http://localhost:8086]: failed doing req: Post "http://localhost:8086/write?db=telegraf": dial tcp 127.0.0.1:8086: connect: connection refused
2021-12-02T12:01:48Z E! [agent] Error writing to outputs.influxdb: could not write any address
################################################################################
Looks like the default configuration parameters???
However, there are mapping files in the container directory
![image|690x313](upload://8wERaOAQHzdp2RE4oN5T6lZjXII.jpeg)

![image|690x313](upload://8wERaOAQHzdp2RE4oN5T6lZjXII.jpeg)

@Jay_Clifford The boss asked for support :pray: :pray: :pray: :pray:

About the missing config
note: I know almost nothing of Docker BUT
Telegraf by default loads only the telegraf.conf file, in order to consider a folder you must explicitly say so using --config-directory, the might look like:

telegraf -config ./telegraf.conf --config-directory ./telegraf.d

After a quick googling looks like you need to specify the command/arg/entrypoint in your docker-compose file and specify that command

About the error:
This looks like a network error to me, as the error clearly says.

2021-12-02T12:01:48Z E! [outputs.influxdb] When writing to [http://localhost:8086]: failed doing req: Post "http://localhost:8086/write?db=telegraf": dial tcp 127.0.0.1:8086: connect: connection refused
2021-12-02T12:01:48Z E! [agent] Error writing to outputs.influxdb: could not write any address

The error happens every 10s because Telegraf tries to write data every 10sec, as per config flush_interval, but is unable to reach your Influx database.

If the problem was the configuration telegraf won’t even start, and an error will tell you exactly which row of the configuration is invalid.

1 Like

HI, @Giovanni_Luisotto
Good morning, Thank you very much for your prompt,I found the reason,
I was pleasantly surprised to find a line of comments in the startup file
Probably caused here
:ox::beer: ==> It means great :joy:

docker container config file: