[[socket_listener]] and [[processors.lookup]] - Tags and Values Not Inserted

Please help, using [[inputs.socket_listener]] and [[processors.lookup]] the expected items did not get inserted tags and values form lookup table file.

  • Only guess I have is the separator in the sockets_listener being different? Since coming from Graphite, I put a “_” in there. Does processors.lookup see it as “.” before the separator is replaced.
[global_tags]
[agent]
  interval = "10s"
  round_interval = true
  metric_batch_size = 1000
  metric_buffer_limit = 10000
  collection_jitter = "0s"
  flush_interval = "10s"
  flush_jitter = "0s"
  precision = "0s"
  debug = true
  logtarget = "file"
  logfile = "C://Users//myuser//telegrafdebug.txt"
  logfile_rotation_max_size = "5MB"
  logfile_rotation_max_archives = 5
  hostname = ""
  omit_hostname = false
[[outputs.file]]
  files = ["stdout"]
[[inputs.socket_listener]]
  service_address = "udp://0.0.0.0:2012"
  data_format = "graphite"
  separator = "_"
  templates = [
     "my.site.*.* measurement.measurement.eqsitesite.field",
     "my.site.*.*.* measurement.measurement.eqsitesite.field*",
     "my.site.*.*.*.*.max measurement.measurement.eqsitesite.site.field*",
     # For health
     "my.site.health.* measurement.measurement.field.site",
   ]
[[processors.lookup]]
  files = ["C://Program Files//telegraf//telegraf.d//lut.json"]
  format = "csv_key_values"
  key = '{{.Tag "site"}}'

Lookup File
lut.json

-,sitename,latitude,longitude
my_site-1,Temp,0.0000,-0.0000
my_site-2,UseThisSiteName,00.7830,-00.3672

stdout.txt

my_site,host=GNSSCUA02,site=2,xrcsite=12 connected_groups_max=4 1702521267000000000
my_site,host=GNSSCUA02,site=2,xrcsite=12 connected_units_max=5 1702522584000000000

debuglog.txt

2023-12-14T03:33:47Z I! Starting Telegraf 1.28.5 brought to you by InfluxData the makers of InfluxDB
2023-12-14T03:33:47Z I! Available plugins: 240 inputs, 9 aggregators, 29 processors, 24 parsers, 59 outputs, 5 secret-stores
2023-12-14T03:33:47Z I! Loaded inputs: cpu disk diskio mem socket_listener swap system
2023-12-14T03:33:47Z I! Loaded aggregators: 
2023-12-14T03:33:47Z I! Loaded processors: lookup
2023-12-14T03:33:47Z I! Loaded secretstores: 
2023-12-14T03:33:47Z I! Loaded outputs: file influxdb
2023-12-14T03:33:47Z I! Tags enabled: host=GNSSCUA02
2023-12-14T03:33:47Z I! [agent] Config: Interval:10s, Quiet:false, Hostname:"GNSSCUA02", Flush Interval:10s
2023-12-14T03:33:47Z D! [agent] Initializing plugins
2023-12-14T03:33:47Z D! [agent] Connecting outputs
2023-12-14T03:33:47Z D! [agent] Attempting connection to [outputs.influxdb]
2023-12-14T03:33:47Z D! [agent] Successfully connected to outputs.influxdb
2023-12-14T03:33:47Z D! [agent] Attempting connection to [outputs.file]
2023-12-14T03:33:47Z D! [agent] Successfully connected to outputs.file
2023-12-14T03:33:47Z D! [agent] Starting service inputs
2023-12-14T03:33:47Z I! [inputs.socket_listener] Listening on udp://[::]:2012
2023-12-14T03:33:57Z D! [outputs.file] Wrote batch of 9 metrics in 2.3082ms
2023-12-14T03:33:57Z D! [outputs.file] Buffer fullness: 0 / 10000 metrics
2023-12-14T03:33:57Z D! [outputs.influxdb] Wrote batch of 9 metrics in 75.3582ms
2023-12-14T03:33:57Z D! [outputs.influxdb] Buffer fullness: 0 / 10000 metrics
2023-12-14T03:34:07Z D! [outputs.influxdb] Wrote batch of 14 metrics in 4.6123ms
2023-12-14T03:34:07Z D! [outputs.influxdb] Buffer fullness: 0 / 10000 metrics

Did you mean to set

[[processors.lookup]]
  files = ["C://Program Files//telegraf//telegraf.d//lut.json"]
  format = "csv_key_values"
  key = '{{.Name}}-{{.Tag "site"}}'

Because now you only use the site tag which makes up the key to be 2 in both of your example metrics…

1 Like

That was it, at first I didn’t notice you corrected this by adding : {{.Name}}-

[[processors.lookup]]
  files = ["C://Program Files//telegraf//telegraf.d//lut.json"]
  format = "csv_key_values"
  key = '{{.Name}}-{{.Tag "site"}}

Some how I got on the wrong track seeing this post using key w/o .Name.

1 Like