OPNsense Forum

Archive => 20.1 Legacy Series => Topic started by: Maltech on May 04, 2020, 10:19:37 am

Title: Get metrics from unbound via telegraf
Post by: Maltech on May 04, 2020, 10:19:37 am
I'm trying to get statistics from unbound with telegraph. So far I have these lines added to the telegraf config:

Code: [Select]
[[inputs.unbound]]
  binary = "/usr/local/sbin/unbound-control"
  thread_as_tag = false

But I get the following error:

Code: [Select]
E! [inputs.unbound] Error in plugin: error gathering metrics: error running unbound-control: exit status 1 (/usr/local/sbin/unbound-control [stats_noreset])
When I execute the command on the shell I also get an error but without the square brackets it works.
Code: [Select]
/usr/local/sbin/unbound-control stats_noreset
But how can I remove these brackets from the telegraf?
Title: Re: Get metrics from unbound via telegraf
Post by: andrema2 on July 06, 2020, 04:38:57 pm
Hi

Have you figure it out ?
Title: Re: Get metrics from unbound via telegraf
Post by: andrema2 on July 07, 2020, 06:56:25 pm
Hi

So, I kinda found a solution.

I change the input from unbound to exec
[[inputs.exec]]
  commands = ["sh /root/unbound-control.sh"]
  timeout = "5s"
  data_format = "logfmt"

I created a script but it can be the unbound-control command line without a problem.

You have to add telegraf to unbound group.

pw group mod unbound -m telegraf

Instead of going into unbound it is going to exec in the Influx.

The problem that I'm facing is after the restart of the OPNsense telegraf looses unbound group. If someone can help me with it, that would be great.
Title: Re: Get metrics from unbound via telegraf
Post by: Martink on March 11, 2021, 08:56:49 pm
Hi, before starting a new thread I wanted to bump this. I tried both approaches, but neither is working out for me.

When I leave it to the simple unbound input I still get this error.
On the CLI I can issue the telegram command and it returns the entries perfectly fine, in the log in the GUI the error, I tried multiple searching within Google but no success, open for suggestion :-)