i’m new to community so if i’ve i done any beginner move, pardon me here
about the problem:
i have set up mosquitto, influxdb and telegraf on my vps
while running my telegraf, i get the:
Error in plugin: invalid character “‘c’” looking for beginning of value
here’s all info that might help:
mqtt publisher data example:
msg send {“msg”:“Hello”,“device_id”:1234567890,“inputA”:148,“inputB”:-2167,“inputC”:818,“inputD”:488,“inputE”:46,“inputF”:179,“inputG”:1,“inputH”:1,“protocol”:“tcp”,“date”:“2024-10-12 13:41:28”}
telegraf output (used --test):
test,device_id=1234567890,topic=test inputA=1.48,inputB=-21.67,inputC=8.18,inputD=4.88,inputE=0.46,inputF=1.79,inputG=0.01,inputH=0.01 1728733410993721776
terminal output while i ran my telegraf.conf:
telegraf --config http://*****:8086/api/v2/telegrafs/0dc94d65ced94000 -debug
2024-10-12T11:44:28Z I! Loading config: http://*****:8086/api/v2/telegrafs/0dc94d65ced94000
2024-10-12T11:44:28Z I! Starting Telegraf 1.32.0 brought to you by InfluxData the makers of InfluxDB
2024-10-12T11:44:28Z I! Available plugins: 235 inputs, 9 aggregators, 32 processors, 26 parsers, 62 outputs, 6 secret-stores
2024-10-12T11:44:28Z I! Loaded inputs: mqtt_consumer
2024-10-12T11:44:28Z I! Loaded aggregators:
2024-10-12T11:44:28Z I! Loaded processors: converter regex starlark
2024-10-12T11:44:28Z I! Loaded secretstores:
2024-10-12T11:44:28Z I! Loaded outputs: influxdb_v2
2024-10-12T11:44:28Z I! Tags enabled:
2024-10-12T11:44:28Z I! [agent] Config: Interval:10s, Quiet:false, Hostname:"", Flush Interval:10s
2024-10-12T11:44:28Z D! [agent] Initializing plugins
2024-10-12T11:44:28Z I! [processors.regex] tags: Using explicit mode...
2024-10-12T11:44:28Z I! [processors.regex] tags: Using explicit mode...
2024-10-12T11:44:28Z D! [agent] Connecting outputs
2024-10-12T11:44:28Z D! [agent] Attempting connection to [outputs.influxdb_v2]
2024-10-12T11:44:28Z D! [agent] Successfully connected to outputs.influxdb_v2
2024-10-12T11:44:28Z D! [agent] Starting service inputs
2024-10-12T11:44:28Z I! [inputs.mqtt_consumer] Connected [tcp://*****:1883]
2024-10-12T11:44:28Z W! [inputs.mqtt_consumer] No metrics were created from a message. Verify your parser settings. This message is only printed once.
2024-10-12T11:44:28Z E! [inputs.mqtt_consumer] Error in plugin: invalid character 'c' looking for beginning of value
2024-10-12T11:44:30Z E! [inputs.mqtt_consumer] Error in plugin: connection lost: EOF
2024-10-12T11:44:30Z D! [inputs.mqtt_consumer] Disconnected [tcp://*****:1883]
my telegraf.conf:
[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 = "$INFLUX_TOKEN"
organization = "hivagroup"
bucket = "test"
timeout = "5s"
additional data:
X-Influxdb-Build: OSS
X-Influxdb-Version: v2.7.10
Telegraf 1.32.0
Ubuntu VERSION=“20.04.6 LTS (Focal Fossa)”
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME=“Ubuntu 20.04.6 LTS”
VERSION_ID=“20.04”
if you’re questioning why i want such structure:
the format i’m looking for
as i understand, it seems problem is with telegraf and the way it’s parsing data, but… no clue what to do so