Error in plugin: invalid character 'c' looking for beginning of value

hello people, i get “Error in plugin: invalid character ‘c’ looking for beginning of value” while lunching my telegraf config, i’m new + clueless

additional data:

X-Influxdb-Build: OSS
X-Influxdb-Version: v2.7.10
Telegraf 1.32.0

terminal output:

inputs.mqtt_consumer] Connected [tcp://*****:1883]
2024-10-11T23:24:43Z W! [inputs.mqtt_consumer] No metrics were created from a message. Verify your parser settings. This message is only printed once.2024-10-11T23:24:43Z E! [inputs.mqtt_consumer] Error in plugin: invalid character ‘c’ looking for beginning of value

.
my mqtt json published data:

msg send {“msg”:“Hello”,“device_id”:1234567890,“inputA”:328,“inputB”:1176,“inputC”:663,“inputD”:100,“inputE”:24,“inputF”:-40,“inputG”:1,“inputH”:-5,“protocol”:“tcp”,“date”:“2024-10-12 01:15:42”}

my config json output in --test:

> test,device_id=1234567890,topic=test inputA=3.28,inputB=11.76,inputC=6.63,inputD=1,inputE=0.24,inputF=-0.4,inputG=0.01,inputH=-0.05 1728688592706516650

my config:
in other topic

[agent]
  interval = "10s"
  round_interval = true
  metric_batch_size = 2500 #1000
  metric_buffer_limit = 100000 #10000
  collection_jitter = "0s"
  flush_interval = "10s"
  flush_jitter = "0s"
  precision = ""
  hostname = ""
  omit_hostname = true
 
[[inputs.mqtt_consumer]]
  servers = ["tcp://****:1883"]
  topics = ["emqx/#"]
  username = "****"
  password = "****"
  client_id = "*****"
  data_format = "json"
  tag_keys = ["device_id"]
  qos = 0
[[processors.regex]]
  [[processors.regex.tags]]
    key = "topic"
    pattern = "^emqx/(.*)$"
    replacement = "${1}"
[[processors.converter]]
  [processors.converter.fields]
    float = ["inputA", "inputB", "inputC", "inputD", "inputE", "inputF", "inputG", "inputH"]
[[processors.starlark]]
  source = '''
def apply(metric):
    for field in ["inputA", "inputB", "inputC", "inputD", "inputE", "inputF", "inputG", "inputH"]:
        if field in metric.fields:
            metric.fields[field] = float(metric.fields[field]) / 100  # Remove this line to keep original values
    metric.name = metric.tags["topic"]
    return metric
'''
[[outputs.influxdb_v2]]
  urls = ["http://*******:8086"]
  token = "*****"
  organization = "****"
  bucket = "test"
  timeout = "5s"

@alireza_j,
Is it able to write most points?
The published data might have small inconsistencies with valid JSON format, such as unescaped characters or missing quotes and that could be causing that. I’d review the actual message payload being received by Telegraf. It might help to subscribe directly to the MQTT topic using a client like mosquitto_sub or a similar tool to see exactly what is being sent.

mosquitto_sub -h <MQTT_BROKER> -t "emqx/#" -v

And cross compare with the time of error.

@srebhan does anything jump out to you here? Thank you for your help!

1 Like

No nothing particular but usually these type of errors come from non-JSON payloads trying to be parsed as JSON…

1 Like

i’m not sure what was the problem, but as i did test it on actual device (esp32 that would pub)
problem got fixed :face_with_head_bandage:

1 Like