IMD SolutionComputing LibraryShop main store

Troubleshooting

Why one bad InfluxDB metric drops the whole write batch

Edge computing and IIoT Published 8 min read By IMD Solution engineering team

Short answer

One malformed line fails the whole InfluxDB 2.x write request: the server has no per-point skip, so the Logstash output discards every valid neighbor in the batch. Fix it in front of the write — scalars only, flatten or divert bad fields, and cap the request size to limit the blast radius.

On this page
  1. Why does InfluxDB 2.7 reject the whole batch when one metric is bad?
  2. What does the error body tell you?
  3. Which quick fixes do not work?
  4. How do you find the bad metric in the Logstash pipeline?
  5. Why do the points that do land sit near 1970?
  6. How do you stop one bad metric from erasing its neighbors?
  7. How many points does one bad metric cost?
  8. How do you prove the fix before it touches production?
  9. Which decision applies to your fault?
  10. Questions asked

One malformed metric cancels an entire write request: InfluxDB 2.x parses the request body as one unit and has no per-point skip option, so a single line that fails line-protocol parsing rejects the request, and the Logstash output logs it as a non-recoverable exception and discards every point in the batch. The gap that follows appears in Grafana across every series that shared the request, not only the faulty producer's. The fix lives in front of the database: emit one scalar type per field, flatten or divert non-scalar fields in the pipeline, and cap the points-per-request number so a residual fault costs a bounded slice instead of the whole batch.

Why does InfluxDB 2.7 reject the whole batch when one metric is bad? #

Because the server has no per-point skip option: the write request is parsed as one unit, a single line that fails line-protocol parsing fails the whole request, and the Logstash output treats that failure as non-recoverable and drops the batch.

The pipeline in the reported case reads a Kafka topic and posts the events to InfluxDB 2.7 as one multi-line line-protocol body per flush. The server answers a parse failure with a body carrying "code":"invalid", the output raises the error it logs as Non recoverable exception while writing to InfluxDB, and the whole body, valid lines included, never reaches the bucket. The report dates the behavior to a migration from 1.8 to 2.7, but the deciding fact does not depend on settling the version history: while the writer forwards a non-scalar field, no setting on the database rescues the request. Retries cannot help, because the same payload comes back and fails the same way. The tolerance has to be built into the pipeline, in front of the write.

What does the error body tell you? #

The response body separates the fault classes: a code of invalid with unable to parse quotes the malformed token and means a payload fault, while a type-conflict reply names the field and its stored type — read that text before changing any configuration.

The logged failure in the reported case reads:

{"code":"invalid","message":"unable to parse 'metrics.counters,container_name=container-with-error-metric,level=metrics.counter,datacenter=test cacheMiss={\"cacheKeyPrefix\"=>\"container-with-error-metric::message-hash::\", \"cacheStore\"=>\"redis\"},timestamp=\"2023-08-13T08:09:06.791Z\" 1691914146791': invalid boolean"}

The field cacheMiss carries a stringified hash — the => is Ruby hash notation — where line protocol accepts only the four scalar field types: float, integer with an i suffix, quoted string, boolean. An unquoted value that is none of those is tried as a boolean and comes back as invalid boolean. The same error text reaches InfluxDB from other writers, and its causes are worked through for a NAS-based writer in Fix InfluxDB invalid boolean from a NAS write.

A type conflict is the second payload fault, and it was the instance named in the migration report: writing an integer into a field already stored as boolean. Parse errors quote the token; conflict errors name the field and its stored type, so the message tells you which fault you are holding. Keep both apart from capacity faults: timeouts, connection resets and 5xx answers are the recoverable class, and the reset that follows a network outage is worked through in Fix Node-RED InfluxDB write errors after a network outage — an invalid payload replayed ten times fails ten times.

Message signature Fault class Where the fix belongs
unable to parse ... invalid boolean Non-scalar field value in the payload Producer schema, then flatten or divert in the pipeline
Reply names the field and its stored type Type conflict with the bucket schema One type per field; check the schema before changing one
Timeout, connection reset, 5xx Capacity or network fault Sizing and retries
Points dated near the Unix epoch Precision mismatch Set the write precision to the timestamp's unit

Which quick fixes do not work? #

