Configuration specified the fields ["topic"], but they were not used

Hi i’m new to the telegraf and influxdb v2 (cloud). i have a problem regarding my configuration went i try to run it it said plugin inputs.mqtt_consumer: line 38: configuration specified the fields [“topic”], but they were not used. This is either a typo or this config option does not exist in this version.
what does the specified the field:[“topic”] mean, is there a incorrect placement went im configure the file?
here is my complete configuration file (with my personal data ):
[agent]
interval = “20s”
round_interval = true
metric_batch_size = 1000
metric_buffer_limit = 10000
collection_jitter = “5s”
flush_interval = “10s”
flush_jitter = “5s”
precision = “1ms”
debug = false
quiet = true
logtarget = “file”
logfile = “telegraflog”
logfile_rotation_interval = “1d”
logfile_rotation_max_size = “0”
logfile_rotation_max_archives = -1
log_with_timezone = “Asia/Jakarta”
hostname = “”
omit_hostname = false
[[outputs.influxdb_v2]]
urls =[“”]
token = “”
organization = “”
bucket = “”

bucket_tag = “”

exclude_bucket_tag = false
timeout = “600s”

http_headers = {“X-Special-Header” = “Special-Value”}

http_proxy = “http://corporate.proxy:3128

user_agent = “telegraf”

content_encoding = “gzip”

influx_uint_support = false

tls_ca = “/etc/telegraf/ca.pem”

tls_cert = “/etc/telegraf/cert.pem”

tls_key = “/etc/telegraf/key.pem”

insecure_skip_verify = false

[[inputs.mqtt_consumer]]

example: servers = [“tcp://localhost:1883”]

servers = [“ssl://localhost:1883”]

servers = [“ws://localhost:1883”]

servers = []
topics = [
sensor/lokasi/#, ]
topic_tag = “”
qos = 1
connection_timeout = “600s”
max_undelivered_messages = 1000
persistent_session = true

client_id = “”

username = “”
password = “<redacted”

tls_ca = “/etc/telegraf/ca.pem”

tls_cert = “/etc/telegraf/cert.pem”

tls_key = “/etc/telegraf/key.pem”

insecure_skip_verify = false

data_format = “influx”
influx_parser_type = “internal”
influx_timestamp_precision = “1ns”
[[inputs.mqtt_consumer.topic_parsing]]
topic = “sensor/lokasi/#”
measurement = “Hasil_Data”
tags = “lokasi”
fields = “CO2_ppm”
[[inputs.mqtt_consumer.topic.types]]
key = “CO2_ppm”
data_type = “float”

Hi,

It is really helpful to put your config between triple backticks ``` like so it renders it as text and not markdown to make it a bit easier to view.

[[inputs.mqtt_consumer.topic.types]]

This should not be an array of dictionaries, but a dictionary, you need to remove the extra brackets:

[inputs.mqtt_consumer.topic.types]

ah thats why, and sorry for bad renders this is my first time asking about this kinda thing thx you for the advice

1 Like

after i change into what you told me the error its stil the same.
here the configure you told me to change:

``` topic = "sensor/lokasi/#"
``` measurement = "Hasil_Data"
``` tags = "lokasi"
``` fields = "CO2_ppm"
```[inputs.mqtt_consumer.topic.types]
``` key = "CO2_ppm"
``` data_type = "float"
so i try the opposite of that by removing the extra bracket on 
```[[inputs.mqtt_consumer.topic_parsing]] 
this error happen afterward:
```error parsing mqtt_consumer, line 63: cannot unmarshal TOML table into []mqtt_consumer.TopicParsingConfig (need struct or map)
is this different problem?

So order matters with TOML, the types come after topic_parsing

Can you provide the full config + the output?

here you go
mqtt_plugin_sensor.txt (1.9 KB)
e
and this is the outuput after i start it

error parsing mqtt_consumer, line 63: cannot unmarshal TOML table into [ ]mqtt_consumer.TopicParsingConfig (need struct or map)

Ah I missed this on saturday, it isn’t topic it is topic_parsing

[inputs.mqtt_consumer.topic_parsing.types]

so based on what you provided in that file what you want is:

  [[inputs.mqtt_consumer.topic_parsing]]
    topic = "sensor/lokasi/#"
    measurement = "Hasil_Data"
    tags = "lokasi"
    fields = "CO2_ppm"

    [inputs.mqtt_consumer.topic_parsing.types]
        key = "CO2_ppm"
        data_type = "float"

I need to update the docs that is a bad typo. PR to update docs: docs(inputs.mqtt_consumer): Update topic parsing types naming by powersj · Pull Request #15301 · influxdata/telegraf · GitHub