Telegraf mqtt msg to influxdb filter

Hi, @Jay_Clifford
Happy start. Thank you for your support! :+1: :+1: :pray:
One more question, I want to know influx v 2.0 Can a large amount of data of the Internet of things be stored for a long time?? :thinking: :thinking: :thinking:
Is it convenient to talk about the single node storage bottleneck? At what level does my data need to be distributed :thinking: :thinking: :thinking: :thinking:

Hi @loneWolf666,
No worries at all! Would you mind opening a separate ticket for this and tag me there? Sorry for this just trying to keep our threads as close to the original topics as possible.

Hi, @loneWolf666,
A strange phenomenon happened on my server :hear_no_evil:

##################### system resource telegraf  config ##################################
  ## Organization is the name of the organization you wish to write to; must exist.
  organization = "trunkport"

  ## Destination bucket to write into.
  bucket = "system_resource"

  ## 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"

  ## Content-Encoding for write request body, can be set to "gzip" to
  ## compress body or "identity" to apply no encoding.
  # content_encoding = "gzip"

  ## Enable or disable uint support for writing uints influxdb 2.0.
  # influx_uint_support = false

  ## Optional TLS Config for use on HTTP connections.
  # tls_ca = "/etc/telegraf/ca.pem"
  # tls_cert = "/etc/telegraf/cert.pem"
  # tls_key = "/etc/telegraf/key.pem"
  ## Use TLS but skip chain & host verification
  # insecure_skip_verify = false
[[inputs.cpu]]
  ## Whether to report per-cpu stats or not
  percpu = true
  ## Whether to report total system cpu stats or not
  totalcpu = true
  ## If true, collect raw CPU time metrics
  collect_cpu_time = false
  ## If true, compute and report the sum of all non-idle CPU states
  report_active = false
[[inputs.disk]]
  ## By default stats will be gathered for all mount points.
  ## Set mount_points will restrict the stats to only the specified mount points.
  # mount_points = ["/"]
  ## Ignore mount points by filesystem type.
  ignore_fs = ["tmpfs", "devtmpfs", "devfs", "iso9660", "overlay", "aufs", "squashfs"]
[[inputs.diskio]]
  ## By default, telegraf will gather stats for all devices including
  ## disk partitions.
  ## Setting devices will restrict the stats to the specified devices.
  # devices = ["sda", "sdb", "vd*"]
  ## Uncomment the following line if you need disk serial numbers.
  # skip_serial_number = false
  #
  ## On systems which support it, device metadata can be added in the form of
  ## tags.
  ## Currently only Linux is supported via udev properties. You can view
  ## available properties for a device by running:
  ## 'udevadm info -q property -n /dev/sda'
  ## Note: Most, but not all, udev properties can be accessed this way. Properties
  ## that are currently inaccessible include DEVTYPE, DEVNAME, and DEVPATH.
  # device_tags = ["ID_FS_TYPE", "ID_FS_USAGE"]
  #
  ## Using the same metadata source as device_tags, you can also customize the
  ## name of the device via templates.
  ## The 'name_templates' parameter is a list of templates to try and apply to
  ## the device. The template may contain variables in the form of '$PROPERTY' or
  ## '${PROPERTY}'. The first template which does not contain any variables not
  ## present for the device is used as the device name tag.
  ## The typical use case is for LVM volumes, to get the VG/LV name instead of
  ## the near-meaningless DM-0 name.
  # name_templates = ["$ID_FS_LABEL","$DM_VG_NAME/$DM_LV_NAME"]
[[inputs.mem]]
  # no configuration
[[inputs.net]]
  ## By default, telegraf gathers stats from any up interface (excluding loopback)
  ## Setting interfaces will tell it to gather these explicit interfaces,
  ## regardless of status.
  ##
  # interfaces = ["eth0"]
  ##
  ## On linux systems telegraf also collects protocol stats.
  ## Setting ignore_protocol_stats to true will skip reporting of protocol metrics.
  ##
  # ignore_protocol_stats = false
  ##
