Skip to content

Commit c1ddd6a

Browse files
committed
OBSDOCS-2819: Document how to scrape a custom log file from a pod filesystem
1 parent f3c6298 commit c1ddd6a

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

modules/otel-receivers-filelog-receiver.adoc

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,48 @@ include::snippets/technology-preview.adoc[]
3232
----
3333
<1> A list of file glob patterns that match the file paths to be read.
3434
<2> An array of Operators. Each Operator performs a simple task such as parsing a timestamp or JSON. To process logs into a desired format, chain the Operators together.
35+
36+
To collect logs from application containers, you can use this receiver with sidecar injection. The {OTELOperator} allows injecting an OpenTelemetry Collector as a sidecar container into a application pod. This approach is useful when your application writes logs to files within the container filesystem. To access the generated files, both pods require a shared volume for the application container and the sidecar Collector. This receiver can then tail log files and apply Operators to parse and transform the logs. To use this receiver in sidecar mode to collect logs from application containers, you must configure volume mounts in the `OpenTelemetryCollector` custom resource. The Collector requires access to the log files through a shared volume, such as `emptyDir`, that is mounted in both the application container and the sidecar Collector container. The following is a complete example of this approach:
37+
38+
.OpenTelemetry Collector custom resource with the Filelog Receiver configured in sidecar mode
39+
[source,yaml]
40+
----
41+
apiVersion: opentelemetry.io/v1beta1
42+
kind: OpenTelemetryCollector
43+
metadata:
44+
name: filelog
45+
namespace: otel-logging
46+
spec:
47+
mode: sidecar
48+
volumeMounts: # <1>
49+
- name: logs
50+
mountPath: /var/log/app
51+
config:
52+
receivers:
53+
filelog:
54+
include: # <2>
55+
- /var/log/app/*.log
56+
operators:
57+
- type: regex_parser
58+
regex: '^(?P<timestamp>\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}) \[(?P<level>\w+)\] (?P<message>.*)$'
59+
timestamp:
60+
parse_from: attributes.timestamp
61+
layout: '%Y-%m-%d %H:%M:%S'
62+
processors: {}
63+
exporters:
64+
debug:
65+
verbosity: detailed
66+
service:
67+
pipelines:
68+
logs:
69+
receivers: [filelog]
70+
processors: []
71+
exporters: [debug]
72+
----
73+
<1> Defines the volume mount that the sidecar Collector uses to access the target log files. This volume must match the volume name defined in the application deployment.
74+
<2> Specifies file glob patterns for matching the log files to tail. The Filelog Receiver watches these paths for new log entries.
75+
+
76+
[IMPORTANT]
77+
====
78+
The `volumeMounts` field in the `OpenTelemetryCollector` custom resource is critical for the sidecar to access log files. The volume specified here must be defined in the application's `Deployment` or `Pod` specification. Both the application container and the sidecar collector must mount the same volume.
79+
====

0 commit comments

Comments
 (0)