Skip to content

Unable to Parse Timestamp in OTEL Collector Filelog Receiver #34390

Closed
@vimalraj3

Description

@vimalraj3

Description

I am experiencing an issue with the OTEL Collector configuration where the filelog receiver is unable to parse timestamps from the log files. Below are the relevant configurations and the error message encountered:

OpenTelemetry Collector configuration

receivers:
  filelog:
    include: [ /var/logs/*.log ]
    operators:
      - type: regex_parser
        regex: '^(?P<timestamp>\d{4}-\d{2}-\d{2}-\d{2}-\d{2}-\d{2}:\d{3}) \[(?P<thread>[^\]]+)\] (?P<sev>[A-Z]*) (?P<msg>.*)$'
        timestamp:
          parse_from: attributes.timestamp
          layout_typ: strptime
          layout: '%Y-%m-%d-%H-%M-%S:%L'
        severity:
          parse_from: attributes.sev

exporters:
  debug:
    verbosity: detailed 

service:
  pipelines:
    logs:
      receivers: [filelog] 
      exporters: [debug]

Input Logs

2024-07-31-11-11-20:295 [http-nio-8300-exec-5] DEBUG com.txnws_watchlist.TxnWsWatchlist.eventing.RabbitPublisher:46 - Exit in rabbitMqEventPublisher
2024-07-31-11-11-20:295 [http-nio-8300-exec-5] DEBUG com.txnws_watchlist.TxnWsWatchlist.eventing.RabbitPublisher:46 - Exit in rabbitMqEventPublisher
2024-07-31-11-11-20:295 [http-nio-8300-exec-5] DEBUG com.txnws_watchlist.TxnWsWatchlist.eventing.RabbitPublisher:46 - Exit in rabbitMqEventPublisher
2024-07-31-11-11-20:295 [http-nio-8300-exec-5] DEBUG com.txnws_watchlist.TxnWsWatchlist.eventing.RabbitPublisher:46 - Exit in rabbitMqEventPublisher

Steps to Reproduce:

  1. Configure the OTEL Collector with the above configuration.
  2. Include log files with timestamps in the format YYYY-MM-DD-HH-MM-SS:SSS.
  3. Run the collector and observe the error in the logs.

Expected Result

The timestamp in the logs should be parsed correctly using the specified regex pattern and layout format.

Actual Result

2024-08-02T11:56:06.423Z    error   helper/transformer.go:102       Failed to process entry {"kind": "receiver", "name": "filelog","data_type": "logs", "operator_id": "regex_parser", "operator_type": "regex_parser", "error": {"description": "time parser: parsing time \"2024-07-31-11-11-20:295\" as \"2006-01-02-15-04-05::999\": cannot parse \"295\" as \"::999\""}, "action": "send"}  

Collector version

v0.104.0

Environment information

OS: Amazon Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions