Telegraf - alias for multiple agents

Hi,

Could you please confirm how to add alias names for multiple agents separately in Inputs.snmp configuration?

Here is the list of agents
[[inputs.snmp]]
agents = [
“udp://11.12.21.21:161”,
“udp://11.12.21.22:161”,
“udp://11.12.21.23:161”,
“udp://11.12.21.24:161”,
“udp://11.12.21.25:161”,
“udp://11.12.21.26:161”,
“udp://11.12.21.27:161”,
“udp://11.12.21.28:161”
]

@Hipska could you please provide some solution on this. I tried following options but it doesn’t work.

Option-1
[[inputs.snmp]]
agents = [“udp://11.12.21.21:161”]
alias = “US-server”
agents=[“udp://11.12.21.21:161”],
alias = “UK-server”

Option-2
[[inputs.snmp]]
agents = [“udp://11.12.21.21:161”]
alias = “US-server”

[[inputs.snmp]]
agents=[“udp://11.12.21.21:161”],
alias = “UK-server”

Option 2 looks indeed how you should proceed.

Thank you for your quick response, I dont see agent_host column get change with alias in the influxDB if I choose option-2. Do I need to enable any additional parameter within Telegraf?
Thanks,

I don’t understand your question, but you can always run telegraf --test with your config to see if you are getting the correct metrics.

Sorry if my above query confusing you.
I mean even after adding the alias it still sending the IP address in influxDB instead of hostname of Alias.

Do I need to modify anything within Telegraf for the Agent_Host in order to send the alias names instead of IP as an output to the InfluxDB?

This is very different question than your original question.

alias is used to name and distinguish different plugins from each other. This is especially helpful for logging. It is not used to rename metrics or change the data when sending it.

I think the easiest method to add your “alias” to your metrics is to add a new tag for each snmp output:

[[inputs.snmp]]
  agents=["udp://11.12.21.21:161"]
  tags = {alias = "UK-server"}

You could also use a processor to swap out the agent_host for your alias if you didn’t want antoher tag.

1 Like

Thank you for the solution @Hipska. Now I am getting necessary data after adding the tag values.

@Hipska, I see the alias tab created in influxDB but currently only one agent name is appearing.

Out of 10 agents, the last agents displaying with alias name. Do I need to modify anything in the Telegraf in presenting all agents alias names

Please don’t @ me anymore!

What does your current config look like? Did you change the value of the tags for each input config?

(Please also put your config inside a code block for better readability)

Yes I added the tags for each agent in the input.snmp, here is the configuration.

[global_tags]
  # dc = "us-east-1" # will tag all metrics with dc=us-east-1
  # rack = "1a"
  ## Environment variables can be used as tags, and throughout the config file
  #user = "$USER"

[agent]
  ## Default data collection interval for all inputs
  #interval = "10s"
  ## Rounds collection interval to 'interval'
  ## ie, if interval="10s" then always collect on :00, :10, :20, etc.
 round_interval = true
  hostname = ""
 ## If set to true, do no set the "host" tag in the telegraf agent.
 omit_hostname = false

  ## Method of translating SNMP objects. Can be "netsnmp" (deprecated) which
  ## translates by calling external programs snmptranslate and snmptable,
  ## or "gosmi" which translates using the built-in gosmi library.
  # snmp_translator = "netsnmp"

  ## Name of the file to load the state of plugins from and store the state to.
  ## If uncommented and not empty, this file will be used to save the state of
  ## stateful plugins on termination of Telegraf. If the file exists on start,
  ## the state in the file will be restored for the plugins.
  # statefile = ""




# # Configuration for sending metrics to InfluxDB 2.0
[[outputs.influxdb_v2]]
#   ## The URLs of the InfluxDB cluster nodes.
#   ##
#   ## Multiple URLs can be specified for a single cluster, only ONE of the
#   ## urls will be written to each interval.
#   ##   ex: urls = ["https://us-west-2-1.aws.cloud2.influxdata.com"]
urls = ["http://10.XX.XX.XX:8086"]
#
#   ## Token for authentication.
token = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx"
#
#   ## Organization is the name of the organization you wish to write to.
organization = "SBC-TEST"
#
#   ## Destination bucket to write into.
bucket = "Oracle_SNMP_US"
#
#   ## The value of this tag will be used to determine the bucket.  If this
#   ## tag is not set the 'bucket' option is used as the default.
#   # bucket_tag = ""
#
#   ## If true, the bucket tag will not be added to the metric.
#   # exclude_bucket_tag = false
#
#   ## Timeout for HTTP messages.
#   # timeout = "5s"
#
#   ## Additional HTTP headers
#   # http_headers = {"X-Special-Header" = "Special-Value"}
#
#   ## HTTP Proxy override, if unset values the standard proxy environment
#   ## variables are consulted to determine which proxy, if any, should be used.
#   # http_proxy = "http://corporate.proxy:3128"
#
#   ## HTTP User-Agent
user_agent = "telegraf"


[[inputs.snmp]]
agents = ["udp://10.XX.XX.XX:161"]
tags = {alias = "US-ECB01"}

[[inputs.snmp]]
agents= ["udp://10.XX.XX.XX:161"]
tags = {alias = "US-ECB02"}

[[inputs.snmp]]
agents= ["udp://10.XX.XX.XX:161"]
tags= {alias = "US-SBC1"}

[[inputs.snmp]]
agents= ["udp://10.XX.XX.XX:161"]
tags= {alias = "US-SBC02"}

[[inputs.snmp]]
agents= ["udp://10.XX.XX.XX:161"]
tags = {alias= "US-SBC05"}



path = ["/usr/share/snmp/mibs"]
#
#   ## SNMP community string.
community = "SBCInfluxdb"
#
#   ## Agent host tag
agent_host_tag = "agent_host"
#



[[inputs.snmp.table]]
   oid = "ACMEPACKET-ENVMON-MIB::apEnvMonTemperatureStatusTable"
   name = "SBC-TempStatus"
   index_as_tag = true

[[inputs.snmp.table]]
   oid = "APSYSMGMT-MIB::apSipSessionAgentStatsTable"
   name = "SBC-AgentTableStatus"
 # inherit_tags = ["source"]

Again, please put all of it in one code block. I will not reply on topic until you edit your post. As you can see, it is unreadable like this…

Please check now if you are able to validate the configuration file. Thanks

Okay, I only see a table to be collected for the device US-SBC05, I assume that is also the one that you can find in InfluxDB?

You also need to specify which tables/fields to be collected for the other devices…

Ok, you mean to say, I need to add table and field separately for all agents?

Correct.

Sorry, this reply didn’t come through due to some minimal character limitation…