Skip to content

How to disable annotation collection with rancher-logging?

Article Number: 000022101

Environment

SUSE Rancher Prime - All versions

Rancher-logging-105.3.x+

Procedure

  • There could be situations where users might want to disable annotation collection with rancher-logging in order to reduce the amount of data being transferred on the output.
  • Disabling annotation collection in the logs can be achieved by customising a record_transformer filter plugin in the ClusterFlow/Flow as shown in the example below:
apiVersion: logging.banzaicloud.io/v1beta1
kind: ClusterOutput
metadata:
 name: test-output
 namespace: cattle-logging-system
spec:
 file:
    path: /tmp/logs/${tag}/%Y/%m/%d/%H.%M
    buffer:
      timekey: 1m
      timekey_wait: 10s
      timekey_use_utc: true
---
apiVersion: logging.banzaicloud.io/v1beta1
kind: ClusterFlow
metadata:
  name: drop-annotations
  namespace: cattle-logging-system
spec:
  filters:
    - record_transformer:
        remove_keys: "$.kubernetes.annotations"
  globalOutputRefs:
    - test-output
  • Verify that the annotations are not collected from the Fluentd logs. In the example shown above, the logs from path /tmp/logs/ stored inside rancher-logging-root-fluentd-0 pod can be reviewed. Below is an example of such log snippet that does not collect annotation:
2025-10-14T08:48:45+00:00       kubernetes.var.log.containers.test-logging-pod_cattle-logging-system_sak-8ee60280b8735d9f14f81a7ce3fb4e58985da1cc419d2feb6ec0b1b8320b43a6.log   {"time":"2025-10-14T08:48:45.108926277Z","stream":"stdout","logtag":"F","message":"Hello World from Rancher Logging!","kubernetes":{"pod_name":"test-logging-pod","namespace_name":"cattle-logging-system","pod_id":"f4f2e04c-8fdf-4564-aad9-992071724ef2","labels":{"logging-test":"true","objectset.rio.cattle.io/hash":"a933de1454495e4c5d41a35ca4b9cb9caf7f1181"},"host":"abhishekh-do-abhishekh-do-rn7hx-9xwxt","container_name":"sak","docker_id":"8ee60280b8735d9f14f81a7ce3fb4e58985da1cc419d2feb6ec0b1b8320b43a6","container_hash":"docker.io/rancherlabs/swiss-army-knife@sha256:af25a3ace6269adb9e494b693644bc2f897ec872076d78f78bc5ded69f2ee222","container_image":"docker.io/rancherlabs/swiss-army-knife:latest"},"kubernetes_namespace":{"name":"cattle-logging-system","labels":{"kubernetes.io/metadata.name":"cattle-logging-system"}}}