Four tempting moves fail on a running 2.x server: there is no skip switch to enable, retries replay the same rejected payload, a conditional drop throws the container's valid metrics away too, and a major-version migration is a project, not a control.

  • A server-side ignore setting. None exists in 2.x; parsing runs per request, so there is nothing to toggle on the database.
  • Retries. The payload is deterministic, so the same request returns the same invalid rejection; only a changed payload writes.
  • Dropping the offending container. A conditional such as if [container_name] == "container-with-error-metric" { drop {} } stops the neighbors' gaps but discards every valid metric that container emits, and it does nothing for the next producer whose schema drifts.
  • Waiting for a newer major release. A migration changes the product and carries its own feature trade-offs; it is a roadmap decision, not a fix for the system losing data today.

How do you find the bad metric in the Logstash pipeline? #

The log hands you the answer: the parse message quotes the failing line in full, so the measurement, tag set and field name are in hand before you change anything — in the logged example the measurement is metrics.counters and the field is cacheMiss.

  1. Copy the quoted line from the Non recoverable exception while writing to InfluxDB entry and note the measurement, the tag set and the field named in the message.
  2. Park a copy of the producer's events in a file output with the rubydebug codec and confirm which field holds a hash or a drifting type.
  3. Check every field value against the four scalar types: float, integer with an i suffix, quoted string, boolean.
  4. Check the timestamp digits: the sample line ends in 1691914146791, a 13-digit epoch stamp, and it also carries timestamp="2023-08-13T08:09:06.791Z" as a quoted string field that duplicates the point time — the duplicate invites its own type conflict and should be removed.

Why do the points that do land sit near 1970? #

A 13-digit epoch stamp such as 1691914146791 is milliseconds, and a write request that leaves the precision at the default nanoseconds reads it as nanoseconds, so the point lands about 28 minutes after the Unix epoch — in Grafana that shows as a cluster of points dated January 1970.

The arithmetic: 1,691,914,146,791 ns ÷ 1,000,000,000 = 1,691.9 s ≈ 28 min 12 s, which dates the point 1970-01-01T00:28:12Z. The string field in the same line confirms the unit: 2023-08-13T08:09:06.791Z is exactly the instant those milliseconds encode. The v2 write request accepts a precision parameter with the units ns, us, ms and s — set it to the unit the producer emits, then confirm the newest point in the bucket sits at the current wall clock.

How do you stop one bad metric from erasing its neighbors? #

Three changes in front of the write remove the failure: producers emit one scalar type per field, a pipeline filter flattens or diverts anything non-scalar before the output, and the points-per-request size is capped so a residual bad point costs a bounded slice instead of the whole flush.

Fix the producer first: scalars only, one type per field across every service writing the measurement, and no duplicated timestamp string. In a Telegraf-based stack the same discipline applies at the input, where dropping or renaming bad fields before the write is worked through in Filter MQTT fields in Telegraf before they reach InfluxDB.

For a Logstash pipeline, the sketch below flattens one level of hash nesting and tags any non-scalar value that survives; _lp_invalid is an illustrative tag name, and event.set, event.remove, event.tag and to_hash are the documented methods of the ruby filter — adapt the field rules to your schema:

filter {
  ruby {
    code => '
      event.to_hash.each { |k, v|
        next unless v.is_a?(Hash)
        v.each { |sk, sv| event.set("#{k}_#{sk}", sv) }
        event.remove(k)
      }
      event.to_hash.each { |k, v|
        event.tag("_lp_invalid") if v.is_a?(Hash) || v.is_a?(Array)
      }
    '
  }
}
output {
  if "_lp_invalid" in [tags] {
    file { path => "/var/log/logstash/influx-rejects-%{+YYYY-MM-dd}.log" }
  } else {
    # the existing influxdb output stays here
  }
}

Events carrying the tag go to a reject file instead of the database, so the batch keeps flowing and the faulty payload is preserved for the producer's owner. Reduce the request size in the output plugin's batch and flush settings — the option names vary by plugin version, so take them from that plugin's own documentation — and remove the container-level drop only after the test below passes.

How many points does one bad metric cost? #

Points lost per fault equals points per request minus one, so an illustrative 500-point request loses 499 valid neighbors per bad metric; at one fault every 30 seconds that is 120 × 499 = 59,880 points an hour, and a 50-point cap cuts it to 120 × 49 = 5,880.

