Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
aos
GitHub Repository: aos/docker-otel-lgtm
Path: blob/main/examples/java/json-logging-logback/k8s/collector-configmap.yaml
401 views
1
apiVersion: v1
2
kind: ConfigMap
3
metadata:
4
name: otel-collector-config
5
data:
6
otel-collector-config.yaml: |-
7
receivers:
8
otlp:
9
protocols:
10
grpc:
11
endpoint: 0.0.0.0:4317
12
http:
13
endpoint: 0.0.0.0:4318
14
prometheus/collector: # needed if you use the docker-lgtm image
15
config:
16
scrape_configs:
17
- job_name: 'opentelemetry-collector'
18
static_configs:
19
- targets: [ 'localhost:8888' ]
20
filelog/json-logback:
21
include:
22
- /var/log/pods/*/*/*.log
23
include_file_path: true
24
operators:
25
- id: container-parser
26
type: container
27
- id: router
28
type: router
29
routes:
30
- output: json_parser
31
expr: 'body matches "\\{[^{}]*\\}" == true'
32
- id: json_parser
33
type: json_parser
34
on_error: drop_quiet
35
body: attributes.formattedMessage
36
timestamp:
37
parse_from: attributes.timestamp
38
layout_type: 'epoch'
39
layout: 'ms'
40
severity:
41
parse_from: attributes.level
42
trace:
43
trace_id:
44
parse_from: attributes.mdc.trace_id
45
span_id:
46
parse_from: attributes.mdc.span_id
47
trace_flags:
48
parse_from: attributes.mdc.trace_flags
49
scope_name:
50
parse_from: attributes.loggerName
51
- id: move_service_namespace
52
type: move
53
if: 'attributes.mdc["service.namespace"] != nil'
54
from: attributes.mdc["service.namespace"]
55
to: resource["service.namespace"]
56
- id: move_service_name
57
type: move
58
from: attributes.mdc["service.name"]
59
to: resource["service.name"]
60
- id: move_service_version
61
type: move
62
from: attributes.mdc["service.version"]
63
to: resource["service.version"]
64
- id: move_service_instance_id
65
type: move
66
if: 'attributes.mdc["service.instance.id"] != nil'
67
from: attributes.mdc["service.instance.id"]
68
to: resource["service.instance.id"]
69
- id: move_deployment_environment
70
type: move
71
if: 'attributes.mdc["deployment.environment"] != nil'
72
from: attributes.mdc["deployment.environment"]
73
to: resource["deployment.environment"]
74
- id: move_thread_name
75
type: move
76
from: attributes.threadName
77
to: attributes["thread.name"]
78
- id: move_throwable_class_name
79
type: move
80
if: "attributes.throwable?.className != nil"
81
from: attributes.throwable.className
82
to: attributes["exception.type"]
83
- id: move_throwable_message
84
type: move
85
if: "attributes.throwable?.message != nil"
86
from: attributes.throwable.message
87
to: attributes["exception.message"]
88
# FIXME "stepArray" is a json array eroding the visualization in Loki
89
# [{ "className": "a.b.C", "methodName": "do", "fileName": "C.java", "lineNumber": 123},...]
90
# It would help if logBack had a raw toString of the stack trace
91
- id: move_throwable_stack_trace
92
type: move
93
if: "attributes.throwable?.stepArray != nil"
94
from: attributes.throwable.stepArray
95
to: attributes["exception.stacktrace"]
96
- id: remove_throwable
97
type: remove
98
field: attributes.throwable
99
- id: remove_logger_name
100
type: remove
101
field: attributes.loggerName
102
- id: remove_timestamp
103
type: remove
104
field: attributes.timestamp
105
- id: remove_observed_timestamp
106
type: remove
107
field: attributes["observed.timestamp"]
108
- id: remove_level
109
type: remove
110
field: attributes.level
111
- id: remove_detected_level
112
type: remove
113
field: attributes["detected.level"]
114
- id: remove_mdc
115
type: remove
116
field: attributes.mdc
117
- id: remove_context
118
type: remove
119
field: attributes.context
120
- id: remove_formattedMessage
121
type: remove
122
field: attributes.formattedMessage
123
- id: remove_logtag
124
type: remove
125
field: attributes.logtag
126
- id: remove_file
127
type: remove
128
field: attributes["log.file.path"]
129
- id: remove_filename
130
type: remove
131
field: attributes["log.file.name"]
132
- id: remove_stream
133
type: remove
134
field: attributes["log.iostream"]
135
- id: remove_time
136
type: remove
137
field: attributes.time
138
139
processors:
140
batch:
141
resourcedetection:
142
detectors: [ "env", "system" ]
143
override: false
144
145
exporters:
146
otlphttp/metrics:
147
endpoint: http://localhost:9090/api/v1/otlp
148
otlphttp/traces:
149
endpoint: http://localhost:4418
150
otlphttp/logs:
151
endpoint: http://localhost:3100/otlp
152
debug/metrics:
153
verbosity: detailed
154
debug/traces:
155
verbosity: detailed
156
debug/logs:
157
verbosity: detailed
158
nop:
159
160
service:
161
pipelines:
162
traces:
163
receivers: [ otlp ]
164
processors: [ batch ]
165
exporters: [ otlphttp/traces ]
166
metrics:
167
receivers: [ otlp, prometheus/collector ]
168
processors: [ batch ]
169
exporters: [ otlphttp/metrics ]
170
logs/otlp:
171
receivers: [ otlp ]
172
processors: [ batch ]
173
exporters: [ otlphttp/logs ]
174
logs/json-elastic:
175
receivers: [ filelog/json-logback ]
176
processors: [ batch ]
177
exporters: [ otlphttp/logs ]
178
# exporters: [ otlphttp/logs, debug/logs ] # Uncomment this line to enable debug logging
179
180
181
182