I'm having a hard time grasping how the [global_tags] work

If I set my global tags like this:

[global_tags]
center  = "Unknown"
ups  = "Unknown"
grid  = "Unknown" 

how would I need to associate the tags with an input config similar to this?:

#USI2_UPSA_ACTIVE_POWER
#center is “USI2”; ups is “A”; grid tag not used for this reading.

  [[inputs.snmp.field]]
       oid= ".1.3.6.1.4.1.4131.1.6.3.2.1.3.102"
       name= "UPS_A_kW"
       conversion = "float"

This is a completely new area of study for me and I greatly appreciate any help!

Global tags can be specified in the [global_tags] table in key=“value” format. All metrics that are gathered will be tagged with the tags specified. Global tags are overriden by tags set by plugins.
It’s useful when using telegraf to:

Run a single telegraf collection, outputting metrics to stdout:

telegraf --config telegraf.conf --test

It’s also useful to change debug=true in the agent portion of your confing.

Does that help?

1 Like

Thank you!! After reading and practicing with --test a few times I think the lightbulb has clicked. I just needed to add [inputs.snmp.tags] Its funny how everything is obvious in hindsight. just in case anyone has the same question in the future, this is what I learned:

testing the config in my first post (before adding the [global_tags] section) yielded the output below.

snmp,agent_host=******,host=***** UPS_A_kW=162 1630531173000000000

After adding the [global_tags] section, this was the output:

> snmp,agent_host=********,center=unknown,grid=unknown,host=houdcim02,ups=unknown UPS_A_kW=163 1630531556000000000

Notice how the global tags are now listed in the output as “center = unknown” etc.
The next step was to add [inputs.snmp.tags] and define them as below:

[inputs.snmp.tags]
"center" = "USI2"
"ups" = "A"

Which yielded these results:

> snmp,agent_host=*******,center=USI2,grid=unknown,host=houdcim02,ups=A UPS_A_kW=162 1630531966000000000

Thank you for the help Anaisdg! I hope this can help some other beginner in the future.

1 Like

Hello @Rcase,
Thanks for sharing your solution!!