Variable hostnames from SNMP metrics?

I am using a pre-defined telegraf.conf file for multiple Ubiquiti access points. This is defined here

The problem I am having is that these don’t show up in Chronograf under hosts. At first, I suspected this was because I had set omit_hostname = true. I did this because everything was being tagged with the name of the host where telegraf is running, not the name of the access point. However, when I set this to false, I still wasn’t getting the access points on the Chronograf hosts tab.

Is it possible to define multiple hosts (while using SNMP to query multiple targets)?

The provided configuration does get the hostname of the access point:

   #  System name (hostname)
   [[inputs.snmp.field]]
     is_tag = true
     name = "sysName"
     oid = "RFC1213-MIB::sysName.0"

It’s setting that value to sysName though. Is it as simple has changing name to hostname? Or do I need to dynamically set hostname = ???? somehow?

Yes, you can just set this to write to the host tag. The host tag is meant to indicate the system Telegraf is running on, and is used by Chronograf. We are starting to use a new standard tag called source to indicate the system that the metric describes but it’s not widespread enough to be used by Chronograf yet.

Thanks for the reply @daniel. Just to confirm I am understanding correctly, does this mean I can change my block of code to read like this?

  #  System name (hostname)
  [[inputs.snmp.field]]
    is_tag = true
    name = "host"
    oid = "RFC1213-MIB::sysName.0"

You can set name to anything you want.
But also keep in mind to inherit it the tag when querying the actual snmp fields.
This is example of mine:

[[inputs.snmp]]
   name = "TROLOLO"
[[inputs.snmp.field]]
 name = "hostname"
 oid = ".iso.org.dod.internet.mgmt.mib-2.system.sysName.0"
 is_tag = true
 [[inputs.snmp.table]]
  name = "TROLOLO"
  inherit_tags = [ "hostname" ]
  [[inputs.snmp.table.field]]
    name = "slotNo"
    is_tag = true
    oid = "1.3.6.1.4.1.3041.101.23.1.1.1"
  [[inputs.snmp.table.field]]
    name = "temperature"
    oid = "1.3.6.1.4.1.3041.101.23.1.1.2"