[[inputs.processes]]
  # no configuration
[[inputs.swap]]
  # no configuration
[[inputs.system]]
  ## Uncomment to remove deprecated metrics.
  # fielddrop = ["uptime_format"]

#################  iot monitor config.d dir telegraf ############################

  ## Destination bucket to write into.
  bucket = "vehicle_info"

  ## 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"

  ## Content-Encoding for write request body, can be set to "gzip" to
  ## compress body or "identity" to apply no encoding.
  # content_encoding = "gzip"

  ## Enable or disable uint support for writing uints influxdb 2.0.
  # influx_uint_support = false

  ## Optional TLS Config for use on HTTP connections.
  # tls_ca = "/etc/telegraf/ca.pem"
  # tls_cert = "/etc/telegraf/cert.pem"
  # tls_key = "/etc/telegraf/key.pem"
  ## Use TLS but skip chain & host verification
  # insecure_skip_verify = false


###############################################################################
#                            INPUT PLUGINS                                    #
###############################################################################
[[inputs.mqtt_consumer]]
  ## Broker URLs for the MQTT server or cluster.  To connect to multiple
  ## clusters or standalone servers, use a seperate plugin instance.
  ##   example: servers = ["tcp://localhost:1883"]
  ##            servers = ["ssl://localhost:1883"]
  ##            servers = ["ws://localhost:1883"]
  ## servers = ["tcp://172.29.60.10:1883"]
  servers = ["tcp://172.17.0.2:1883"]

  ## Topics that will be subscribed to.
  topics = [
    "/realtime-monitor/upload-info/+"
  ]

  ## Data format to consume.
  ## Each data format has its own unique set of configuration options, read
  ## more about them here:
  ## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md
  data_format = "json"


  name_override = "test-list-2"


###############################################################################
#                            Processor PLUGINS                                #
###############################################################################
#credit goes to @srebhan

[[processors.starlark]]
  source = '''
def apply(metric):
  fields = ["wheel_angle", "wheel_odometer"]
  for f in fields:
    key_prefix = f+"_"
    key_len = len(key_prefix)
    keys = [x for x in metric.fields.keys() if x.startswith(key_prefix)]
    keys = sorted(keys, key=lambda x: int(x[key_len:]))
    values = [str(metric.fields.pop(k)) for k in keys]
    new_value = "["+', '.join(values)+"]"
    metric.fields[f] = new_value
  return metric
'''

[[processors.printer]]

