Various telegraf qns

  • Is it possible to have multiple output plugins? How do I direct an input
    with an output type?
  • How can control the number of input pollers running concurrently?
  • How can I customise the measurement name of the Nagios data format? eg.
    I have the following configured…
    [[inputs.exec]]

Commands array

commands = [ “/usr/lib/nagios/plugins/check_nrpe -H foo -c check_disk” ]

Timeout for each command to complete.

timeout = “60s”

measurement name suffix (for separating different commands)

name_suffix = “_mycollector”

data_format = "nagios

And it’s giving me

nagios_state_mycollector,host=grafana state=0i 1525189319000000000
/_mycollector,unit=MB,host=grafana max=4000,value=1945,warning=4000,min=0

I would like the output be stored as
disk,fs=/,unit=MB,hostname=foo max=4000,value=1945,warning=4000,min=0 1525189319000000000
etc

Make sure to reference the docs on configuration for more details, but here are some quick answers:

Is it possible to have multiple output plugins?

Yes, you can specify multiple outputs of the same or different types.

How do I direct an input with an output type?

Use the measurement filtering options

How can control the number of input pollers running concurrently?

Inputs run every interval, you can give an input a plugin specific interval or use the agent level interval. You can use the collection_jitter option to reduce the thundering herd effect.

How can I customise the measurement name of the Nagios data format?

Use the name_override option on the input

I’ve set the name_override, but now I lose the mount point. How can I set the mount point as a tag name?

There isn’t a way currently to move the measurement name into a tag in Telegraf, but since this is running as a exec script maybe you could wrap it using something like this:

#!/bin/sh
out=$(/usr/lib/nagios/plugins/check_nrpe -H foo -c check_disk)
echo "disk,fs=$out"

You would need to improve this to deal with multiple lines and errors running the command but it might be a workaround.

Thanks. I wasn’t able to find the part in measurements filtering where I can associate an output plugin to an input. Can I have an example?
Also, speaking of measurement filtering, how can I filter by field value instead of name?

eg. given the following, i would like to only include / and /boot
HOST-RESOURCES-MIB::hrStorageDescr.1 = STRING: Physical memory
HOST-RESOURCES-MIB::hrStorageDescr.3 = STRING: Virtual memory
HOST-RESOURCES-MIB::hrStorageDescr.6 = STRING: Memory buffers
HOST-RESOURCES-MIB::hrStorageDescr.7 = STRING: Cached memory
HOST-RESOURCES-MIB::hrStorageDescr.10 = STRING: Swap space
HOST-RESOURCES-MIB::hrStorageDescr.31 = STRING: /
HOST-RESOURCES-MIB::hrStorageDescr.35 = STRING: /dev/shm
HOST-RESOURCES-MIB::hrStorageDescr.36 = STRING: /boot

Here is an example using namepass/namedrop to split metrics out to different outputs, but you can also use the other filtering options in a similar way to filter on other criteria.

There isn’t currently a way to filter by field value, we will probably add this in the future though. In this specific case you might want to save hrStorageDescr as a tag and then use tagpass to include only the values you want.

  [[inputs.snmp.table]]
    oid = "HOST-RESOURCES-MIB::hrStorageTable"

	[[inputs.snmp.table.field]]
	oid = "HOST-RESOURCES-MIB::hrStorageDescr"
	name = "desc"
	is_tag = true

  [inputs.snmp.tagpass]
    desc = ["/", "/boot"]