Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
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
...



We recommend that you select a method that suits your environment.



The advantage of using the open source fluent-bit is that the user can handle it by reading log files stored in the directory.






apiVersion: opentelemetry.io/v1alpha1
kind: Instrumentation
metadata:
name: {Instrumentation name}
spec:
exporter:
endpoint: {log-agent Service address}:4318
python:
image: ghcr.io/open-telemetry/opentelemetry-operator/autoinstrumentation-python:0.44b0
env:
- name: OTEL_LOGS_EXPORTER
value: otlp_proto_http
- name: OTEL_EXPORTER_OTLP_LOGS_ENDPOINT
value: {log-agent Service address}:4318/v1/logs
- name: OTEL_PYTHON_LOGGING_AUTO_INSTRUMENTATION_ENABLED
value: 'true'
# Used when you want to collect all Java applications for which the anotation value of the namespace is 'true'.
- name: OTEL_EXPORTER_OTLP_LOGS_HEADERS
value: app_token={Application Token},app_name={Application Name}instrumentation.opentelemetry.io/inject-python: '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: {python-application image}
imagePullPolicy: Always
...This is a method of installing into an existing application using the SDK provided by Opentelemetry. Logging in Python is currently under development at opentelemetry.
<dependency>
<groupId>io.opentelemetry.instrumentation</groupId>
<artifactId>opentelemetry-logback-appender-1.0</artifactId>
<version>2.0.0-alpha</version>
<scope>runtime</scope>
</dependency>runtimeOnly group: 'io.opentelemetry.instrumentation', name: 'opentelemetry-logback-appender-1.0', version: '2.0.0-alpha'<dependency>
<groupId>io.opentelemetry.instrumentation</groupId>
<artifactId>opentelemetry-log4j-appender-2.17</artifactId>
<version>OPENTELEMETRY_VERSION</version>
<scope>runtime</scope>
</dependency>
</dependencies>runtimeOnly("io.opentelemetry.instrumentation:opentelemetry-log4j-appender-2.17:OPENTELEMETRY_VERSION") ...
<appender name="OpenTelemetry"
class="io.opentelemetry.instrumentation.logback.appender.v1_0.OpenTelemetryAppender">
</appender>
...
<logger name="OTLP" additivity="false">
<appender-ref ref="OpenTelemetry"/>
<level value="INFO"/>
</logger><Configuration status="WARN" packages="io.opentelemetry.instrumentation.log4j.appender.v2_17">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout
pattern="%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} trace_id: %X{trace_id} span_id: %X{span_id} trace_flags: %X{trace_flags} - %msg%n"/>
</Console>
<OpenTelemetry name="OpenTelemetryAppender"/>
</Appenders>
<Loggers>
<Root>
<AppenderRef ref="OpenTelemetryAppender" level="All"/>
<AppenderRef ref="Console" level="All"/>
</Root>
</Loggers>
</Configuration>private static final Logger logger = LoggerFactory.getLogger("OTLP");
// Logging with a logger called OTLP. This can be changed
// If you set it to 'ALL' in the above document, you can log with console and opentelemetry....
# Required settings to export log
ENV OTEL_EXPORTER_OTLP_ENDPOINT=$OTEL_EXPORTER_OTLP_ENDPOINT
ENV OTEL_EXPORTER_OTLP_LOGS_ENDPOINT=$OTEL_EXPORTER_OTLP_LOGS_ENDPOINT
ENV OTEL_EXPORTER_OTLP_LOGS_HEADERS=$OTEL_EXPORTER_OTLP_LOGS_HEADERS
ENV OTEL_LOGS_EXPORTER=$OTEL_LOGS_EXPORTER
ENV OTEL_SERVICE_NAME=$OTEL_SERVICE_NAME
# None processing to not collect metrics and traces
ENV OTEL_METRICS_EXPORTER=none
ENV OTEL_TRACES_EXPORTER=none
# Download sdk
RUN wget -q https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v2.0.0/opentelemetry-javaagent.jar
ENTRYPOINT ["java", "-javaagent:opentelemetry-javaagent.jar", "-jar", "app.jar"]
...apiVersion: apps/v1
kind: Deployment
...
spec:
...
template:
spec:
containers:
- env:
# opentelemetry collector svc address (eg. http://log-agent-cocktail-log-agent.cocktail-addon:4318)
- name: OTEL_EXPORTER_OTLP_ENDPOINT
value: {log-agent Service address}:4318
# Log service address of opentelemetry collector (eg. http://log-agent-cocktail-log-agent.cocktail-addon:4318/v1/logs)
- name: OTEL_EXPORTER_OTLP_LOGS_ENDPOINT
value: {log-agent Service address}:4318/v1/logs
# Settings using opelemetry protocol
- name: OTEL_LOGS_EXPORTER
value: otlp
# 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
......
# flask 애플리케이션용 opentelemetry Sdk 다운로드
RUN pip install --upgrade pip && pip install opentelemetry-distro && opentelemetry-bootstrap -a install && pip install flask
# Log를 Export할 필수설정
ENV OTEL_EXPORTER_OTLP_ENDPOINT=$OTEL_EXPORTER_OTLP_ENDPOINT
ENV OTEL_EXPORTER_OTLP_LOGS_ENDPOINT=$OTEL_EXPORTER_OTLP_LOGS_ENDPOINT
ENV OTEL_EXPORTER_OTLP_LOGS_HEADERS=$OTEL_EXPORTER_OTLP_LOGS_HEADERS
ENV OTEL_SERVICE_NAME=$OTEL_SERVICE_NAME
ENV OTEL_LOGS_EXPORTER=$OTEL_LOGS_EXPORTER
# Python 애플리케이션 로깅을 위한 필수 설정
ENV OTEL_PYTHON_LOGGING_AUTO_INSTRUMENTATION_ENABLED=true
# metric과 trace를 수집하지 않기 위한 none 처리
ENV OTEL_METRICS_EXPORTER=none
ENV OTEL_TRACES_EXPORTER=none
...apiVersion: apps/v1
kind: Deployment
...
spec:
...
template:
spec:
containers:
- env:
# opentelemetry collector svc address (eg. http://log-agent-cocktail-log-agent.cocktail-addon:4318)
- name: OTEL_EXPORTER_OTLP_ENDPOINT
value: {log-agent Service address}:4318
# Log service address of opentelemetry collector (eg. http://log-agent-cocktail-log-agent.cocktail-addon:4318/v1/logs)
- name: OTEL_EXPORTER_OTLP_LOGS_ENDPOINT
value: {log-agent Service address}:4318/v1/logs
# Settings using opelemetry protocol
- name: OTEL_LOGS_EXPORTER
value: otlp_proto_http
# 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: {python-application image}
imagePullPolicy: Always
...










