-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfilelogreceiver.yml
117 lines (110 loc) · 3.21 KB
/
filelogreceiver.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
receivers:
otlp:
protocols:
grpc:
filelog:
# ingest app log (proprietary format)
include: [ logs/otel.log ]
operators:
# parse JSON logs from app
- type: json_parser
# conform timestamp
timestamp:
parse_from: attributes["@timestamp"]
layout_type: strptime
location: UTC
layout: '%Y-%m-%dT%H:%M:%S.%fZ'
# conform severity
severity:
parse_from: attributes.level
# conform body
body: attributes.message
# conform trace meta
trace:
trace_id:
parse_from: attributes.trace_id
span_id:
parse_from: attributes.span_id
# conform scope
scope_name:
parse_from: attributes["code.namespace"]
# clean up raw attributes parsed above
- type: remove
field: attributes["@timestamp"]
- type: remove
field: attributes.level
- type: remove
field: attributes.message
- type: remove
field: attributes.trace_id
if: attributes.trace_id != nil
- type: remove
field: attributes.span_id
if: attributes.span_id != nil
# service.name attribute needs to be on the resource
- type: move
from: attributes["service.name"]
to: resource["service.name"]
# parse stack trace to extract exception message
- type: regex_parser
parse_from: attributes["exception.stacktrace"]
regex: '^\S*:\s(?P<exception_message>.*)\n.*'
if: attributes["exception.stacktrace"] != nil
- type: move
from: attributes.exception_message
to: attributes["exception.message"]
if: attributes["exception_message"] != nil
# remove (currently) unused fields
- type: remove
field: attributes.level_value
- type: remove
field: attributes["@version"]
- type: remove
field: attributes["thread_name"]
if: attributes.thread_name != nil
- type: remove
field: attributes.trace_flags
if: attributes.trace_flags != nil
processors:
batch:
# remove "logback.mdc" prefix from baggage attributes
transform/log:
error_mode: ignore
log_statements:
- context: log
statements:
- replace_all_patterns(attributes, "key", "logback\\.mdc\\.baggage\\.", "baggage.")
# drop otlp logs in this mode
filter/otlplog:
logs:
exclude:
match_type: regexp
bodies:
- .*
exporters:
logging:
verbosity: detailed
otlphttp/elastic:
endpoint: "${ELASTIC_APM_SERVER_ENDPOINT}"
headers:
# Elastic APM Server secret token
Authorization: "Bearer ${ELASTIC_APM_SERVER_SECRET}"
service:
pipelines:
traces:
receivers: [ otlp ]
processors: [ batch ]
exporters: [ logging, otlphttp/elastic]
metrics:
receivers: [ otlp ]
processors: [ batch ]
exporters: [ logging, otlphttp/elastic]
logs/file:
receivers: [ filelog ]
processors: [ transform/log, batch ]
exporters: [ logging, otlphttp/elastic]
# drop otlp logs in this mode
logs/otlp:
receivers: [ otlp ]
processors: [ filter/otlplog ]
exporters: [ logging ]