Skip to content

Commit

Permalink
Update examples that should have changed with update to v0.28.0 (#9019)
Browse files Browse the repository at this point in the history
  • Loading branch information
djaglowski authored Apr 4, 2022
1 parent 1e4e103 commit 3235bc0
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 47 deletions.
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

0 comments on commit 3235bc0

Please sign in to comment.