apache/druid · error · ParseException

Multiple lines present; unable to parse more than one per re

Error message

Multiple lines present; unable to parse more than one per record.

What it means

The reader is designed to ingest one Influx line-protocol point per record. After parsing, if lines.size() != 1 (typically more than one parsed line), it throws ParseException("Multiple lines present; unable to parse more than one per record."). Records containing several protocol points must be split upstream.

Source

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

  @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));
    }

    line.field_set().field_pair().forEach(t -> parseField(t, out));

View on GitHub (pinned to 9b90983fd2)

Solutions

  1. Split the input so each record contains exactly one line-protocol point (fix the line delimiter/splitSpec in the input source config).
  2. Fix the producer to emit one point per message/line rather than batching multiple points.
  3. Pre-process the file to replace embedded newlines/record separators between points with proper record boundaries.
  4. If one point per record can't be guaranteed, switch to an input format/reader that supports multi-line batches.

Example fix

// before: one record = "m1 v=1\nm2 v=2"
// after: configure input to split on newline so each record is a single point, or emit separately
m1 v=1
m2 v=2
Defensive patterns

Strategy: validation

Validate before calling

// Pre-split and validate record count
String[] points = record.split("\n");
if (points.length > 1) {
  throw new IllegalArgumentException("record must contain exactly one line-protocol point, got " + points.length);
}

Try / catch

try {
  return parseLineToMap(input);
} catch (org.apache.druid.java.util.common.parsers.ParseException e) {
  if (e.getMessage() != null && e.getMessage().contains("Multiple lines present")) {
    // split and re-submit individual points through the pipeline
    return null;
  }
  throw e;
}

Prevention

When it happens

Trigger: A single input record containing two or more line-protocol points (e.g. two measurements separated by a newline that survived in the record, or a record assembled from multiple protocol lines).

Common situations: A source file where points are concatenated without proper record boundaries; a streaming producer batching multiple points into one message; line-ending mismatches (\r\n vs custom splitIngestion) causing two lines to land in one record.

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/343fcff82bd06b81. Report an issue: GitHub.