SensorsIot / IOTstack

Docker stack for getting started on IOT on the Raspberry PI
GNU General Public License v3.0
1.42k stars 303 forks source link

2023-06-24 Telegraf - master branch - PR 1 of 2 #718

Closed Paraphraser closed 1 year ago

Paraphraser commented 1 year ago

Issue reported on Discord led to the discovery of several problems with Telegraf:

  1. Default configuration had been amended to:

    • Add support for both InfluxDB 1.8 and InfluxDB 2; and
    • Comment-out both InfluxDB outputs.

    The practical consequences were:

    • The Dockerfile sed command could not find [outputs.influxdb], so the urls = ["http://influxdb:8086"] could not be inserted, so telegraf could not write to any database; and
    • The container went into a restart loop.
  2. The default entrypoint.sh script had been amended to invoke telegraf via:

    exec setpriv --reuid telegraf --init-groups "$@"

    Inside the container, user "telegraf" is userID 999. Outside container space, user 999 is not a member of the docker group so it doesn't have access to /var/run/docker.sock.

    The practical consequence was the telegraf process inside the container endlessly complaining:

    E! [inputs.docker] Error in plugin: permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock

Problem 1 has been addressed by removing the sed logic and adding outputs.influxdb.conf to the auto_include folder:

[[outputs.influxdb]]
urls = ["http://influxdb:8086"]

This defaults to the telegraf database and is sufficient for telegraf to get going.

Problem 2 has been addressed by not downgrading privileges. The alternative of changing the documentation to require the user to add userID 999 to the docker group is sub-optimal and not really in the spirit of IOTstack where, to the maximum extent possible, containers should "just work".