# Telegraf - alias for multiple agents

**URL:** <https://community.influxdata.com/t/telegraf-alias-for-multiple-agents/29564>\
**Category:** Telegraf\
**Created:** [April 19, 2023, 10:19am UTC](https://community.influxdata.com/t/telegraf-alias-for-multiple-agents/29564 "2023-04-19T10:19:38Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![Manju](https://avatars.discourse-cdn.com/v4/letter/m/ecd19e/32.png) [@Manju](https://community.influxdata.com/u/Manju)\
**Post date:** [April 19, 2023, 10:19am UTC](https://community.influxdata.com/t/telegraf-alias-for-multiple-agents/29564/1 "2023-04-19T10:19:38Z")

</div>

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”  
]

---

<div class="post-metadata">

**Author:** ![Manju](https://avatars.discourse-cdn.com/v4/letter/m/ecd19e/32.png) [@Manju](https://community.influxdata.com/u/Manju)\
**Post date:** [April 20, 2023, 12:56pm UTC](https://community.influxdata.com/t/telegraf-alias-for-multiple-agents/29564/2 "2023-04-20T12:56:27Z")

</div>

@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”

---

<div class="post-metadata">

**Author:** ![Hipska](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/hipska/32/3877_2.png) [@Hipska](https://community.influxdata.com/u/Hipska)\
**Post date:** [April 20, 2023, 1:32pm UTC](https://community.influxdata.com/t/telegraf-alias-for-multiple-agents/29564/3 "2023-04-20T13:32:10Z")

</div>

Option 2 looks indeed how you should proceed.

---

<div class="post-metadata">

**Author:** ![Manju](https://avatars.discourse-cdn.com/v4/letter/m/ecd19e/32.png) [@Manju](https://community.influxdata.com/u/Manju)\
**Post date:** [April 20, 2023, 2:24pm UTC](https://community.influxdata.com/t/telegraf-alias-for-multiple-agents/29564/4 "2023-04-20T14:24:47Z")

</div>

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,

---

<div class="post-metadata">

**Author:** ![Hipska](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/hipska/32/3877_2.png) [@Hipska](https://community.influxdata.com/u/Hipska)\
**Post date:** [April 20, 2023, 2:36pm UTC](https://community.influxdata.com/t/telegraf-alias-for-multiple-agents/29564/5 "2023-04-20T14:36:28Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Manju](https://avatars.discourse-cdn.com/v4/letter/m/ecd19e/32.png) [@Manju](https://community.influxdata.com/u/Manju)\
**Post date:** [April 20, 2023, 2:43pm UTC](https://community.influxdata.com/t/telegraf-alias-for-multiple-agents/29564/6 "2023-04-20T14:43:44Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![jpowers](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/jpowers/32/8569_2.png) [@jpowers](https://community.influxdata.com/u/jpowers)\
**Post date:** [April 20, 2023, 2:58pm UTC](https://community.influxdata.com/t/telegraf-alias-for-multiple-agents/29564/7 "2023-04-20T14:58:39Z")

</div>

> [@Manju](#):
>
> 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:

```toml
[[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.

---

<div class="post-metadata">

**Author:** ![Manju](https://avatars.discourse-cdn.com/v4/letter/m/ecd19e/32.png) [@Manju](https://community.influxdata.com/u/Manju)\
**Post date:** [April 20, 2023, 5:29pm UTC](https://community.influxdata.com/t/telegraf-alias-for-multiple-agents/29564/8 "2023-04-20T17:29:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Manju](https://avatars.discourse-cdn.com/v4/letter/m/ecd19e/32.png) [@Manju](https://community.influxdata.com/u/Manju)\
**Post date:** [April 21, 2023, 9:24am UTC](https://community.influxdata.com/t/telegraf-alias-for-multiple-agents/29564/9 "2023-04-21T09:24:03Z")

</div>

@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

---

<div class="post-metadata">

**Author:** ![Hipska](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/hipska/32/3877_2.png) [@Hipska](https://community.influxdata.com/u/Hipska)\
**Post date:** [April 21, 2023, 9:36am UTC](https://community.influxdata.com/t/telegraf-alias-for-multiple-agents/29564/10 "2023-04-21T09:36:53Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![Manju](https://avatars.discourse-cdn.com/v4/letter/m/ecd19e/32.png) [@Manju](https://community.influxdata.com/u/Manju)\
**Post date:** [April 21, 2023, 10:02am UTC](https://community.influxdata.com/t/telegraf-alias-for-multiple-agents/29564/11 "2023-04-21T10:02:13Z")

</div>

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

```auto
[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"

```

```auto
[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

```

```auto
  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"]
```

---

<div class="post-metadata">

**Author:** ![Hipska](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/hipska/32/3877_2.png) [@Hipska](https://community.influxdata.com/u/Hipska)\
**Post date:** [April 21, 2023, 10:21am UTC](https://community.influxdata.com/t/telegraf-alias-for-multiple-agents/29564/12 "2023-04-21T10:21:45Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![Manju](https://avatars.discourse-cdn.com/v4/letter/m/ecd19e/32.png) [@Manju](https://community.influxdata.com/u/Manju)\
**Post date:** [April 21, 2023, 12:04pm UTC](https://community.influxdata.com/t/telegraf-alias-for-multiple-agents/29564/13 "2023-04-21T12:04:18Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Hipska](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/hipska/32/3877_2.png) [@Hipska](https://community.influxdata.com/u/Hipska)\
**Post date:** [April 21, 2023, 12:17pm UTC](https://community.influxdata.com/t/telegraf-alias-for-multiple-agents/29564/14 "2023-04-21T12:17:46Z")

</div>

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…

---

<div class="post-metadata">

**Author:** ![Manju](https://avatars.discourse-cdn.com/v4/letter/m/ecd19e/32.png) [@Manju](https://community.influxdata.com/u/Manju)\
**Post date:** [April 21, 2023, 12:34pm UTC](https://community.influxdata.com/t/telegraf-alias-for-multiple-agents/29564/15 "2023-04-21T12:34:01Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Hipska](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/hipska/32/3877_2.png) [@Hipska](https://community.influxdata.com/u/Hipska)\
**Post date:** [July 31, 2023, 1:27pm UTC](https://community.influxdata.com/t/telegraf-alias-for-multiple-agents/29564/16 "2023-07-31T13:27:26Z")

</div>

Correct.

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