Troubleshooting
Why Telegraf json_v2 writes nothing from dotted MQTT string keys
Short answer
A buffer that stays at 0 / 10000 metrics means no point ever left the parser. Two independent faults sit in this setup, and either one alone empties the bucket: the subscription is one topic level short of the published sensor topic, and GJSON-style paths read the dots in keys such as 71.7.0 as object separators, so optional = true skips every field silently. Subscribe at the exact level, escape each dot, and keep optional off while commissioning.

On this page
Telegraf 1.36.3 connects to the MQTT broker and to InfluxDB, yet the bucket stays empty and every flush logs Buffer fullness: 0 / 10000 metrics. A buffer that never fills means no metric ever left the parser, so the fault sits upstream of the output, not in the write path. Two independent faults sit in this setup, and either one alone empties the bucket: the subscription is one topic level short of the topic the meter publishes on, and the field paths read the dots in keys such as 71.7.0 as object separators, which optional = true turns into a silent skip. Fix the topic first, then escape the dots and prove each path with optional switched off.
Where the data stops #
The request path is: meter publisher, broker at tcp://192.168.10.214:1883, the mqtt_consumer subscription, the json_v2 parser, the agent metric buffer, the influxdb_v2 output, the bucket. The debug log proves two hops: Connected [tcp://192.168.10.214:1883] and Successfully connected to outputs.influxdb_v2. TCP, credentials and the output connection are fine.
Buffer fullness counts metrics waiting to be written. A reading of zero on every flush means the output never received a metric, which leaves two candidates: the broker never delivers a message to this client, or the parser receives messages and returns no metrics. One test separates them, shown in the next section. If points were leaving the parser and vanishing between Telegraf and the bucket, the fault would be downstream instead; that is the case covered in Telegraf MQTT consumer connects but writes no data to InfluxDB.
The subscription misses the sensor level #
The meter publishes on SHRDZM/807D3A37863A/807D3A37863A/sensor. The configuration subscribes to SHRDZM/807D3A37863A/807D3A37863A. MQTT filters match level by level and never by prefix: a subscription to a parent does not receive its children. The broker delivers nothing, the plugin sits idle, and no error appears anywhere, because a filter that matches nothing is not an error on either side.
topics entry |
Matches the published topic | Note |
|---|---|---|
SHRDZM/807D3A37863A/807D3A37863A |
No | Missing the sensor level |
SHRDZM/807D3A37863A/807D3A37863A/sensor |
Yes | Exact; preferred for a single meter |
SHRDZM/+/+/sensor |
Yes | Single-level wildcards; covers several meters |
SHRDZM/807D3A37863A/# |
Yes | Also pulls in any other subtopic the device publishes |
Confirm from any host that can reach the broker before touching Telegraf: mosquitto_sub -h 192.168.10.214 -u <user> -P <pass> -t "SHRDZM/#" -v. If nothing prints within a few publish cycles, the fault is on the broker or publisher side. If the sensor topic prints, the subscription string is the first fix: set it to the exact sensor level for a single meter.
Why dotted keys skip silently #
json_v2 evaluates path as a GJSON path, where a dot descends one object level. A path of 71.7.0 asks for key 71, then 7 inside it, then 0 inside that. The payload is flat, with every key at the root, so the path resolves to nothing. The payload itself is valid JSON: the dots are legal key characters, and the mismatch is with the path syntax, not the data.
Without optional, the failure is loud: the parser errors with a message that the path doesn't exist. A reproduction with a flat file input shows both outcomes on the same valid document: a field with path = "1_1" parses, while path = "1.1" fails. The configuration sets optional = true on every field, and that flag converts the missing-path error into a silent skip. Every field is skipped, the parser emits no metric, and nothing reaches the log.
The working rule: leave optional off during commissioning so a wrong path fails loudly, and reinstate it only for keys the meter may genuinely omit.
The fix in the configuration #
- Subscribe at the exact level,
SHRDZM/807D3A37863A/807D3A37863A/sensorfor a single meter. - Escape each dot with a backslash in the path. A TOML literal string keeps the backslash as written, so
path = '71\.7\.0'is the cleanest form; inside a double-quoted string the backslash must be doubled,"71\\.7\\.0". - Add
renameto every field: the escaped path is awkward as a field name, and dotted field names force quoting in Flux queries. - Leave
optionaloff and runtelegraf --config <file> --testuntil the points print. TOML accepts only straight ASCII quotes, and the configuration text shows typographic quotes and a stray>aftertype = "int", so validate the real file with the same run. - Edit the configuration the process actually runs. The debug run loads its config from
--config http://192.168.50.133:8086/api/v2/telegrafs/0fba69b7b5211000, the configuration stored in InfluxDB, not a local file. Edits to a file on disk never reach that process: change the stored Telegraf configuration or point--configat a local file, then restart.
One security note belongs with step five: the API token sits in readable form in that configuration, and a token that has been shared outside the plant must be rotated in InfluxDB, with the replacement placed where the process reads it.
[[inputs.mqtt_consumer]]
servers = ["tcp://192.168.10.214:1883"]
topics = ["SHRDZM/807D3A37863A/807D3A37863A/sensor"]
username = "X"
password = "K"
data_format = "json_v2"
[[inputs.mqtt_consumer.json_v2]]
measurement_name = "smartmeter"
timestamp_path = "timestamp"
timestamp_format = "2006-01-02T15:04:05"
timestamp_timezone = "CET"
[[inputs.mqtt_consumer.json_v2.field]]
path = '71\.7\.0'
rename = "current_l3"
type = "float"
[[inputs.mqtt_consumer.json_v2.field]]
path = '1\.7\.0'
rename = "power_import"
type = "int"
Repeat the field block for the remaining keys. The names below follow common OBIS numbering; confirm each meaning and its unit against the meter documentation before naming fields.
| Payload key | Sample value | Type | Likely meaning |
|---|---|---|---|
32.7.0, 52.7.0, 72.7.0 |
236.10 |
float | Phase voltages |
31.7.0, 51.7.0, 71.7.0 |
2.50 |
float | Phase currents |
1.7.0, 2.7.0 |
0, 17 |
int | Instantaneous import and export power |
16.7.0 |
-17 |
int | Signed net power |
1.8.0, 2.8.0, 3.8.0, 4.8.0 |
9929432 |
int | Cumulative energy registers |
uptime |
0003:09:38:02 |
string | Not numeric; keep as string or omit |
Worked example: three dotted fields from one meter payload on Telegraf 1.36.3 #
Inputs, with where each comes from:
- Published topic
SHRDZM/807D3A37863A/807D3A37863A/sensor: 4 levels, from the broker-side subscriber. - Configured
topicsentry: 3 levels, from the configuration under test. - Payload depth: 1 level, a flat object with 16 root keys, 3 of them declared as fields (
71.7.0,51.7.0,1.7.0), from the meter's publish. - Agent settings: a flush every 10 s into a buffer sized for 10000 metrics, from the configuration.
- Observed buffer: 0 / 10000 metrics, from the debug log.
The rule: a subscription receives a message only when its filter matches the topic level for level; a GJSON path must descend one object level per dot-separated segment, and each segment must name a key at that level; optional = true turns a failed path into a skipped field instead of an error.
The arithmetic:
- Topic match: 4 published levels - 3 filter levels = 1 missing level, so messages delivered to this client = 0.
- Path depth: each declared path has 3 segments and needs 3 object levels; the payload offers 1, so 3 - 1 = 2 levels missing and keys matched per field = 0.
- Per message: 3 declared fields x 0 matches = 0 fields, so metrics per message = 0.
- Buffer: 0 messages x 0 metrics per message = 0 metrics, logged at the next flush as 0 / 10000.
The result after the fix: the 4-level filter matches and messages arrive; the escaped path 71\.7\.0 is one segment naming one root key, so each field matches once, 3 fields per message yield one metric, and the buffer leaves zero at the next flush.
Decision: with a subscriber confirming the sensor topic and the corrected configuration loaded, buffer fullness above zero within two flush intervals (20 s at these agent settings) proves the chain end to end. Still at zero after that: the paths match nothing; rerun the test with optional removed and read the first path error.
Telling the faults apart #
| Observation | Cause | Discriminator | Fix |
|---|---|---|---|
| Buffer at zero; the broker-side subscriber prints nothing for this filter | Topic filter one level short | mosquitto_sub on SHRDZM/# shows the sensor suffix |
Subscribe at the exact level |
Buffer at zero; messages arrive; --test prints nothing |
Dotted paths with optional = true |
Remove optional; the path error appears |
Escape the dots, add rename |
| Points appear but values are wrong or missing | Wrong type or string passthrough | Check the field suffixes in the --test output |
Declare type per field |
| Write rejected after a type change | The field already exists in the bucket with another type | The output logs an HTTP 422 type-conflict message | Follow Why a renamed InfluxDB field writes after a field type conflict |
Strings, types and the timestamp once data flows #
Every value in the payload is a quoted string. json_v2 converts a numeric string when the field declares type, so "236.10" becomes a float and "17" an int; with no type declared the value stays a string, which is how numbers end up in a string measurement, the case covered in Why Telegraf writes MQTT float values into the string measurement. The uptime value 0003:09:38:02 is not numeric at all: keep it as a string or omit it.
The timestamp carries no UTC offset, so timestamp_format = "2006-01-02T15:04:05" parses the meter's local time and timestamp_timezone tells Telegraf which zone that time belongs to. The configuration sets CET; keep it matched to the meter's clock, because a zone that disagrees shifts every point by the offset between the two.
Questions asked
Does the meter's publisher need to change instead of Telegraf?
There is no need to touch it. JSON permits dots in key names, so the payload is legal as published and any validator will accept it. The escaping belongs on the Telegraf side and is complete there, which matters most where the meter's output cannot be reconfigured. Leave the publisher alone and fix the paths in the parser configuration.
Does the silent skip also happen with file or http inputs?
Yes, because the path rule belongs to json_v2, not to mqtt_consumer. Any input that hands json_v2 a flat payload with dotted keys skips those keys the same way, file and http inputs included. A file input reading a saved copy of the payload is also the quickest reproduction: iterate on the escaped paths there, then move the proven field blocks into the live configuration.
Is optional = true dependable for keys at the root of the payload?
Treat it as version-dependent. An issue filed in the Telegraf tracker reports that optional takes effect only for fields below the root object, so on affected versions a missing root-level path raises an error even with the flag set; on 1.36.3 the skip is silent. Either way, prove every root-level path with the flag off before relying on the flag in production.
What does a full buffer with an empty bucket mean?
The opposite fault. Buffer fullness counts metrics queued between collection and the next flush, so a buffer that grows while the bucket stays empty points at the output: the write is failing on token, organization or bucket, and the output plugin logs that error itself. A buffer at zero, as in this case, points upstream, to the subscription and the parser.
