telegraf和influxdb都是運(yùn)行在docker 上面查刻,influxdb沒(méi)有顯示http鏈接信息,以下是telegraf的日志:
# docker run -v /root/telegraf:/etc/telegraf/telegraf.conf -v /var/run:/var/run telegraf
2019-10-21T08:30:30Z I! Starting Telegraf 1.12.3
2019-10-21T08:30:30Z I! Using config file: /etc/telegraf/telegraf.conf
2019-10-21T08:30:30Z I! Loaded inputs: diskio kernel mem processes swap system cpu disk
2019-10-21T08:30:30Z I! Loaded aggregators:
2019-10-21T08:30:30Z I! Loaded processors:
2019-10-21T08:30:30Z I! Loaded outputs: influxdb
2019-10-21T08:30:30Z I! Tags enabled: host=d73cf0686f67
2019-10-21T08:30:30Z I! [agent] Config: Interval:10s, Quiet:false, Hostname:"d73cf0686f67", Flush Interval:10s
2019-10-21T08:30:30Z W! [outputs.influxdb] when writing to [http://127.0.0.1:8086]: database "telegraf" creation failed: Post http://127.0.0.1:8086/query: dial tcp 127.0.0.1:8086: connect: connection refused
2019-10-21T08:30:50Z E! [outputs.influxdb] when writing to [http://127.0.0.1:8086]: Post http://127.0.0.1:8086/write?consistency=any&db=telegraf: dial tcp 127.0.0.1:8086: connect: connection refused
2019-10-21T08:30:50Z E! [agent] Error writing to outputs.influxdb: could not write any address
2019-10-21T08:31:00Z E! [outputs.influxdb] when writing to [http://127.0.0.1:8086]: Post http://127.0.0.1:8086/write?consistency=any&db=telegraf: dial tcp 127.0.0.1:8086: connect: connection refused
2019-10-21T08:31:00Z E! [agent] Error writing to outputs.influxdb: could not write any address
2019-10-21T08:31:10Z E! [outputs.influxdb] when writing to [http://127.0.0.1:8086]: Post http://127.0.0.1:8086/write?consistency=any&db=telegraf: dial tcp 127.0.0.1:8086: connect: connection refused
2019-10-21T08:31:10Z E! [agent] Error writing to outputs.influxdb: could not write any address
為什么telegraf一直請(qǐng)求不到influxdb呢?這個(gè)煞筆問(wèn)題我自己的鍋咳胃,改一下telegraf配置ip地址就好了。
因?yàn)閮蓚€(gè)服務(wù)都是在在docker上運(yùn)行的,所以telegraf請(qǐng)求的ip地址不能填localhost或者127.0.0.1询张。
需要填docker分配的地址或者本機(jī)的ip地址,建議選后者浙炼。