Adding metrics to service monitoring telegraf

Is it possible to add metrics to telegraf monitoring service ?
Would be nice to have vpn remote access statistics:

  • number of sessions, tunnels per vrf
  • traffic per vrf or interface

i added

[[inputs.exec]]
  commands = ["/etc/telegraf/l2tp-tun.sh"]
  name_override = "l2tp_active_tunnels"
  data_format = "value"
  data_type = "integer"
[[inputs.exec.tags]]
  host = "vyos-lns-1"

to /etc/telegraf/telegraf.d/execinput.conf

The metric is shown by
telegraf -test -config /run/telegraf/vyos-telegraf.conf -config-directory /etc/telegraf/telegraf.d

l2tp_active_tunnels,host=vyos-lns-1 value=1i 1660743503000000000

But it is not available through prometheus-client interface at http://localhost:9273/metrics. Why?
When i run telegraf in test mode, i see exec script working:

Aug 17 16:50:13 accel-l2tp[2310]: cli: tcp: new connection from 127.0.0.1
Aug 17 16:50:13 accel-l2tp[2310]: cli: disconnect

but no periodic connections from telegraf daemon

The l2tp-tun.sh exec script is:

#!/bin/bash
accel-cmd -p 2004 'show stat' | grep -A3 l2tp: |grep active|cut -d' ' -f6

Try to enable debug in vyos-telegraf.conf and restart the service

monitor-log.txt (13.7 KB)

I did debug, but i can see nothing in log except two accel-cmd connections when i run telegraf -test manually:

Aug 18 12:50:46 accel-l2tp[2310]: cli: tcp: new connection from 127.0.0.1
Aug 18 12:50:46 accel-l2tp[2310]: cli: disconnect
Aug 18 12:50:46 accel-l2tp[2310]: cli: tcp: new connection from 127.0.0.1
Aug 18 12:50:46 accel-l2tp[2310]: cli: disconnect

sudo nano /run/telegraf/vyos-telegraf.conf
Put your input.exec to conf file and restart service

sudo systemctl restart vyos-telegraf

that did not help either.
I moved all inputs.exec sections from /etc/telegraf/telegraf.d/execinput.conf to /run/telegraf/vyos-telegraf.conf.
But no accel-cmd runs are observed, and no metrics available from inputs.exec.
monitor-log.txt (11.1 KB)

Sorry, that was my fault.
The telegraf process was started within vrf oam, but the script executed by telegraf should operate in vrf default. That was the issue.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.