apache/druid · error · ParseException

Unable to parse line.

Error message

Unable to parse line.

What it means

parseLineToMap feeds the input record to an ANTLR-generated parser for the Influx line protocol. If the parser reports any syntax errors (parser.getNumberOfSyntaxErrors() != 0), the reader throws ParseException("Unable to parse line.") for the full input. The record is not valid Influx line protocol per the extension's grammar.

Source

Thrown at extensions-contrib/influx-extensions/src/main/java/org/apache/druid/data/input/influx/InfluxLineProtocolReader.java:102

    return false;
  }

  @Override
  public void processHeaderLine(String line)
  {
    // no header lines in influx line protocol
  }

  private Map<String, Object> parseLineToMap(String input)
  {
    CharStream charStream = new ANTLRInputStream(input);
    InfluxLineProtocolLexer lexer = new InfluxLineProtocolLexer(charStream);
    TokenStream tokenStream = new CommonTokenStream(lexer);
    InfluxLineProtocolParser parser = new InfluxLineProtocolParser(tokenStream);

    List<InfluxLineProtocolParser.LineContext> lines = parser.lines().line();
    if (parser.getNumberOfSyntaxErrors() != 0) {
      throw new ParseException(input, "Unable to parse line.");
    }
    if (lines.size() != 1) {
      throw new ParseException(input, "Multiple lines present; unable to parse more than one per record.");
    }

    Map<String, Object> out = new LinkedHashMap<>();

    InfluxLineProtocolParser.LineContext line = lines.get(0);
    String measurement = parseIdentifier(line.identifier());

    if (!checkWhitelist(measurement)) {
      throw new ParseException(input, "Metric [%s] not whitelisted.", measurement);
    }

    out.put(MEASUREMENT_KEY, measurement);
    if (line.tag_set() != null) {
      line.tag_set().tag_pair().forEach(t -> parseTag(t, out));
    }

View on GitHub (pinned to 9b90983fd2)

Solutions

  1. Validate the offending line against Influx line-protocol syntax: measurement[,tag=k v1,...] [timestamp], and fix quoting/escaping (\ , \=, \ ).
  2. Ensure each record is exactly one line-protocol point with at least one field (fields section is mandatory).
  3. Route non-line-protocol data to the appropriate input format instead of the influx reader.
  4. Enable/review the reader's parse-failure logging to see the full rejected input, then correct the producer or add a pre-filter.

Example fix

// before (invalid: field value unquoted string)
cpu,host=a usage="high"
// after
cpu,host=a usage=1.0 1710000000000000000
Defensive patterns

Strategy: validation

Validate before calling

// Cheap pre-parse sanity check before ingesting
if (line == null || line.trim().isEmpty()) throw new IllegalArgumentException("empty line");
int spaceIdx = line.indexOf(' ');
if (spaceIdx <= 0 || spaceIdx == line.length() - 1) throw new IllegalArgumentException("missing fields section: " + line);

Try / catch

try {
  reader.read(record);
} catch (org.apache.druid.java.util.common.parsers.ParseException e) {
  log.warn("Bad line-protocol record, skipping: {}", e.getMessage());
  metrics.incrementParseErrors();
  return null; // or dead-letter the record
}

Prevention

When it happens

Trigger: Streaming a record into the Influx inputSource whose text violates line-protocol grammar — missing measurement, malformed tag/field pairs, unescaped spaces or commas, missing field section, bad timestamp — so ANTLR reports syntax errors.

Common situations: Exported Influx data containing multiple or escaped constructs the grammar doesn't accept; CSV/other data misrouted into the influx parser; truncated records from a producer; unescaped '=' or ',' in tag keys/values; newline or quoting issues in the source file.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


AI-assisted analysis of apache/druid@9b90983fd2 (2026-09-07). Data as JSON: /api/errors/b139f438bcaecaeb. Report an issue: GitHub.