Examples

Flow examples

The following examples show some simple flows. For more examples that use filters, see Filter examples in Flows.

Flow with a single output

This Flow sends every message with the app: nginx label to the output called forward-output-sample.

apiVersion: logging.banzaicloud.io/v1beta1
kind: Flow
metadata:
  name: flow-sample
  namespace: default
spec:
  localOutputRefs:
    - forward-output-sample
  match:
    - select:
        labels:
          app: nginx

Flow with multiple outputs

This Flow sends every message with the app: nginx label to the gcs-output-sample and s3-output-example outputs.

apiVersion: logging.banzaicloud.io/v1beta1
kind: Flow
metadata:
  name: flow-sample
  namespace: default
spec:
  localOutputRefs:
    - gcs-output-sample
    - s3-output-example
  match:
    - select:
        labels:
          app: nginx

Logging examples

Simple Logging definition with default values.

apiVersion: logging.banzaicloud.io/v1beta1
kind: Logging
metadata:
  name: default-logging-simple
spec:
  fluentd: {}
  fluentbit: {}
  controlNamespace: default

Logging with TLS

Simple Logging definition with TLS encryption enabled.

apiVersion: logging.banzaicloud.io/v1beta1
kind: Logging
metadata:
  name: default-logging-tls
  namespace: logging
spec:
  fluentd:
    disablePvc: true
    tls:
      enabled: true
      secretName: fluentd-tls
      sharedKey: asdadas
  fluentbit:
    tls:
      enabled: true
      secretName: fluentbit-tls
      sharedKey: asdadas
  controlNamespace: logging

Output examples

Simple file output

Defines a file output with timestamped log files.

apiVersion: logging.banzaicloud.io/v1beta1
kind: Output
metadata:
  name: file-output-sample
spec:
  file:
    path: /tmp/logs/${tag}/%Y/%m/%d/%H.%M
    buffer:
      timekey: 1m
      timekey_wait: 10s
      timekey_use_utc: true

Drop messages into dev/null output

Creates a dev/null output that can be the destination of messages you want to drop explicitly.

CAUTION:

Messages sent to this output are irrevocably lost forever.
apiVersion: logging.banzaicloud.io/v1beta1
kind: Output
metadata:
  name: null-output-sample
spec:
  nullout: {}

S3 output

Defines an Amazon S3 output to store your logs in a bucket.

apiVersion: logging.banzaicloud.io/v1beta1
kind: Output
metadata:
  name: s3-output-sample
spec:
  s3:
    aws_key_id:
      valueFrom:
        secretKeyRef:
          name: s3-secret
          key: awsAccessKeyId
    aws_sec_key:
      valueFrom:
        secretKeyRef:
          name: s3-secret
          key: awsSecretAccessKey
    s3_bucket: example-logging-bucket
    s3_region: eu-central-1
    path: logs/${tag}/%Y/%m/%d/
    buffer:
      timekey: 1m
      timekey_wait: 10s
      timekey_use_utc: true
    format:
      type: json

GCS output

Defines a Google Cloud Storage output to store your logs.

apiVersion: logging.banzaicloud.io/v1beta1
kind: Output
metadata:
  name: s3-output-sample
spec:
  s3:
    aws_key_id:
      valueFrom:
        secretKeyRef:
          name: s3-secret
          key: awsAccessKeyId
    aws_sec_key:
      valueFrom:
        secretKeyRef:
          name: s3-secret
          key: awsSecretAccessKey
    s3_bucket: example-logging-bucket
    s3_region: eu-central-1
    path: logs/${tag}/%Y/%m/%d/
    buffer:
      timekey: 1m
      timekey_wait: 10s
      timekey_use_utc: true
    format:
      type: json