Hello all,
I have a working Telegraf MQTT configuration.
I have added a Shelly 3PM which passes its data via MQTT in JSON format.
With JSON in Telegraf, I am still new and do not know the syntax.
How can I include the JSON in my existing configuration?
[global_tags]
user = "${USER}"
[[outputs.influxdb_v2]]
## The URLs of the InfluxDB cluster nodes.
##
## Multiple URLs can be specified for a single cluster, only ONE of the
## urls will be written to each interval.
## urls exp: http://127.0.0.1:8086
urls = ["http://2.2.2.2:8086"]
## Token for authentication.
token = "XXXXXXX"
## Organization is the name of the organization you wish to write to; must exist.
organization = "XXXX"
## Destination bucket to write into.
bucket = "VH_Messwerte"
[[inputs.mqtt_consumer]]
#
# MQTT broker URLs to be used. The format is scheme://host:port, schema can be tcp, ssl, or ws.
servers = ["tcp://1.1.1.1:1883"]
connection_timeout = "90s"
#
# Topics to subscribe to.
topics = [
"Energie/#",
"Heizen/#",
"PV/#",
"Umwelt/#",
"shellypro3em-c8f09e87ad5c/status/em:0#",
]
#
persistent_session = true
client_id = "Telegraf_Client"
# Username and password.
username = "MQTT"
password = "password"
#
# Needed only if your payload type is string, since Telegraf does not forward data of this type by default.
# json_string_fields = ["uplink_message_frm_payload"]
#
# Define the message format.
data_format = "value"
data_type = "float"
[[outputs.file]]
files = ["stdout"]
Topic: shellypro3em-c8f09e87ad5c/status/em:0
JSON PAYLOAD:
{
"id":0,
"a_current":0.028,
"a_voltage":235.9,
"a_act_power":0.3,
"a_aprt_power":6.5,
"a_pf":1.00,
"b_current":0.215,
"b_voltage":237.6,
"b_act_power":47.2,
"b_aprt_power":51.0,
"b_pf":0.93,
"c_current":0.030,
"c_voltage":236.9,
"c_act_power":1.1,
"c_aprt_power":7.1,
"c_pf":1.00,
"n_current":null,
"total_current":0.273,
"total_act_power":48.584,
"total_aprt_power":64.683,
"user_calibrated_phase":[],
"errors": ["no_load"]
}
Thank you.