influxdata / telegraf

Agent for collecting, processing, aggregating, and writing metrics, logs, and other arbitrary data.
https://influxdata.com/telegraf
MIT License
14.51k stars 5.55k forks source link

How to add a static tag or field and value to inputs.snmp #3279

Closed wade-lich closed 6 years ago

wade-lich commented 6 years ago

I am trying to find a way to define my data centers in my configuration for inputs.snmp.

I have devices that are the same in two DC A/B. I want to have either a field or tag I can reference as a filter in my select statements in Grafana. Is this possible?

e.g.

[[inputs.snmp.tags]] dc = "A"

This example I feel is less likely.

[[inputs.snmp.field]] name = "DataCenter" value = "B"

If I can't do it in this manner, is there a way around it?

Regards, Wade

danielnelson commented 6 years ago

You can add static tags like:

[[inputs.snmp]]
  # other stuff
  [inputs.snmp.tags]
    site=“EZE”

Make sure you put the table after any options to the plugin.

You can't add static fields, although there is an issue open to allow this #2564

All that said it might be better to use a snmp field:

[[inputs.snmp]]
  # other stuff
  [[inputs.snmp.field]]
    name = "sys_name"
    oid = "SNMPv2-MIB::sysName.0"
    is_tag = true
wade-lich commented 6 years ago

Thanks!, I had already tried the first method and didn’t see the tag key appear in the DB. I noticed here there is only one “[" and "]" not two. that was my problem.

Regards, Wade

On Sep 28, 2017, at 2:37 PM, Daniel Nelson notifications@github.com wrote:

You can add static tags like:

[[inputs.snmp]]

other stuff

[inputs.snmp.tags] site=“EZE” Make sure you put the table after any options to the plugin.

You can't add static fields, although there is an issue open to allow this #2564 https://github.com/influxdata/telegraf/issues/2564 All that said it might be better to use a snmp field:

[[inputs.snmp]]

other stuff

[[inputs.snmp.field]] name = "sys_name" oid = "SNMPv2-MIB::sysName.0" is_tag = true — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/influxdata/telegraf/issues/3279#issuecomment-332971073, or mute the thread https://github.com/notifications/unsubscribe-auth/ASwsW7Y2_D6I1Rhqy3fbOgDOxcWGMGlfks5snBGhgaJpZM4Pn6gT.

jbdupont commented 6 years ago

I am trying to implement the inputs.snmp.tags, but they don't appear to be showing in the output (Telegraf 1.5.2).

Conf file: [[inputs.snmp]] agents = [ "10.10.36.2:161" ] version = 1 community = "bHsuBuz2"

name = "site-power"

[[inputs.snmp.tags]] site = "elkhorn"

[[inputs.snmp.field]] name = "battv" oid = "1.3.6.1.4.1.4128.3"

Output: * Plugin: inputs.snmp, Collection 1 > site-power,agent_host=10.10.36.2,host=grafana battv="25.1964" 1521426117000000000

danielnelson commented 6 years ago

@jbdupont Try using a single bracket: [inputs.snmp.tags]

jbdupont commented 6 years ago

That did it. Sorry, I mis-read what waid-lich's issue was up above, but I see it now. Thank you for the quick reply!

Hipska commented 5 years ago

Is there any documentation of this feature anywhere?

Edit: Nevermind, https://github.com/influxdata/telegraf/blob/master/docs/CONFIGURATION.md#input-plugins