Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update examples that should have changed with update to v0.28.0 #9019

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 28 additions & 22 deletions examples/kubernetes/otel-collector-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@ receivers:
id: get-format
routes:
- output: parser-docker
expr: '$$body matches "^\\{"'
expr: 'body matches "^\\{"'
- output: parser-crio
expr: '$$body matches "^[^ Z]+ "'
expr: 'body matches "^[^ Z]+ "'
- output: parser-containerd
expr: '$$body matches "^[^ Z]+Z"'
expr: 'body matches "^[^ Z]+Z"'
# Parse CRI-O format
- type: regex_parser
id: parser-crio
regex: '^(?P<time>[^ Z]+) (?P<stream>stdout|stderr) (?P<logtag>[^ ]*) (?P<log>.*)$'
output: extract_metadata_from_filepath
timestamp:
parse_from: time
parse_from: body.time
layout_type: gotime
layout: '2006-01-02T15:04:05.000000000-07:00'
# Parse CRI-Containerd format
Expand All @@ -34,36 +34,42 @@ receivers:
regex: '^(?P<time>[^ ^Z]+Z) (?P<stream>stdout|stderr) (?P<logtag>[^ ]*) (?P<log>.*)$'
output: extract_metadata_from_filepath
timestamp:
parse_from: time
parse_from: body.time
layout: '%Y-%m-%dT%H:%M:%S.%LZ'
# Parse Docker format
- type: json_parser
id: parser-docker
output: extract_metadata_from_filepath
timestamp:
parse_from: time
parse_from: body.time
layout: '%Y-%m-%dT%H:%M:%S.%LZ'
# Extract metadata from file path
- type: regex_parser
id: extract_metadata_from_filepath
regex: '^.*\/(?P<namespace>[^_]+)_(?P<pod_name>[^_]+)_(?P<uid>[a-f0-9\-]{36})\/(?P<container_name>[^\._]+)\/(?P<restart_count>\d+)\.log$'
parse_from: $$attributes["file.path"]
parse_from: attributes["file.path"]
# Move out attributes to Attributes
- type: metadata
attributes:
stream: 'EXPR($.stream)'
k8s.container.name: 'EXPR($.container_name)'
k8s.namespace.name: 'EXPR($.namespace)'
k8s.pod.name: 'EXPR($.pod_name)'
k8s.container.restart_count: 'EXPR($.restart_count)'
k8s.pod.uid: 'EXPR($.uid)'
# Clean up log body
- type: restructure
id: clean-up-log-body
ops:
- move:
from: log
to: $
- type: move
from: body.stream
to: attributes["log.iostream"]
- type: move
from: body.container_name
to: attributes["k8s.container.name"]
- type: move
from: body.namespace
to: attributes["k8s.namespace.name"]
- type: move
from: body.pod_name
to: attributes["k8s.pod.name"]
- type: move
from: body.restart_count
to: attributes["k8s.container.restart_count"]
- type: move
from: body.uid
to: attributes["k8s.pod.uid"]
- type: move
from: body.log
to: body
exporters:
logging:
loglevel: debug
Expand Down
53 changes: 28 additions & 25 deletions examples/kubernetes/otel-collector.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,18 @@ data:
id: get-format
routes:
- output: parser-docker
expr: '$$body matches "^\\{"'
expr: 'body matches "^\\{"'
- output: parser-crio
expr: '$$body matches "^[^ Z]+ "'
expr: 'body matches "^[^ Z]+ "'
- output: parser-containerd
expr: '$$body matches "^[^ Z]+Z"'
expr: 'body matches "^[^ Z]+Z"'
# Parse CRI-O format
- type: regex_parser
id: parser-crio
regex: '^(?P<time>[^ Z]+) (?P<stream>stdout|stderr) (?P<logtag>[^ ]*) (?P<log>.*)$'
output: extract_metadata_from_filepath
timestamp:
parse_from: time
parse_from: body.time
layout_type: gotime
layout: '2006-01-02T15:04:05.000000000-07:00'
# Parse CRI-Containerd format
Expand All @@ -41,39 +41,42 @@ data:
regex: '^(?P<time>[^ ^Z]+Z) (?P<stream>stdout|stderr) (?P<logtag>[^ ]*) (?P<log>.*)$'
output: extract_metadata_from_filepath
timestamp:
parse_from: time
parse_from: body.time
layout: '%Y-%m-%dT%H:%M:%S.%LZ'
# Parse Docker format
- type: json_parser
id: parser-docker
output: extract_metadata_from_filepath
timestamp:
parse_from: time
parse_from: body.time
layout: '%Y-%m-%dT%H:%M:%S.%LZ'
# Extract metadata from file path
- type: regex_parser
id: extract_metadata_from_filepath
regex: '^.*\/(?P<namespace>[^_]+)_(?P<pod_name>[^_]+)_(?P<uid>[a-f0-9\-]{36})\/(?P<container_name>[^\._]+)\/(?P<restart_count>\d+)\.log$'
parse_from: $$attributes["file.path"]
parse_from: attributes["log.file.path"]
# Move out attributes to Attributes
- type: metadata
attributes:
stream: 'EXPR($.stream)'
k8s.container.name: 'EXPR($.container_name)'
k8s.namespace.name: 'EXPR($.namespace)'
k8s.pod.name: 'EXPR($.pod_name)'
k8s.container.restart_count: 'EXPR($.restart_count)'
k8s.pod.uid: 'EXPR($.uid)'
# tag the resource level attribute in metadata
resource:
k8s.pod.uid: 'EXPR($.uid)'
# Clean up log body
- type: restructure
id: clean-up-log-body
ops:
- move:
from: log
to: $
- type: move
from: body.stream
to: attributes["log.iostream"]
- type: move
from: body.container_name
to: attributes["k8s.container.name"]
- type: move
from: body.namespace
to: attributes["k8s.namespace.name"]
- type: move
from: body.pod_name
to: attributes["k8s.pod.name"]
- type: move
from: body.restart_count
to: attributes["k8s.container.restart_count"]
- type: move
from: body.uid
to: attributes["k8s.pod.uid"]
- type: move
from: body.log
to: body

processors:
# k8sattributes processor to get the metadata from K8s
Expand Down