Troubleshooting
Why Telegraf writes one InfluxDB point from 80 MQTT entries
Short answer
InfluxDB identifies a point by measurement, tag set and timestamp, so a burst of MQTT entries repeating one timestamp collapses into a single point and later writes overwrite the field values. QuestDB appends every row, which is why it shows the complete burst. Telegraf and the network are healthy; fix the timestamps at the publisher.
On this page
A whole burst of MQTT entries reaches Telegraf, both outputs accept it, and InfluxDB still shows a single point. Nothing was dropped on the way: InfluxDB identifies a point by measurement, tag set and timestamp together, every entry in the burst shares all three, so the writes merge into one stored point and the last field values overwrite the earlier ones. QuestDB shows every entry because it appends each received line as a row and merges nothing. That asymmetry proves the broker, the consumer and the network are healthy; the loss sits in the data contract, and the fix is one distinct timestamp per entry at the publisher. The sections below trace the path hop by hop, show the arithmetic, and end with the decision for each way a publisher can be wrong.
Prove the path delivers every entry #
Both outputs drain from the same agent buffer, and one of them demonstrably receives the complete burst, so the fault cannot sit upstream of the outputs. Walk the hops once and keep the evidence:
- Publisher to broker: the burst of line-protocol messages publishes with no disconnect in the broker log, and the network forwards every message it receives.
- Broker to consumer: eight mqtt_consumer inputs subscribe to the topic
telegrafwithdata_format = "influx", and the startup log prints a Connected line for each broker. - Consumer to output buffers: the agent holds up to 10000 metrics per output, writes them in batches of 2000 and flushes every 10 s; the debug log shows batches draining and buffer fullness returning to its idle level.
- Buffer to QuestDB:
outputs.socket_writersends line protocol overtcp://localhost:9009, and the QuestDB row count grows by the full burst size on every cycle. - Buffer to InfluxDB:
outputs.influxdb_v2writes to the local bucket and logs Wrote batch of 2000 metrics with no error line, yet only one point appears.
Both database targets sit on loopback, so no firewall or cable takes part in the writes, and removing the socket_writer block changed nothing on the InfluxDB side, which rules out interaction between outputs. The Connected lines also rule out the different failure where the Telegraf MQTT consumer connects but writes no data to InfluxDB. Then search the log for rejected writes; a rejected write prints an error or warning line with a status code, and an authorization failure is its own diagnosis in what to fix when Telegraf reports authorization not found on InfluxDB 2:
grep -E " (E|W)! " ./telegraf.log
An empty result closes the transport question, because InfluxDB accepts colliding points without complaint: a clean write says nothing about how many distinct points were stored.
What makes two writes the same point #
InfluxDB identifies a point by measurement, tag set and timestamp together; field keys and values are not part of that identity. A write whose measurement, tags and timestamp match a stored point does not insert a row: its field set merges into that point, and for every field key that already exists the last value written wins. The HTTP status stays clean and the schema never changes when this happens.
| Identity component | Part of the identity? | Role in this failure |
|---|---|---|
| Measurement name | Yes | every entry in a burst carries the same one |
| Tag set | Yes | the agent adds host=qdb to every metric, so all entries share one set |
| Timestamp | Yes | the payload repeats one timestamp across the burst |
| Field keys and values | No | different field values cannot separate points that share an identity |
Two collision mechanisms produce the count you are seeing. Within one burst, every entry carries the same series and the same timestamp, so the whole burst merges into a single point. Across cycles, a publisher that built its message set once and resends it with the original timestamps rewrites that same point every cycle, so the count never grows. The single new entry that appeared after an agent or broker restart is the signature of a generator rebuilding its set with a fresh timestamp, after which the overwriting resumes.
The arithmetic for one burst #
Worked example, one publish cycle. The publisher sends 80 line-protocol entries for the measurement machine (an example name), each carrying the same ten field keys and the timestamp 1632316260000000000 nanoseconds, which reads as 2021-09-22T13:11:00Z; the agent tags every entry host=qdb.
- Series: 1 measurement x 1 tag set = 1 series.
- Distinct timestamps in the burst: 1.
- Stored points in InfluxDB: 1 series x 1 timestamp = 1 point.
- Field values: each of the ten field keys receives 80 values, the last one written wins, so 79 values per key are discarded and 79 x 10 = 790 field values are lost in this single cycle.
- QuestDB, fed the same metrics, appends one row per received line: 80 rows.
Nothing errors and nothing logs; the bucket quietly holds one point where the publisher delivered a full burst of candidates for every field key.
Why QuestDB counts every row #
The socket_writer output forwards the same parsed metrics, and QuestDB stores each received line as a new row. A repeated timestamp is not an error there, and rows merge only if deduplication is explicitly enabled on the table. The row count therefore tracks deliveries exactly, which makes QuestDB this pipeline's delivery meter — and explains why the fault hides so well: a complete QuestDB table says the pipeline works, while the data contract with InfluxDB is broken. Use the QuestDB count to answer whether everything arrived, and the InfluxDB count to answer how many distinct points exist; never ask one database both questions.
Dump what actually leaves Telegraf #
Add a third output that writes the parsed line protocol to a file; it records exactly what both databases receive and gives a count independent of either:
[[outputs.file]]
files = ["/tmp/lp_dump.txt"]
data_format = "influx"
Restart the agent, confirm the startup line now lists file among the loaded outputs, publish one burst, and wait one flush interval — the 10 s this setup uses — so the buffers drain. Count the lines and the distinct identity pairs:
wc -l /tmp/lp_dump.txt
awk '{print $1, $NF}' /tmp/lp_dump.txt | sort -u | wc -l
The first field of a line-protocol record is the measurement plus the tag set and the last field is the timestamp, as long as no tag value contains an escaped space, so the second count is the number of distinct points InfluxDB can hold. A full burst on the first count and one distinct pair on the second is this failure's signature; two equal counts mean the timestamps differ and the identity model no longer explains the loss, so look at the tag sets instead.
Read the timestamp width while the file is open. A nanosecond epoch timestamp has 19 digits; a 10-digit value is seconds. Seconds read under the line protocol's default nanosecond precision land just after 1970-01-01 — the example value 1632316260 read as nanoseconds is 1.63231626 s past the epoch — and a relative query such as range(start: -15m) then returns nothing, so rerun once with range(start: 0) to rule that out.
To count stored points, query one field key over the burst window; bucket data and organization myorg in this setup, with your own measurement and field key substituted for the example names:
from(bucket: "data")
|> range(start: -15m)
|> filter(fn: (r) => r._measurement == "machine" and r._field == "f1")
|> group()
|> count()
Counting a single field key returns points, not points multiplied by the ten field keys stored in each point.
Fix the timestamps where they are born #
Telegraf, the broker, the buffers and the network are eliminated: every entry arrives, parses and drains, and the duplicates ride in the payload. No downstream setting can hand colliding writes distinct instants, so pick the fix where the timestamps are made:
- Publisher stamps at send time — give every entry its own timestamp when it is published instead of one timestamp for the whole set; the burst then stores one point per entry, and the two databases finally agree.
- One snapshot, many values — if the ten values genuinely belong to one instant, keep them as one point: send a single line-protocol line with ten field keys instead of ten lines that share a timestamp, and they merge by design with every field present.
- Separate rows at one instant — if rows must stay separate and legitimately share an instant, add a tag that differs per row, such as a sensor or channel identifier, so the tag sets differ and the point identities differ with them.
- Overwrite intended — sending the same identity on purpose updates the point in place, last value wins; that is a legitimate design, and it is exactly what this pipeline is doing now.
If the timestamps come from the payload rather than from Telegraf's clock, map them deliberately: keeping both the arrival time and the payload timestamp in Telegraf shows how to hold on to both instants instead of letting one silently win.
The decision, case by case: repeated payload timestamps — fix the publisher to stamp each entry; one snapshot spread over many lines — collapse it into one multi-field point or add a distinguishing tag; overwrite intended — leave the design as it is. QuestDB holding more rows than InfluxDB holds points is the expected behavior of two different identity models, not a fault in either database.
Questions asked
Where does the timestamp in an MQTT line-protocol message come from?
With data_format = "influx", Telegraf parses the timestamp written into each line-protocol payload. A message without a timestamp is stamped by Telegraf at arrival. That is why a publisher that reuses payload timestamps, rather than stamping at send time, decides the point count in InfluxDB before Telegraf sees the messages.
Why do trend windows and averages not reveal the merge?
Every window still holds a value for the merged point, so no gap appears in the trend and averages, first and last all compute normally from the one surviving value. The loss shows up only as a point count that stops growing, which is why counting points over a burst window is the reliable check.
What happens to the QuestDB count if deduplication is switched on there?
QuestDB collapses duplicate rows only after deduplication is explicitly enabled on the table. Once it is, QuestDB starts merging the same repeated-timestamp rows that InfluxDB merges, and you lose the independent delivery meter that proved the burst arrived complete. Keep one append-only database in the path if you need that meter.
Does InfluxDB return an error when colliding points arrive?
No. A write that merges into existing points completes with a clean status, and the Telegraf log shows only the usual batch-written lines. Error lines appear for rejected writes, such as an authorization failure, not for identity collisions. A clean log therefore proves delivery, never distinctness.