Fluent Bit is a lightweight log data collector that is used to collect and process data. By installing Flentbit as a sidecar in your application, you parse the application's logs and forward them to O
[SERVICE]
Flush 1
Log_Level info
Daemon off
Parsers_File parsers.conf
[INPUT]
Name tail
Path [The path to the log file where the log will be loaded]
[OUTPUT]
Name stdout
Match *
[FILTER]
Name parser
Match *
Key_Name log
Parser nginx
# Setting to preserve existing log messages before parsing (true: preservation)
Preserve_Key true
Reserve_Data true
# instrumentation_scope, service.name.. in body
[FILTER]
Name modify
Match *
Add service.name 'Application Name'
# Handled by user by inserting script
[FILTER]
Name lua
Match *
script rewrite.lua
call rewrite_tag
[OUTPUT]
Name opentelemetry
Match *
# Host log-agent-cocktail-log-agent.cocktail-addon
Host 'log-agent Service Address'
Port 4318
metrics_uri /v1/metrics
logs_uri /v1/logs
traces_uri /v1/traces
header app_token 'Token'
header app_name 'Application Name'
Log_response_payload True
tls off
tls.verify off
logs_body_key_attributes true[PARSER]
Name nginx
Format regex
Regex ^(?<remote>[^ ]*) (?<host>[^ ]*) (?<user>[^ ]*) \[(?<time>[^\]]*)\] "(?<method>\S+)(?: +(?<path>[^\"]*?)(?: +\S*)?)?" (?<code>[^ ]*) (?<size>[^ ]*)(?: "(?<referer>[^\"]*)" "(?<agent>[^\"]*)")
Time_Key time
Time_Format %d/%b/%Y:%H:%M:%S # A script that adds the value INFO to the value level if the code value is 200, and the value ERROR if it is not 200.
function rewrite_tag(tag, timestamp, record)
if record["code"] == "200" then
record["level"] = "INFO"
else
record["level"] = "ERROR"
end
return 1, timestamp, record
end

















