I can pull Docker metrics successfully using
[[inputs.docker]] in a test setting - the user has access to docker group. However, I’m also interested in logging specific events from a container and this plugin only outputs overall metrics and stats.
So I looked into
[[inputs.socket_listener]]. I have no idea what kind of data will come out, but I know what I’m looking for from watching
sudo docker logs -f <container>. A few things came up during testing:
telegraf --config <file> --testdoesn’t work:
[agent] skipping plugin [[inputs.socket_listener]]: service inputs not supported in --test mode
[[inputs.docker]] works just fine with
--test. I suggest this information should be added to https://github.com/influxdata/telegraf/blob/master/plugins/inputs/socket_listener/README.md
Then, an output plugin is mandatory when not running in
--testmode. Fine, I added
[[outputs.file]] files = ["stdout"]
to the test .conf and since I don’t know what kind of data format to expect, I then added
data_format = "value" data_type = "string"
but this is also not supported
[telegraf] Error running agent: Error parsing inputs.socket.conf, Invalid data format: value
and this error went away when I switched to
data_format = "influx".
Maybe this limitation of the
[[outputs.file]] plugin should also be indicated in https://github.com/influxdata/telegraf/blob/master/plugins/outputs/file/README.md
- Finally I got this
$ telegraf --config inputs.socket.conf
2019-08-19T12:06:38Z I! Starting Telegraf 1.11.4
2019-08-19T12:06:38Z I! Loaded inputs: socket_listener
2019-08-19T12:06:38Z I! Loaded aggregators:
2019-08-19T12:06:38Z I! Loaded processors:
2019-08-19T12:06:38Z I! Loaded outputs: file
2019-08-19T12:06:38Z I! Tags enabled: host=hostname
2019-08-19T12:06:38Z I! [agent] Config: Interval:10s, Quiet:false, Hostname:“hostname”, Flush Interval:10s
2019-08-19T12:06:38Z E! [agent] Service for input inputs.socket_listener failed to start: listen unix /var/run/docker.sock: bind: address already in use
2019-08-19T12:06:38Z E! [telegraf] Error running agent: listen unix /var/run/docker.sock: bind: address already in use
And immediately after I ran the [[inputs.docker]] file in
--test mode and it produced and output, in spite of using the same endpoint address, “unix:///var/run/docker.sock”.
So why does it work in one situation and not the other and what can I do to fix it?
The tests where done in a VPS that already has a Telegraf systemd service running, gathering general system metrics. This service has no
[[inputs.docker]] plugins configured. The .conf files used in the testing were in the user’s home dir, not in /etc/telegraf/telegraf.d/.