SNMP input plugin custom tag

How can I set a custom tag in an SNMP plugin?
I like to have the tag “foo” present in every OID collected like so
hrStorageTable,agent_host=A.B.C.D,fs=/,foo=bar Used=100240i,Size=4056112i 1525764935000000000

Currently I have the following configured, but it’s not showing.

[agent]
omit_hostname = true

[[inputs.snmp]]
agents = [ “A.B.C.D” ]
version = 2
community = “XXXX”
interval = “300s”
timeout = “120s”

[[inputs.snmp.tags]]
foo = “bar”

[[inputs.snmp.table]]
name = “hrStorageTable”
inherit_tags = [ “foo” ]

[[inputs.snmp.table.field]]
name = “Used”
oid = “HOST-RESOURCES-MIB::hrStorageUsed”

[[inputs.snmp.table.field]]
name = “Size”
oid = “HOST-RESOURCES-MIB::hrStorageSize”

[[inputs.snmp.table.field]]
name = “fs”
oid = “HOST-RESOURCES-MIB::hrStorageDescr”
is_tag = true

I think you just need to remove one layer of brackets from your tags table:

- [[inputs.snmp.tags]]
+ [inputs.snmp.tags]
1 Like

Thanks. That fixed it.
What’s the difference between single and double brackets?

What’s the difference between single and double brackets?

In TOML double brackets define an array of tables while single brackets create a single table.

Here is an comparison using JSON format:

Single brackets:

{
	"tags": {
		"foo": "bar"
	}
}

Double brackets:

{
	"tags": [
		{
			"foo": "bar"
		}
	]
}

Details are in the TOML spec.