Both inputs are examples: the output plugin's flush settings set the request size and the faulty producer's emit rate sets the fault count, and the loss moves in straight proportion to each — halve the request size and you halve the loss per fault. Capping the size bounds the damage; only the schema fix removes the cause. Decide the cap from the worst case you can absorb per fault, which is always points per request minus 1.

How do you prove the fix before it touches production? #

Send a ten-event test batch — nine valid points from healthy producers plus one carrying a hash-valued field — and hold rollout until three results land: nine points queryable in the bucket, exactly one line in the reject file, and no non-recoverable exception in the log.

  • Query the affected measurement across the test window and confirm no empty interval sits at the injection time.
  • Reconcile the counts: events consumed, points written and reject-file lines must add up to the ten sent.
  • Watch one full flush interval of normal traffic; the Non recoverable exception while writing to InfluxDB line must not return for payload reasons.
  • Confirm the newest point in the bucket carries the current wall clock, which rules out the precision fault.

Once the test passes, treat the reject file as a monitored output: a growing file is a producer regression arriving on schedule, while a silent file with fresh gaps in Grafana points back to load or precision.

Which decision applies to your fault? #

Match the signature to the fault class: an invalid parse or a named type conflict is a payload fault fixed in front of the database with schema, flatten-divert and a capped request; timeouts and 5xx are capacity faults for sizing and retries; January-1970 points are a precision setting.

For the payload class the decision is final: no InfluxDB 2.x setting skips the point, so the validating, flattening, diverting, size-capped pipeline is the fix, and every other measure only limits what the next bad metric costs.

Questions asked

Can Kafka give the rejected points back?

Usually yes. The events reached Kafka before Logstash, so a rejected request is still in the topic as long as the broker's retention window covers the fault time. Once the pipeline is corrected, a reprocessing consumer reading the same topic can backfill the gap — check the topic's retention setting before assuming the data is gone.

What if the producer cannot be fixed immediately?

Divert instead of drop. Flatten what flattens, tag what remains non-scalar, and route tagged events to a monitored reject file so valid neighbors keep flowing into the database. Hand the reject file to the service owner and treat any growth in it as an open defect against that producer's schema.

Does a newer InfluxDB release skip bad points?

The 2.x parser has no per-point skip option, and a major-version migration brings feature trade-offs of its own, so do not schedule a migration around an unconfirmed parser change. Verify any release against your own ten-event test batch before relying on its handling of a malformed line.

Why does one small producer erase data from busy ones?

Because Logstash batches events across the topics and producers it serves, a low-volume service that emits one malformed field poisons every request it shares with high-volume producers' points. Schema drift between services is the usual trigger, so validate at the pipeline entrance rather than trusting each producer's track record.

Keep reading

  • Troubleshooting

    Fix InfluxDB invalid boolean from a NAS write

    The 400 invalid boolean response is a body-parse failure: the write body opens with a tag set instead of a measurement, and single quotes stop the shell expanding the variables. Send a complete line-protocol point such as disk_temperature,server=BackupNAS,disk=sda value=34, quote the body in double quotes, and expect 204 No Content to confirm the write.

    Edge computing and IIoT

  • How-to

    Build multidimensional arrays in Node-RED for InfluxDB writes

    Cache each subscription's last value per point, re-emit it on a 100 ms inject tick, batch 10 samples per point and join them into one multidimensional array, then format line protocol in a single function node so one influxdb out node writes the whole batch. Ten points at a 100 ms tick become one 100-line write per second; the demonstrated flow neared Node-RED's limit at 80 points.

    Edge computing and IIoT

  • How-to

    Filter MQTT fields in Telegraf before they reach InfluxDB

    Yes: add fielddrop to the mqtt_consumer input block in telegraf.conf and list the parsed field names, for example ENERGY_ApparentPower or the suffix glob *_ReactivePower. The filter runs at the end of the input, so it shapes new points only and never rewrites points already stored in InfluxDB. Drop a minority of fields with fielddrop, keep a minority with fieldinclude, and filter tags with tagdrop.

    Edge computing and IIoT

Why PI Data Archive tag names are not stored as Unicode