How to use the Telegraf inputs.intel_rdt plugin when it requires sudo privs for telegraf user

I’m attempting to use the intel_rdt plugin, which uses the /usr/local/bin/pqos command and requires root privs, but after enabling that input plugin and running the following, I get nothing:

root@stg-19 mddut ~]# telegraf --input-filter intel_rdt --test
2021-06-21T16:10:32Z I! Starting Telegraf 1.19.0
2021-06-21T16:10:32Z I! Using config file: /etc/telegraf/telegraf.conf

So, I add the following line with visudo:

telegraf        ALL=(ALL)       NOPASSWD: /usr/local/bin/pqos

And then I add “use_sudo = true” in telegraf.conf for the plugin, so that the full configuration looks like this:

[[inputs.intel_rdt]]
  ## Optionally set sampling interval to Nx100ms.
  ## This value is propagated to pqos tool. Interval format is defined by pqos itself.
  ## If not provided or provided 0, will be set to 10 = 10x100ms = 1s.
  #sampling_interval = "10"

  ## Optionally specify the path to pqos executable.
  ## If not provided, auto discovery will be performed.
  pqos_path = "/usr/local/bin/pqos"

  ## Optionally specify if IPC and LLC_Misses metrics shouldn't be propagated.
  ## If not provided, default value is false.
  shortened_metrics = false

  ## Specify the list of groups of CPU core(s) to be provided as pqos input.
  ## Mandatory if processes aren't set and forbidden if processes are specified.
  ## e.g. ["0-3", "4,5,6"] or ["1-3,4"]
  cores = ["0-15"]

  ## Specify the list of processes for which Metrics will be collected.
  ## Mandatory if cores aren't set and forbidden if cores are specified.
  ## e.g. ["qemu", "pmd"]
  use_sudo = true

But when I run a test again, I now get the following error:

[root@stg-19 mddut ~]# telegraf --input-filter intel_rdt --test
2021-06-21T16:14:59Z I! Starting Telegraf 1.19.0
2021-06-21T16:14:59Z I! Using config file: /etc/telegraf/telegraf.conf
2021-06-21T16:14:59Z E! [telegraf] Error running agent: Error loading config file /etc/telegraf/telegraf.conf: plugin inputs.intel_rdt: line 2747: configuration specified the fields ["use_sudo"], but they weren't used

How can I get this plugin working properly under the telegraf user?

My apologies. I didn’t include the error when run under the telegraf user (I temporarily changed its login shell to bash from /bin/false):

2021-06-21T17:07:35Z E! [inputs.intel_rdt] Error: pqos: exit status 1
2021-06-21T17:07:35Z E! [inputs.intel_rdt] failed to shut down pqos: os: process already finished
2021-06-21T17:07:36Z E! [telegraf] Error running agent: input plugins recorded 2 errors

@popey any thoughts here? Thank you!!

1 Like

Thanks for the post. The intel_rdt plugin doesn’t (currently) have a use_sudo option, which is why you’re getting the error when you include that in the config. The Good News however, is that there’s an open pull request which adds this option. We’ll get that on the developer radar, and hopefully it can land in a release soon.