diff --git a/examples/kubernetes/README.md b/examples/kubernetes/README.md index d7e8c87ff39d..7b8e3f3a6804 100644 --- a/examples/kubernetes/README.md +++ b/examples/kubernetes/README.md @@ -4,12 +4,18 @@ This demo is a sample app to build the collector and exercise its kubernetes log ## Build and Run +### Kubernetes + +Switch to this directory and run following command: `kubectl apply -n -f otel-collector.yaml` + +### Docker Compose + Two steps are required to build and run the demo: 1. Build latest docker image in main repository directory `make docker-otelcontribcol` 1. Switch to this directory and run `docker-compose up` -## Description +#### Description `varlogpods` contains example log files placed in kubernetes-like directory structure. Each of the directory has different formatted logs in one of three formats (either `CRI-O`, `CRI-Containerd` or `Docker`). diff --git a/examples/kubernetes/otel-collector.yaml b/examples/kubernetes/otel-collector.yaml new file mode 100644 index 000000000000..eb18509d0870 --- /dev/null +++ b/examples/kubernetes/otel-collector.yaml @@ -0,0 +1,153 @@ +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: otel-collector-config +data: + config.yaml: |- + receivers: + filelog: + include: + # - /var/log/pods/namespace_pod-name_pod-uid/container-name/*.log + - /var/log/pods/*/*/*.log + exclude: + # - /var/log/pods/namespace_pod-name_pod-uid/container-name/*.log + - /var/log/pods/*/otel-collector/*.log + start_at: beginning + include_file_path: true + include_file_name: false + operators: + # Find out which format is used by kubernetes + - type: router + id: get-format + routes: + - output: parser-docker + expr: '$$record matches "^\\{"' + - output: parser-crio + expr: '$$record matches "^[^ Z]+ "' + - output: parser-containerd + expr: '$$record matches "^[^ Z]+Z"' + # Parse CRI-O format + - type: regex_parser + id: parser-crio + regex: '^(?P