influxdata / telegraf

Agent for collecting, processing, aggregating, and writing metrics, logs, and other arbitrary data.
https://influxdata.com/telegraf
MIT License
14.59k stars 5.56k forks source link

Systemd Units config errors on being given scope #15745

Closed Tasty213 closed 2 months ago

Tasty213 commented 2 months ago

Relevant telegraf.conf

[[inputs.systemd_units]]
  ## Pattern of units to collect
  ## A space-separated list of unit-patterns including wildcards determining
  ## the units to collect.
  ##  ex: pattern = "telegraf* influxdb* user@*"
  # pattern = "*"

  ## Filter for a specific unit type
  ## Available settings are: service, socket, target, device, mount,
  ## automount, swap, timer, path, slice and scope
  # unittype = "service"

  ## Collect system or user scoped units
  ##  ex: scope = "user"
  scope = "system"

  ## Collect also units not loaded by systemd, i.e. disabled or static units
  ## Enabling this feature might introduce significant load when used with
  ## unspecific patterns (such as '*') as systemd will need to load all
  ## matching unit files.
  # collect_disabled_units = false

  ## Collect detailed information for the units
  # details = false

  ## Timeout for state-collection
  # timeout = "5s"
[[outputs.file]]
  files = ["stdout"]

Logs from Telegraf

2024-08-15T16:09:30Z I! Loading config: /etc/telegraf/telegraf.conf
2024-08-15T16:09:30Z E! error loading config file /etc/telegraf/telegraf.conf: plugin inputs.systemd_units: line 1: configuration specified the fields ["scope"], but they were not used. This is either a typo or this config option does not exist in this version.

System info

Podman 5.1.2

Docker

FROM docker.io/library/telegraf:1.31.3

ADD ./telegraf.conf /etc/telegraf/telegraf.conf

Steps to reproduce

Build the above container using podman build podman build -f ./Containerfile --env=INFLUX_TOKEN=insert_token_here

run it podman run --cap-add cap_net_raw --env=DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus --mount=type=bind,src=/run/user/1000,dst=/run/user/1000 --mount=type=bind,src=/run/user/1000/bus,ro=true,dst=/run/user/1000/bus --mount=type=bind,src=/var/run/dbus/system_bus_socket,ro=true,dst=/var/run/dbus/system_bus_socket {insert hash from build}

Expected behavior

Telegraf monitors systemd units in the scope of the user who ran the container.

Actual behavior

Telegraf errors claiming it can't accept the scope value despite this being shown in the documentation.

Additional info

No response

powersj commented 2 months ago

That is a new feature that will go out in v1.32.0. It was landed in this PR: https://github.com/influxdata/telegraf/pull/15458

You can run a nightly build until then: https://github.com/influxdata/telegraf/blob/master/docs/NIGHTLIES.md

Tasty213 commented 2 months ago

Thanks for the clarification looking forward to 1.32!