Skip to content

Commit

Permalink
added validation for docker log format for recombine statment
Browse files Browse the repository at this point in the history
adjust error logs to send instead of drop
  • Loading branch information
daidokoro committed May 16, 2024
1 parent 8b4fc44 commit 004a09d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
17 changes: 14 additions & 3 deletions modules/ecs-ec2/otel_config.tftpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,37 @@ receivers:
include_file_path: true
# add log.file.path to resource attributes
operators:
- type: router
id: docker_log_json_parser
routes:
- output: json_parser
expr: 'body matches "^\\{\"log\".*\\}"'
default: move_log_file_path

- type: json_parser
parse_from: body
parse_to: body
output: recombine
timestamp:
parse_from: body.time
layout: '%Y-%m-%dT%H:%M:%S.%fZ'
default: move_log_file_path

# handle logs split by docker
- type: recombine
id: recombine
output: move_log_file_path
combine_field: body.log
source_identifier: attributes["log.file.path"]
is_last_entry: body.log endsWith "\n"
force_flush_period: 10s
on_error: drop
force_flush_period: 10s
on_error: send
combine_with: ""

- type: move
id: move_log_file_path
from: attributes["log.file.path"]
to: resource["log.file.path"]

processors:
resourcedetection:
# ecs & docker detectors not required when using ecslogresourcedetection for logs
Expand Down
16 changes: 14 additions & 2 deletions modules/ecs-ec2/otel_config_metrics.tftpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,35 @@ receivers:
include_file_path: true
# add log.file.path to resource attributes
operators:
- type: router
id: docker_log_json_parser
routes:
- output: json_parser
expr: 'body matches "^\\{\"log\".*\\}"'
default: move_log_file_path

- type: json_parser
parse_from: body
parse_to: body
output: recombine
timestamp:
parse_from: body.time
layout: '%Y-%m-%dT%H:%M:%S.%fZ'
default: move_log_file_path

# handle logs split by docker
- type: recombine
id: recombine
output: move_log_file_path
combine_field: body.log
source_identifier: attributes["log.file.path"]
is_last_entry: body.log endsWith "\n"
force_flush_period: 10s
on_error: drop
force_flush_period: 10s
on_error: send
combine_with: ""

- type: move
id: move_log_file_path
from: attributes["log.file.path"]
to: resource["log.file.path"]

Expand Down

0 comments on commit 004a09d

Please sign in to comment.