From c8a7ad6651047897d85224c96edc871dda0c42c3 Mon Sep 17 00:00:00 2001 From: "tomas.panik" Date: Fri, 1 Jul 2022 10:55:42 +0200 Subject: [PATCH 1/4] NH-9834: Adding collection of container logs --- build/docker/Dockerfile | 1 + build/logs-otel-collector-config.yaml | 169 ++++++++++++++++++ ...nighthawk-swi-opentelemetry-collector.yaml | 3 +- deploy/k8s/manifest.yaml | 89 ++++++++- tests/deploy/base/kustomization.yaml | 1 + .../base/patch-logs-apply-env-variables.yaml | 22 +++ 6 files changed, 283 insertions(+), 2 deletions(-) create mode 100644 build/logs-otel-collector-config.yaml create mode 100644 tests/deploy/base/patch-logs-apply-env-variables.yaml diff --git a/build/docker/Dockerfile b/build/docker/Dockerfile index dba7f374..0182c328 100644 --- a/build/docker/Dockerfile +++ b/build/docker/Dockerfile @@ -25,6 +25,7 @@ ENV SCRAPE_INTERVAL="60s" ENV OTEL_ENVOY_ADDRESS_TLS_INSECURE="false" COPY /build/otel-collector-config.yaml /opt/default-config.yaml +COPY /build/logs-otel-collector-config.yaml /opt/log-config.yaml ENTRYPOINT ["/swi-otelcol"] CMD ["--config=/opt/default-config.yaml"] diff --git a/build/logs-otel-collector-config.yaml b/build/logs-otel-collector-config.yaml new file mode 100644 index 00000000..a9169556 --- /dev/null +++ b/build/logs-otel-collector-config.yaml @@ -0,0 +1,169 @@ +exporters: + otlp: + endpoint: ${OTEL_ENVOY_ADDRESS} + tls: + insecure: ${OTEL_ENVOY_ADDRESS_TLS_INSECURE} + headers: + "Authorization": "Bearer ${SOLARWINDS_API_TOKEN}" +extensions: + health_check: {} + +processors: + groupbyattrs/all: + keys: + - k8s.container.name + - k8s.namespace.name + - k8s.pod.name + - k8s.pod.uid + + resource: + attributes: + + # Collector and Manifest version + - key: sw.k8s.agent.manifest.version + value: "1.0" + action: insert + + # Cluster + - key: sw.k8s.cluster.uid + value: ${CLUSTER_UID} + action: insert + + - key: k8s.cluster.name + value: ${CLUSTER_NAME} + action: insert + + # Node + - key: k8s.node.name + value: ${NODE_NAME} + action: insert + + batch: + send_batch_size: 8192 + send_batch_max_size: 8192 + timeout: 1s +receivers: + filelog: + include: [ /var/log/pods/*/*/*.log ] + # Exclude collector container's logs. The file format is /var/log/pods/__//.log + exclude: [ "/var/log/pods/${POD_NAMESPACE}_${POD_NAME}*_*/swi-opentelemetry-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: 'body matches "^\\{"' + - output: parser-crio + expr: 'body matches "^[^ Z]+ "' + - output: parser-containerd + expr: 'body matches "^[^ Z]+Z"' + # Parse CRI-O format + - type: regex_parser + id: parser-crio + regex: '^(?P