You can leverage Custom Resources to configure the OpenTelemetry auto-instrumentation library and add annotations to your workloads to easily collect logs.


apiVersion: opentelemetry.io/v1alpha1
kind: Instrumentation
metadata:
name: {Instrumentation name}
spec:
exporter:
endpoint: {log-agent Service address}:4318
java:
env:
- name: OTEL_LOGS_EXPORTER
value: otlp
- name: OTEL_METRICS_EXPORTER
value: none
- name: OTEL_TRACES_EXPORTER
value: otlp
- name: OTEL_EXPORTER_OTLP_PROTOCOL
value: http/protobuf
# Used when you want to collect all Java applications for which the anotation value of the namespace is 'true'..
- name: OTEL_EXPORTER_OTLP_LOGS_ENDPOINT
value: {log-agent Service address}:4318/v1/logsinstrumentation.opentelemetry.io/inject-java: 'true'apiVersion: apps/v1
kind: Deployment
...
spec:
...
template:
spec:
containers:
- env:
# Application name
- name: OTEL_SERVICE_NAME
value: {Application name}
# Settings for authentication
- name: OTEL_EXPORTER_OTLP_LOGS_HEADERS
value: app_token={Application token},app_name={Application name}
image: {java-application image}
imagePullPolicy: Always
...


