Custom tags for inputs.socket_listener

Hi, Is there a way to create custom static tags into inputs.socket_listener?

Of course

There is a “node” to do that, which works in any plugin which is [inputs._inputname_.tags], you have to add it at the end of the input itself, below a sample

# Collect statistics about itself
[[inputs.internal]]
  ## If true, collect telegraf memory stats.
  # collect_memstats = true

  ## Custom Section with additional tag, useful in case of multiple telegraf instances on the same host
  [inputs.internal.tags]
    telegraf_instance = "default"

Thanks @Giovanni_Luisotto. I have tried this but this is not working with all input types.
For example socket_listener and elasticsearch.

Can you share a sample of those 2 inputs?
that should work on all inputs, therefore we could open an issue on Github to have it fixed.

Hi @Giovanni_Luisotto, sorry for late reply. I found a workaround but the issue still persists.

 [[inputs.socket_listener]]
   [inputs.socket_listener.tags]
     type = "dhcp"
#    role = "dhcp-collectd"
#    owner = "systems"
  service_address = "udp://192.168.101.104:25826"
  data_format = "collectd"
  collectd_auth_file = "/etc/telegraf/telegraf.d/auth_file"
  collectd_security_level = "encrypt"
  # # collectd_typesdb = ["/usr/share/collectd/types.db"]
  collectd_typesdb = ["/usr/share/collectd/types.db"]

Logs:

Jun 08 16:06:32 SN-SINTP1-A2821 telegraf[24889]: 2021-06-08T08:06:32Z E! [telegraf] Error running agent: Error loading config file /etc/telegraf/telegraf.d/dns-collecd.conf: Error parsing socket_listener, could not parse tags for input socket_listener
Jun 08 16:06:32 SN-SINTP1-A2821 systemd[1]: telegraf.service: main process exited, code=exited, status=1/FAILURE
Jun 08 16:06:32 SN-SINTP1-A2821 systemd[1]: Unit telegraf.service entered failed state.
Jun 08 16:06:32 SN-SINTP1-A2821 systemd[1]: telegraf.service failed.
Jun 08 16:06:32 SN-SINTP1-A2821 systemd[1]: telegraf.service holdoff time over, scheduling restart.
Jun 08 16:06:32 SN-SINTP1-A2821 systemd[1]: Stopped The plugin-driven server agent for reporting metrics into InfluxDB.
Jun 08 16:06:32 SN-SINTP1-A2821 systemd[1]: start request repeated too quickly for telegraf.service
Jun 08 16:06:32 SN-SINTP1-A2821 systemd[1]: Failed to start The plugin-driven server agent for reporting metrics into InfluxDB.
Jun 08 16:06:32 SN-SINTP1-A2821 systemd[1]: Unit telegraf.service entered failed state.
Jun 08 16:06:32 SN-SINTP1-A2821 systemd[1]: telegraf.service failed.

move the inputs.socket_listener.tags note at the end of the input plugin, otherwise, even the parts below will be considered as part of that node.

let me know if that solves the issue