Skip to content

Commit 4e66213

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 4e66213

File tree

1 file changed

+81
-0
lines changed

1 file changed

+81
-0
lines changed

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

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,87 @@ 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+
include_file_path: true
694+
include_file_name: false
695+
operators:
696+
- type: container
697+
exporters:
698+
debug:
699+
verbosity: detailed
700+
service:
701+
pipelines:
702+
logs:
703+
receivers: [filelog]
704+
exporters: [debug]
705+
securityContext:
706+
runAsUser: 0
707+
seLinuxOptions:
708+
type: spc_t
709+
readOnlyRootFilesystem: true
710+
allowPrivilegeEscalation: false
711+
seccompProfile:
712+
type: RuntimeDefault
713+
capabilities:
714+
drop:
715+
- ALL
716+
volumeMounts:
717+
- name: varlogpods
718+
mountPath: /var/log/pods
719+
readOnly: true
720+
volumes:
721+
- name: varlogpods
722+
hostPath:
723+
path: /var/log/pods
724+
----
725+
<1> Configure a Security Context Constraint (SCC) to allow accessing files on the host
726+
<2> Assign the SCC to the collector Service Account (the OpenTelemetry Operator creates this Service Account)
727+
<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.
728+
648729
[id="journald-receiver_{context}"]
649730
== Journald Receiver
650731

0 commit comments

Comments
 (0)