I am trying to run telegraf inside a docker container to monitor the host system metrics and have mounted the hosts file system into the container as suggested in the documentation.
The CPU, memory, disk plugins are correctly collecting metrics for the host system, but the net plugin is collecting metrics about the container not the host. This can be seen by running telegraf on the host system and comparing the metrics.
Is this expected or am I missing some config, there was nothing suggested in the docs for the plugin?
This is my docker compose config:
telegraf-system: image: docker.io/library/telegraf:1.21.4 container_name: telegraf-system restart: always privileged: true volumes: - ./telegraf/telegraf.conf:/etc/telegraf/telegraf.conf:ro - /var/run/docker.sock:/var/run/docker.sock - /:/hostfs:ro - /run/udev:/run/udev:ro depends_on: - "influxdb" environment: - HOST_MOUNT_PREFIX=/hostfs - HOST_ETC=/hostfs/etc - HOST_PROC=/hostfs/proc - HOST_SYS=/hostfs/sys - HOST_VAR=/hostfs/var - HOST_RUN=/hostfs/run