Skip to content

Commit 80d5a4b

Browse files
TRACING-5422: Add an example OpenTelemetry Collector CR with filelog receiver that parses OpenShift cluster logs
Signed-off-by: Andreas Gerstmayr <agerstmayr@redhat.com>
1 parent 53b0c51 commit 80d5a4b

File tree

1 file changed

+84
-0
lines changed

1 file changed

+84
-0
lines changed

observability/otel/otel-collector/otel-collector-receivers.adoc

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,90 @@ include::snippets/technology-preview.adoc[]
645645
<1> A list of file glob patterns that match the file paths to be read.
646646
<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.
647647

648+
.OpenTelemetry Collector custom resource with enabled Filelog Receiver that parses OpenShift cluster logs
649+
[source,yaml]
650+
----
651+
apiVersion: security.openshift.io/v1
652+
kind: SecurityContextConstraints
653+
metadata:
654+
name: otel-clusterlogs-collector-scc <1>
655+
allowPrivilegedContainer: false
656+
requiredDropCapabilities:
657+
- ALL
658+
allowHostDirVolumePlugin: true
659+
volumes:
660+
- configMap
661+
- emptyDir
662+
- hostPath
663+
- projected
664+
- secret
665+
defaultAllowPrivilegeEscalation: false
666+
allowPrivilegeEscalation: false
667+
runAsUser:
668+
type: RunAsAny
669+
seLinuxContext:
670+
type: RunAsAny
671+
readOnlyRootFilesystem: true
672+
forbiddenSysctls:
673+
- '*'
674+
seccompProfiles:
675+
- runtime/default
676+
users:
677+
- system:serviceaccount:observability:clusterlogs-collector <2>
678+
---
679+
apiVersion: opentelemetry.io/v1beta1
680+
kind: OpenTelemetryCollector
681+
metadata:
682+
name: clusterlogs
683+
namespace: observability
684+
spec:
685+
mode: daemonset
686+
config:
687+
receivers:
688+
filelog:
689+
include:
690+
- "/var/log/pods/*/*/*.log"
691+
exclude:
692+
- "/var/log/pods/*/otc-container/*.log" <3>
693+
- "/var/log/pods/*/*/*.gz"
694+
- "/var/log/pods/*/*/*.log.*"
695+
- "/var/log/pods/*/*/*.tmp"
696+
include_file_path: true
697+
include_file_name: false
698+
operators:
699+
- type: container
700+
exporters:
701+
debug:
702+
verbosity: detailed
703+
service:
704+
pipelines:
705+
logs:
706+
receivers: [filelog]
707+
exporters: [debug]
708+
securityContext:
709+
runAsUser: 0
710+
seLinuxOptions:
711+
type: spc_t
712+
readOnlyRootFilesystem: true
713+
allowPrivilegeEscalation: false
714+
seccompProfile:
715+
type: RuntimeDefault
716+
capabilities:
717+
drop:
718+
- ALL
719+
volumeMounts:
720+
- name: varlogpods
721+
mountPath: /var/log/pods
722+
readOnly: true
723+
volumes:
724+
- name: varlogpods
725+
hostPath:
726+
path: /var/log/pods
727+
----
728+
<1> Configure a Security Context Constraint (SCC) to allow accessing files on the host
729+
<2> Assign the SCC to the collector Service Account (the OpenTelemetry Operator creates this Service Account)
730+
<3> Exclude logs from the collector container. In this example configuration, the container prints all cluster logs to stdout for demonstration purposes, which would create a loop.
731+
648732
[id="journald-receiver_{context}"]
649733
== Journald Receiver
650734

0 commit comments

Comments
 (0)