Troubleshooting
Telegraf MQTT consumer connects but writes no data to InfluxDB
Short answer
An empty 0 / 10000 output buffer with both the MQTT and InfluxDB connections up means no metrics are reaching Telegraf's parser. Prove live delivery with a second subscriber on a different client ID before touching parser or buffer settings: the two startup connections are independent events, and with qos = 0 and a non-persistent session, traffic published while Telegraf is offline is unrecoverable.
On this page
- Why do both connections succeed while no points get stored?
- What does the buffer fullness line really count?
- How do I prove the broker is delivering messages right now?
- Why doesn't the root wildcard subscription pick up every topic?
- How do I tell whether parsing is dropping the payloads?
- What is the logfile error covering up?
- Do bigger batch or buffer settings help get data through?
- Questions asked
Telegraf 1.18.2 connected to the broker at tcp://192.168.1.25:1883 and to the InfluxDB output at http://192.168.1.25:8086, the database is created on startup, and the debug log still repeats Buffer fullness: 0 / 10000 metrics every 10 s with no stored points. That combination means no metrics are being created at all: the two successful connections are independent events, not an end-to-end test. Prove live delivery with a second MQTT subscriber on its own client ID before touching the parser, the batch size, or the buffer limit, and repair the logfile path so reception and parser errors are visible. With qos = 0 and persistent_session = false, anything published while Telegraf is offline is unrecoverable, so every test must use live traffic.
Why do both connections succeed while no points get stored? #
Because each startup line proves only its own hop: Connected [tcp://192.168.1.25:1883] says the broker accepted Telegraf's connection, and the output line says the HTTP API on port 8086 answered — neither says a message was published, parsed, or written. The pipeline has four stages and each log line covers exactly one of them:
| Stage | A success here proves | It does not prove |
|---|---|---|
| Publisher to broker | The publisher sent a message to this broker | That Telegraf's subscription matches the topic |
| Broker to Telegraf | The subscription matched and a payload was delivered | That the payload parsed into a metric |
| mqtt_consumer parser | Messages became metrics | That InfluxDB accepted them |
| Telegraf to InfluxDB | Writes were accepted on port 8086 | That your query selects those points |
Recreating the database by restarting the service proves only that the output plugin initialized it — the same class of partial proof as the connection lines. Because the broker, Telegraf, and InfluxDB share one host and both configured endpoints are that host's own address, a cable or switch fault is a low-priority explanation here. The same stage-by-stage split in a Node-RED pipeline is covered in troubleshooting missing data in a Node-RED InfluxDB Grafana stack.
Work in this order:
- Repair the logfile path so diagnostics are visible.
- Attach a second subscriber with its own client ID and confirm one live publication.
- Compare the publisher's exact topic with
topics = ["#"], including topics that start with$. - Only then judge parsing, using the captured payload and the mqtt_consumer diagnostics.
- Finish by querying the database for a written point.
What does the buffer fullness line really count? #
It counts metrics waiting in the output queue at that instant — with flush_interval = "10s", a healthy pipeline creating 2 metrics per interval also reads 0 / 10000 right after a flush, because the batch was just written. The metric buffer exists for output outages: it fills when InfluxDB refuses or fails writes and drains when writes succeed. A documented Telegraf issue report shows exactly that behavior — with InfluxDB down, buffer fullness climbed to 4000 of 50000 metrics and drained once the database returned.
So your steady 0 reading across successive flushes means zero metrics were created in those windows; the line is a snapshot of the queue, not a counter of received messages. Since no parse error appears in the debug excerpt either, the evidence points upstream of the parser: either nothing is being delivered, or the subscription does not match the topic being published.
How do I prove the broker is delivering messages right now? #
Connect a second MQTT subscriber to the same broker and account, give it a different client ID from telegraf-fronius, and watch for one live publication — if nothing arrives while the publisher should be sending, the fault is upstream of Telegraf. Run the test like this:
- Subscribe with the same account the config uses and a client ID of your own; never reuse
telegraf-fronius. - Record one message's exact topic and raw payload, not just the value shown in the publishing application, while Telegraf stays connected.
- If the subscriber connects but sees nothing, check the account's subscription permissions and whether the publisher really targets this broker.
- Close the test client when you are done, so debugging does not leave an extra subscribed identity on the broker.
Two settings in your config decide what this test can and cannot show. qos = 0 is the MQTT protocol's at-most-once level: no acknowledgment, no retransmission. persistent_session = false opens a clean session, so when Telegraf disconnects the broker discards its state and queues nothing — the gap can never be replayed as a test. Retained messages are a separate broker feature: check whether the publisher sets the retained flag if you expect a value without a live publisher, but do not treat retention as history.
This publisher-side proof is the same first move as when a PLC MQTT client never reaches your broker, and the exposure QoS 0 leaves open is what covering the QoS 0 loss window in Sparkplug MQTT transmission works through. Decision: if the subscriber sees nothing, stop debugging Telegraf — fix the publisher's destination, the topic, or the account's permissions. If the subscriber sees data while Telegraf stays at zero, move to the topic filter, then the parser.
Why doesn't the root wildcard subscription pick up every topic? #
Because the MQTT specification forbids a wildcard at the root from matching topic names that start with $, so any publisher using a $-prefixed topic is invisible to your root-level subscription — subscribe to that topic explicitly instead. In MQTT, topic names beginning with $ are reserved for the server's own use, and the matching rules keep a filter starting with # from ever matching them: a root-level # is not "everything".
Compare the publisher's exact topic string, character for character, with the subscription; MQTT topic matching is case-sensitive and treats spaces as significant. Once you locate the real stream, replace the root wildcard with the actual topic prefix: you drop broker-internal noise and the subscription documents what the pipeline consumes. Decision: if the publisher uses a $-prefixed topic you need, name that topic in topics explicitly rather than relying on #.
How do I tell whether parsing is dropping the payloads? #
Run Telegraf with --debug and watch for the mqtt_consumer parse diagnostic — the documented line "No metrics were created from a message" followed by "Verify your parser settings" is direct evidence that payloads arrive but produce no metrics. In your run that line never appears, which together with the empty buffer is itself evidence that messages are not arriving. When you do see it, align data_format = "json" and data_type = "float" with the payload you captured, including where the numeric value sits in the JSON structure.
Decision: never change a parser setting before you have looked at one raw payload; a blind change trades one mismatch for another. If diagnostics show metrics being created and points still do not land, move to the output side: query the database you configured, not a default one, and confirm a write following a known live publication.
What is the logfile error covering up? #
Telegraf cannot open /var/log/telegraf/telegraf-vrm.log because the directory does not exist, so it falls back to stderr — every reception and parser error is still produced, just somewhere else, usually the service manager's captured output. The error does not stop collection: the same run loads both plugins and connects both endpoints. Create the directory with write permission for the account the service runs as, or point logtarget = "file" at a location that account can write, and verify by starting the service and reading the file back. Until that works, read the diagnostics wherever the service manager captures stderr. Decision: fix this in parallel with the delivery test — the parser verdict depends on lines you can actually see.
Do bigger batch or buffer settings help get data through? #
No — leave metric_batch_size = 1000 and metric_buffer_limit = 10000 alone: they govern how Telegraf ships metrics it has already created, and your log shows zero created, so no output tuning changes anything. These settings are outage insurance on the output side, and the arithmetic shows how much.
Healthy case: the publisher sends one JSON message every 5 s, so each 10 s flush interval creates 2 metrics. That is 2 ≤ 1000, so one small batch is written per flush and the buffer returns to 0 — the same log line as your dead pipeline. Only a query that returns the measurement tells the two apart.
Outage case at the same rate: 2 metrics per 10 s is 0.2 metrics per second, so the 10000-metric buffer holds 10000 ÷ 0.2 = 50000 s ≈ 13.9 h of backlog. In batch terms that is 10000 ÷ 1000 = 10 flush cycles of full batches, matching the reported behavior of the buffer filling while InfluxDB is down and draining on recovery. Decision: keep the values as they are, prove delivery and parsing first, and treat any later buffer tuning as a separate, measured throughput decision.
Questions asked
Should I raise qos to 1 and enable persistent_session to stop losing data?
QoS 1 makes broker-to-Telegraf delivery acknowledged and retransmitted, and a persistent session lets the broker queue messages while Telegraf is disconnected, but neither changes anything if the publisher targets a different broker or a topic your filter misses. Fix delivery with the second-subscriber test first, then set qos = 1 and persistent_session = true to cover restart gaps.
Can I run the test subscriber with Telegraf's client_id?
No. The broker treats the client identifier as unique: when a new connection presents the same one, it drops the existing connection, so you would disconnect Telegraf and prove nothing about its session. Give the test subscriber its own client ID while using the same account.
Does the database appearing after startup prove the InfluxDB output works?
It proves the output plugin reached the API on port 8086 and set the database up, nothing more. A write is proven by querying that same database for the measurement the parser built from a live payload, one flush after the delivery test succeeds.
How fast should points appear once delivery works?
Within one flush interval plus a few seconds: with flush_interval = 10s and 2 metrics created per interval, each flush writes one small batch and the buffer reads 0 again. If the measurement appears but history has gaps, those gaps match the periods collection was down at qos = 0 and cannot be backfilled from the broker.