Skip to content

[pkg/stanza] Container parser not playing well with downstream operator that experiences an error #34295

Closed
@TylerHelmuth

Description

@TylerHelmuth

Component(s)

pkg/stanza

What happened?

Description

I'm seeing strange behavior when I use the container parser chained with a regex parser that sometimes fails (because the regex is not always present in the log). When the regex_parser fails, logs collection stops. I believe this is because the container parser currently breaks out of the crioConsumer goroutine if the Write returns an error:

func (p *Parser) crioConsumer(ctx context.Context) {
entriesChan := p.crioLogEmitter.OutChannel()
p.criConsumers.Add(1)
defer p.criConsumers.Done()
for entries := range entriesChan {
for _, e := range entries {
err := p.Write(ctx, e)
if err != nil {
p.Logger().Error("failed to write entry", zap.Error(err))
return
}
}
}
}

Steps to Reproduce

Use a filelogreceiver config such as

filelog:
        exclude: []
        include:
        - /var/log/pods/*/*/*.log
        include_file_name: false
        include_file_path: true
        operators:
        - id: container-parser
          max_log_size: 102400
          type: container
        - type: regex_parser
          regexp: '\slevel=(?P<severity_field>\w+)\s'
          on_error: send_quiet
          severity:
            parse_from: attributes.severity_field
        retry_on_failure:
          enabled: true
        start_at: end

Send through a log that does not match the regex parser and then send through a log that does match.

Expected Result

Both logs are sent, with the second having a severity set.

Actual Result

Neither logs are sent.

Collector version

v0.105.0

Environment information

No response

OpenTelemetry Collector configuration

No response

Log output

No response

Additional context

No response

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions