Path: blob/main/examples/java/json-logging-logback/k8s/collector-configmap.yaml
401 views
apiVersion: v11kind: ConfigMap2metadata:3name: otel-collector-config4data:5otel-collector-config.yaml: |-6receivers:7otlp:8protocols:9grpc:10endpoint: 0.0.0.0:431711http:12endpoint: 0.0.0.0:431813prometheus/collector: # needed if you use the docker-lgtm image14config:15scrape_configs:16- job_name: 'opentelemetry-collector'17static_configs:18- targets: [ 'localhost:8888' ]19filelog/json-logback:20include:21- /var/log/pods/*/*/*.log22include_file_path: true23operators:24- id: container-parser25type: container26- id: router27type: router28routes:29- output: json_parser30expr: 'body matches "\\{[^{}]*\\}" == true'31- id: json_parser32type: json_parser33on_error: drop_quiet34body: attributes.formattedMessage35timestamp:36parse_from: attributes.timestamp37layout_type: 'epoch'38layout: 'ms'39severity:40parse_from: attributes.level41trace:42trace_id:43parse_from: attributes.mdc.trace_id44span_id:45parse_from: attributes.mdc.span_id46trace_flags:47parse_from: attributes.mdc.trace_flags48scope_name:49parse_from: attributes.loggerName50- id: move_service_namespace51type: move52if: 'attributes.mdc["service.namespace"] != nil'53from: attributes.mdc["service.namespace"]54to: resource["service.namespace"]55- id: move_service_name56type: move57from: attributes.mdc["service.name"]58to: resource["service.name"]59- id: move_service_version60type: move61from: attributes.mdc["service.version"]62to: resource["service.version"]63- id: move_service_instance_id64type: move65if: 'attributes.mdc["service.instance.id"] != nil'66from: attributes.mdc["service.instance.id"]67to: resource["service.instance.id"]68- id: move_deployment_environment69type: move70if: 'attributes.mdc["deployment.environment"] != nil'71from: attributes.mdc["deployment.environment"]72to: resource["deployment.environment"]73- id: move_thread_name74type: move75from: attributes.threadName76to: attributes["thread.name"]77- id: move_throwable_class_name78type: move79if: "attributes.throwable?.className != nil"80from: attributes.throwable.className81to: attributes["exception.type"]82- id: move_throwable_message83type: move84if: "attributes.throwable?.message != nil"85from: attributes.throwable.message86to: attributes["exception.message"]87# FIXME "stepArray" is a json array eroding the visualization in Loki88# [{ "className": "a.b.C", "methodName": "do", "fileName": "C.java", "lineNumber": 123},...]89# It would help if logBack had a raw toString of the stack trace90- id: move_throwable_stack_trace91type: move92if: "attributes.throwable?.stepArray != nil"93from: attributes.throwable.stepArray94to: attributes["exception.stacktrace"]95- id: remove_throwable96type: remove97field: attributes.throwable98- id: remove_logger_name99type: remove100field: attributes.loggerName101- id: remove_timestamp102type: remove103field: attributes.timestamp104- id: remove_observed_timestamp105type: remove106field: attributes["observed.timestamp"]107- id: remove_level108type: remove109field: attributes.level110- id: remove_detected_level111type: remove112field: attributes["detected.level"]113- id: remove_mdc114type: remove115field: attributes.mdc116- id: remove_context117type: remove118field: attributes.context119- id: remove_formattedMessage120type: remove121field: attributes.formattedMessage122- id: remove_logtag123type: remove124field: attributes.logtag125- id: remove_file126type: remove127field: attributes["log.file.path"]128- id: remove_filename129type: remove130field: attributes["log.file.name"]131- id: remove_stream132type: remove133field: attributes["log.iostream"]134- id: remove_time135type: remove136field: attributes.time137138processors:139batch:140resourcedetection:141detectors: [ "env", "system" ]142override: false143144exporters:145otlphttp/metrics:146endpoint: http://localhost:9090/api/v1/otlp147otlphttp/traces:148endpoint: http://localhost:4418149otlphttp/logs:150endpoint: http://localhost:3100/otlp151debug/metrics:152verbosity: detailed153debug/traces:154verbosity: detailed155debug/logs:156verbosity: detailed157nop:158159service:160pipelines:161traces:162receivers: [ otlp ]163processors: [ batch ]164exporters: [ otlphttp/traces ]165metrics:166receivers: [ otlp, prometheus/collector ]167processors: [ batch ]168exporters: [ otlphttp/metrics ]169logs/otlp:170receivers: [ otlp ]171processors: [ batch ]172exporters: [ otlphttp/logs ]173logs/json-elastic:174receivers: [ filelog/json-logback ]175processors: [ batch ]176exporters: [ otlphttp/logs ]177# exporters: [ otlphttp/logs, debug/logs ] # Uncomment this line to enable debug logging178179180181182