But I found information about system resources in both buckets (vehicle_info)?? :hear_no_evil:
cpu mem  .......  field  Should there only be system resource buckets :weary:
![image|690x323](upload://n6et38KPMoXbQA4qSR1vyMxY6IL.png)


There are system resource buckets ”[[processors.starlark]]“ handler field :cold_face:

Hi @loneWolf666,
not to worry what you need to do is filter those metrics out. So they are not processed through the starlark plugin or your output plugin to system resource. I have taken your config and applied an example but you will need to replace the <INSERT> with your own measurements name:

##################### system resource telegraf  config ##################################
  ## Organization is the name of the organization you wish to write to; must exist.
  organization = "trunkport"

  ## Destination bucket to write into.
  bucket = "system_resource"

  ## 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"

  ## Content-Encoding for write request body, can be set to "gzip" to
  ## compress body or "identity" to apply no encoding.
  # content_encoding = "gzip"

  ## Enable or disable uint support for writing uints influxdb 2.0.
  # influx_uint_support = false

  ## Optional TLS Config for use on HTTP connections.
  # tls_ca = "/etc/telegraf/ca.pem"
  # tls_cert = "/etc/telegraf/cert.pem"
  # tls_key = "/etc/telegraf/key.pem"
  ## Use TLS but skip chain & host verification
  # insecure_skip_verify = false
[[inputs.cpu]]
  ## Whether to report per-cpu stats or not
  percpu = true
  ## Whether to report total system cpu stats or not
  totalcpu = true
  ## If true, collect raw CPU time metrics
  collect_cpu_time = false
  ## If true, compute and report the sum of all non-idle CPU states
  report_active = false
[[inputs.disk]]
  ## By default stats will be gathered for all mount points.
  ## Set mount_points will restrict the stats to only the specified mount points.
  # mount_points = ["/"]
  ## Ignore mount points by filesystem type.
  ignore_fs = ["tmpfs", "devtmpfs", "devfs", "iso9660", "overlay", "aufs", "squashfs"]
[[inputs.diskio]]
  ## By default, telegraf will gather stats for all devices including
  ## disk partitions.
  ## Setting devices will restrict the stats to the specified devices.
  # devices = ["sda", "sdb", "vd*"]
  ## Uncomment the following line if you need disk serial numbers.
  # skip_serial_number = false
  #
  ## On systems which support it, device metadata can be added in the form of
  ## tags.
  ## Currently only Linux is supported via udev properties. You can view
  ## available properties for a device by running:
  ## 'udevadm info -q property -n /dev/sda'
  ## Note: Most, but not all, udev properties can be accessed this way. Properties
  ## that are currently inaccessible include DEVTYPE, DEVNAME, and DEVPATH.
  # device_tags = ["ID_FS_TYPE", "ID_FS_USAGE"]
  #
  ## Using the same metadata source as device_tags, you can also customize the
  ## name of the device via templates.
  ## The 'name_templates' parameter is a list of templates to try and apply to
  ## the device. The template may contain variables in the form of '$PROPERTY' or
  ## '${PROPERTY}'. The first template which does not contain any variables not
  ## present for the device is used as the device name tag.
  ## The typical use case is for LVM volumes, to get the VG/LV name instead of
  ## the near-meaningless DM-0 name.
  # name_templates = ["$ID_FS_LABEL","$DM_VG_NAME/$DM_LV_NAME"]
[[inputs.mem]]
  # no configuration
[[inputs.net]]
  ## By default, telegraf gathers stats from any up interface (excluding loopback)
  ## Setting interfaces will tell it to gather these explicit interfaces,
  ## regardless of status.
  ##
  # interfaces = ["eth0"]
  ##
  ## On linux systems telegraf also collects protocol stats.
  ## Setting ignore_protocol_stats to true will skip reporting of protocol metrics.
  ##
  # ignore_protocol_stats = false
  ##
[[inputs.processes]]
  # no configuration
[[inputs.swap]]
  # no configuration
[[inputs.system]]
  ## Uncomment to remove deprecated metrics.
  # fielddrop = ["uptime_format"]

#################  iot monitor config.d dir telegraf ############################

  ## Destination bucket to write into.
  bucket = "vehicle_info"

  ## 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"

  ## Content-Encoding for write request body, can be set to "gzip" to
  ## compress body or "identity" to apply no encoding.
  # content_encoding = "gzip"

  ## Enable or disable uint support for writing uints influxdb 2.0.
  # influx_uint_support = false

  ## Optional TLS Config for use on HTTP connections.
  # tls_ca = "/etc/telegraf/ca.pem"
  # tls_cert = "/etc/telegraf/cert.pem"
  # tls_key = "/etc/telegraf/key.pem"
  ## Use TLS but skip chain & host verification
  # insecure_skip_verify = false


###############################################################################
#                            INPUT PLUGINS                                    #
###############################################################################
[[inputs.mqtt_consumer]]
  ## Broker URLs for the MQTT server or cluster.  To connect to multiple
  ## clusters or standalone servers, use a seperate plugin instance.
  ##   example: servers = ["tcp://localhost:1883"]
  ##            servers = ["ssl://localhost:1883"]
  ##            servers = ["ws://localhost:1883"]
  ## servers = ["tcp://172.29.60.10:1883"]
  servers = ["tcp://172.17.0.2:1883"]

  ## Topics that will be subscribed to.
  topics = [
    "/realtime-monitor/upload-info/+"
  ]

  ## Data format to consume.
  ## Each data format has its own unique set of configuration options, read
  ## more about them here:
  ## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md
  data_format = "json"


  name_override = "test-list-2"


###############################################################################
#                            Processor PLUGINS                                #
###############################################################################
#credit goes to @srebhan

[[processors.starlark]]

namepass = ["test-list-2"]
  source = '''
def apply(metric):
  fields = ["wheel_angle", "wheel_odometer"]
  for f in fields:
    key_prefix = f+"_"
    key_len = len(key_prefix)
    keys = [x for x in metric.fields.keys() if x.startswith(key_prefix)]
    keys = sorted(keys, key=lambda x: int(x[key_len:]))
    values = [str(metric.fields.pop(k)) for k in keys]
    new_value = "["+', '.join(values)+"]"
    metric.fields[f] = new_value
  return metric
'''

I added the namepass feature to your starlark plugin. I could not find your InfluxDB output plugin. You will also want to add a namedrop. To your influxDB output plugin which is writing to your system bucket. Here is any example:

[[outputs.influxdb_v2]]
namedrop = ["test-list-2"]

alias = "k8-2"
  urls = ["${INFLUX_HOST}"]
  token = "${INFLUX_TOKEN}"
  organization = "${INFLUX_ORG}"
  bucket = "bucket2"

This will drop any metrics with the measurement name

cool topic your working on BTW

Hi, @Jay_Clifford
Thank you for your support!
Because my production environment decides to update conveniently, different mqtt topics use different telegraf configurations and put them in the telegraf. d directory and the data monitored by different topics and telegraf configurations enter different influxdb bucketsfor easy updating
I wonder if this plan can be realized? The problem with my local debugging is that I only sent a message to an mqtt topic, All telegraf conf received messages, causing all the data of the influx to be stored in buckets,It looks like mqtt topic topic matching mechanism fails :hear_no_evil:

image

image

image

Hi, @Jay_Clifford
I added the configuration you prompted
namedrop = [“vehicle_info”, “system”]
name_override = “vehicle_info”
namepass = [“vehicle_info”]

but telegraf parser config error

############################# config ###############################
  2021-12-08T09:29:11Z I! Starting Telegraf 1.20.4
2021-12-08T09:29:11Z E! [telegraf] Error running agent: Error loading config file /etc/telegraf/telegraf.conf: Error parsing data: line 79: key `namedrop' is in conflict with line 4ed
2021-12-08T09:29:26Z I! Starting Telegraf 1.20.4
2021-12-08T09:29:26Z E! [telegraf] Error running agent: Error loading config file /etc/telegraf/telegraf.conf: Error parsing data: line 79: key `namedrop' is in conflict with line 4ed
2021-12-08T09:29:54Z I! Starting Telegraf 1.20.4
2021-12-08T09:29:54Z E! [telegraf] Error running agent: Error loading config file /etc/telegraf/telegraf.conf: Error parsing data: line 79: key `namedrop' is in conflict with line 4ed
2021-12-08T09:30:05Z I! Starting Telegraf 1.20.4
2021-12-08T09:30:05Z E! [telegraf] Error running agent: Error loading config file /etc/telegraf/telegraf.d/vehicle_info.conf: Error parsing data: line 79: key `namedrop' is in conflict with line 4ed
#################### Error reporting can only be seen to resolve conflicts #####################

########################### telegraf.conf ##################################
# Configuration for telegraf agent
[agent]
  interval = "10s"

  round_interval = true

  metric_batch_size = 1000

  metric_buffer_limit = 10000

  collection_jitter = "0s"

  flush_interval = "10s"

  flush_jitter = "0s"

  precision = ""
  hostname = ""

  omit_hostname = false
[[outputs.influxdb_v2]]
  namedrop = ["vehicle_info", "vehicle_state"]

  urls = ["http://192.168.16.2:8086"]

  ## Token for authentication.
  token = "jovyuwtCCN59l2X3LA8Qz35A2em6wrlihj2E2P_meF0qN-UEWwcOEq4ZRmTU7ZVMCD-IL7_YvAwTdsasW-OocQ=="

  ## Organization is the name of the organization you wish to write to; must exist.
  organization = "trunkport"

  ## Destination bucket to write into.
  bucket = "system_resource"


  # bucket_tag = ""

  # exclude_bucket_tag = false

  ## Timeout for HTTP messages.
  # timeout = "5s"


[[inputs.cpu]]
  ## Whether to report per-cpu stats or not
  percpu = true
  ## Whether to report total system cpu stats or not
  totalcpu = true
  ## If true, collect raw CPU time metrics
  collect_cpu_time = false
  ## If true, compute and report the sum of all non-idle CPU states
  report_active = false
[[inputs.disk]]
  ## By default stats will be gathered for all mount points.
  ## Set mount_points will restrict the stats to only the specified mount points.
  # mount_points = ["/"]
  ## Ignore mount points by filesystem type.
  ignore_fs = ["tmpfs", "devtmpfs", "devfs", "iso9660", "overlay", "aufs", "squashfs"]
[[inputs.diskio]]
  ## By default, telegraf will gather stats for all devices including
  ## disk partitions.
  ## Setting devices will restrict the stats to the specified devices.
  # devices = ["sda", "sdb", "vd*"]
  ## Uncomment the following line if you need disk serial numbers.
  # skip_serial_number = false
  #
  ## On systems which support it, device metadata can be added in the form of
  ## tags.
  ## Currently only Linux is supported via udev properties. You can view
  ## available properties for a device by running:
  ## 'udevadm info -q property -n /dev/sda'
  ## Note: Most, but not all, udev properties can be accessed this way. Properties
  ## that are currently inaccessible include DEVTYPE, DEVNAME, and DEVPATH.
  # device_tags = ["ID_FS_TYPE", "ID_FS_USAGE"]
  #
  ## Using the same metadata source as device_tags, you can also customize the
  ## name of the device via templates.
  ## The 'name_templates' parameter is a list of templates to try and apply to
  ## the device. The template may contain variables in the form of '$PROPERTY' or
  ## '${PROPERTY}'. The first template which does not contain any variables not
  ## present for the device is used as the device name tag.
  ## The typical use case is for LVM volumes, to get the VG/LV name instead of
  ## the near-meaningless DM-0 name.
  # name_templates = ["$ID_FS_LABEL","$DM_VG_NAME/$DM_LV_NAME"]
[[inputs.mem]]
  # no configuration
[[inputs.net]]
  ## By default, telegraf gathers stats from any up interface (excluding loopback)
  ## Setting interfaces will tell it to gather these explicit interfaces,
  ## regardless of status.
  ##
  # interfaces = ["eth0"]
  ##
  ## On linux systems telegraf also collects protocol stats.
  ## Setting ignore_protocol_stats to true will skip reporting of protocol metrics.
  ##
  # ignore_protocol_stats = false
  ##
[[inputs.processes]]
  # no configuration
[[inputs.swap]]
  # no configuration
[[inputs.system]]
  ## Uncomment to remove deprecated metrics.
  # fielddrop = ["uptime_format"]


  [[processors.printer]]

  [[processors.starlark]]
namepass = ["vehicle_state"]

############## telegraf.d  / telegraf_info.conf ##################################

# Configuration for telegraf agent
[agent]
  interval = "10s"
  round_interval = true


  metric_batch_size = 1


  metric_buffer_limit = 10000


  collection_jitter = "0s"


  flush_jitter = "10s"


  precision = ""

  ## Log at debug level.
  debug = true



  ## Override default hostname, if empty use os.Hostname()
  hostname = ""
  ## If set to true, do no set the "host" tag in the telegraf agent.
  omit_hostname = false

[[outputs.influxdb_v2]]
  namedrop = ["vehicle_state", "system"]

  urls = ["http://192.168.16.2:8086"]

  ## Token for authentication.
  token = "jovyuwtCCN59l2X3LA8Qz35A2em6wrlihj2E2P_meF0qN-UEWwcOEq4ZRmTU7ZVMCD-IL7_YvAwTdsasW-OocQ=="

  ## Organization is the name of the organization you wish to write to; must exist.
  organization = "trunkport"

  ## Destination bucket to write into.
  bucket = "art_monitor"



[[inputs.mqtt_consumer]]

  servers = ["tcp://172.17.0.2:1883"]

  ## Topics that will be subscribed to.
  topics = [
    "/realtime-monitor/vehicle-info/+"
  ]



  data_format = "json"

  tag_keys = ["name"]

  [[inputs.exec]]
    ## Commands array
    commands = []

    ## measurement name suffix (for separating different commands)

    name_suffix = "json"


    json_strict = false

    json_string_fields = ["name"]

    name_override = "vehicle_info"


  [[processors.printer]]

  [[processors.starlark]]
namepass = ["vehicle_state"]

###################### telegraf.d/telegraf.conf ################
# Configuration for telegraf agent
[agent]
  ## Default data collection interval for all inputs
  interval = "10s"

  round_interval = true


  metric_batch_size = 1


  metric_buffer_limit = 10000


  collection_jitter = "0s"

  ## Default flushing interval for all outputs. Maximum flush_interval will be
  ## flush_interval + flush_jitter
  flush_interval = "10s"

  flush_jitter = "10s"


  precision = ""


  hostname = ""
  ## If set to true, do no set the "host" tag in the telegraf agent.
  omit_hostname = false
[[outputs.influxdb_v2]]
namedrop = ["vehicle_info","system"]

  urls = ["http://192.168.16.2:8086"]

  ## Token for authentication.
  token = "jovyuwtCCN59l2X3LA8Qz35A2em6wrlihj2E2P_meF0qN-UEWwcOEq4ZRmTU7ZVMCD-IL7_YvAwTdsasW-OocQ=="

  ## Organization is the name of the organization you wish to write to; must exist.
  organization = "trunkport"

  ## Destination bucket to write into.
  bucket = "vehicle_info"


###############################################################################
#                            INPUT PLUGINS                                    #
###############################################################################
[[inputs.mqtt_consumer]]
  ## Broker URLs for the MQTT server or cluster.  To connect to multiple
  ## clusters or standalone servers, use a seperate plugin instance.
  ##   example: servers = ["tcp://localhost:1883"]
  ##            servers = ["ssl://localhost:1883"]
  ##            servers = ["ws://localhost:1883"]
  ## servers = ["tcp://172.29.60.10:1883"]
  servers = ["tcp://172.17.0.2:1883"]

  ## Topics that will be subscribed to.
  topics = [
    "/realtime-monitor/upload-info/+"
  ]

  ## Data format to consume.
  ## Each data format has its own unique set of configuration options, read
  ## more about them here:
  ## https://github.com/influxdata/telegraf/blob/master/docs/DATA_FORMATS_INPUT.md
  data_format = "json"


  name_override = "vehicle_state"


###############################################################################
#                            Processor PLUGINS                                #
###############################################################################
#credit goes to @srebhan

[[processors.starlark]]
namepass = ["vehicle_info"]
  source = '''
def apply(metric):
  fields = ["wheel_angle", "wheel_odometer"]
  for f in fields:
    key_prefix = f+"_"
    key_len = len(key_prefix)
    keys = [x for x in metric.fields.keys() if x.startswith(key_prefix)]
    keys = sorted(keys, key=lambda x: int(x[key_len:]))
    values = [str(metric.fields.pop(k)) for k in keys]
    new_value = "["+', '.join(values)+"]"
    metric.fields[f] = new_value
  return metric
'''

[[processors.printer]]

Hi @loneWolf666,
What is the parse error and which line?

Perhaps its because you have specified your agent config settings twice?

[[outputs.influxdb_v2]]
namedrop = [“vehicle_info”, “vehicle_state”]

I have three telegraf configurations, and name “name override” is performed on each mqtt data,
Two other configurations, name override, are excluded from each configuration

I do not see an issue with this line. It is the correct notation. Here is one of my examples which use name override plus routing:

# Telegraf Configuration
#
# Telegraf is entirely plugin driven. All metrics are gathered from the
# declared inputs, and sent to the declared outputs.
#
# Plugins must be declared in here to be active.
# To deactivate a plugin, comment out the name and any variables.
#
# Use 'telegraf -config telegraf.conf -test' to see what metrics a config
# file would generate.
#
# Environment variables can be used anywhere in this config file, simply surround
# them with ${}. For strings the variable must be within quotes (ie, "${STR_VAR}"),
# for numbers and booleans they should be plain (ie, ${INT_VAR}, ${BOOL_VAR})


# Global tags can be specified here in key="value" format.
[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"


# Configuration for telegraf agent
[agent]
  ## Default data collection interval for all inputs
  interval = "5s"
  ## Rounds collection interval to 'interval'
  ## ie, if interval="10s" then always collect on :00, :10, :20, etc.
  round_interval = true

  ## Telegraf will send metrics to outputs in batches of at most
  ## metric_batch_size metrics.
  ## This controls the size of writes that Telegraf sends to output plugins.
  metric_batch_size = 1000

  ## Maximum number of unwritten metrics per output.  Increasing this value
  ## allows for longer periods of output downtime without dropping metrics at the
  ## cost of higher maximum memory usage.
  metric_buffer_limit = 10000

  ## Collection jitter is used to jitter the collection by a random amount.
  ## Each plugin will sleep for a random time within jitter before collecting.
  ## This can be used to avoid many plugins querying things like sysfs at the
  ## same time, which can have a measurable effect on the system.
  collection_jitter = "5s"

  ## Default flushing interval for all outputs. Maximum flush_interval will be
  ## flush_interval + flush_jitter
  flush_interval = "10s"
  ## Jitter the flush interval by a random amount. This is primarily to avoid
  ## large write spikes for users running a large number of telegraf instances.
  ## ie, a jitter of 5s and interval 10s means flushes will happen every 10-15s
  flush_jitter = "5s"

  ## By default or when set to "0s", precision will be set to the same
  ## timestamp order as the collection interval, with the maximum being 1s.
  ##   ie, when interval = "10s", precision will be "1s"
  ##       when interval = "250ms", precision will be "1ms"
  ## Precision will NOT be used for service inputs. It is up to each individual
  ## service input to set the timestamp at the appropriate precision.
  ## Valid time units are "ns", "us" (or "µs"), "ms", "s".
  precision = ""


  ## Override default hostname, if empty use os.Hostname()
  hostname = ""
  ## If set to true, do no set the "host" tag in the telegraf agent.
  omit_hostname = false

  debug = true

  quiet = false


###############################################################################
#                            OUTPUT PLUGINS                                   #
###############################################################################

[[outputs.influxdb_v2]]
namepass = ["test"]

alias = "k8"
  urls = ["${INFLUX_HOST}"]
  token = "${INFLUX_TOKEN}"
  organization = "${INFLUX_ORG}"
  bucket = "bucket1"

[[outputs.influxdb_v2]]
namedrop = ["test"]

alias = "k8-2"
  urls = ["${INFLUX_HOST}"]
  token = "${INFLUX_TOKEN}"
  organization = "${INFLUX_ORG}"
  bucket = "bucket2"

###############################################################################
#                            INPUT PLUGINS                                    #
###############################################################################
[[inputs.file]]
    alias = "file-1"
  files = ["./data/sample.json"]
  data_format = "json"
  tag_keys = ["Driver", "Channel", "Trace", "Notes", "Address", "Instrument"]

  name_override = "test"

[[inputs.file]]
    alias = "file-2"
  files = ["./data/sample.json"]
  data_format = "json"
  tag_keys = ["Driver", "Channel", "Trace", "Notes", "Address", "Instrument"]

  name_override = "test2"

  [[inputs.file]]
    alias = "file-3"
  files = ["./data/sample.json"]
  data_format = "json"
  tag_keys = ["Driver", "Channel", "Trace", "Notes", "Address", "Instrument"]

  name_override = "test3"

I checked your config again and this should not be there. Or maybe a copy-paste error. As there is no starlark function