From 362714a52aaa9f8954aa094800c62395d06ae945 Mon Sep 17 00:00:00 2001 From: Max Leonov Date: Fri, 21 Nov 2025 14:13:20 +0100 Subject: [PATCH] OBSDOCS-2819: Document how to scrape a custom log file from a pod filesystem --- modules/otel-receivers-filelog-receiver.adoc | 45 ++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/modules/otel-receivers-filelog-receiver.adoc b/modules/otel-receivers-filelog-receiver.adoc index e7f8ede51745..04289a5ddbba 100644 --- a/modules/otel-receivers-filelog-receiver.adoc +++ b/modules/otel-receivers-filelog-receiver.adoc @@ -32,3 +32,48 @@ include::snippets/technology-preview.adoc[] ---- <1> A list of file glob patterns that match the file paths to be read. <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. + +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: + +.OpenTelemetry Collector custom resource with the Filelog Receiver configured in sidecar mode +[source,yaml] +---- +apiVersion: opentelemetry.io/v1beta1 +kind: OpenTelemetryCollector +metadata: + name: filelog + namespace: otel-logging +spec: + mode: sidecar + volumeMounts: # <1> + - name: logs + mountPath: /var/log/app + config: + receivers: + filelog: + include: # <2> + - /var/log/app/*.log + operators: + - type: regex_parser + regex: '^(?P\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}) \[(?P\w+)\] (?P.*)$' + timestamp: + parse_from: attributes.timestamp + layout: '%Y-%m-%d %H:%M:%S' + processors: {} + exporters: + debug: + verbosity: detailed + service: + pipelines: + logs: + receivers: [filelog] + processors: [] + exporters: [debug] +---- +<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. +<2> Specifies file glob patterns for matching the log files to tail. This receiver watches these paths for new log entries. ++ +[IMPORTANT] +==== +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. +====