Chapter 5. Fine-tune log forwarding


Adjust rate limits, delivery behavior, collector log levels, and resource limits to optimize log forwarding performance for your workload.

5.1. Configure rate limits

You can configure rate limits on inputs and outputs to control log forwarding volume and prevent resource exhaustion. Rate limits specify the maximum number of log records per second that the collector can process. When the rate limit is exceeded, the collector drops excess log records.

Prerequisites

  • You have a working ClusterLogForwarder custom resource (CR).
  • You have cluster-admin permissions.

Procedure

  1. Configure rate limits on inputs, outputs, or both.

    apiVersion: observability.openshift.io/v1
    kind: ClusterLogForwarder
    metadata:
      name: instance
      namespace: openshift-logging
    spec:
      serviceAccount:
        name: collector
      inputs:
      - name: limited-app-logs
        type: application
        application:
          tuning:
            rateLimitPerContainer:
              maxRecordsPerSecond: 100
      outputs:
      - name: limited-splunk
        type: splunk
        splunk:
          url: https://splunk.example.com:8088
          authentication:
            token:
              key: token
              secretName: splunk-secret
        rateLimit:
          maxRecordsPerSecond: 1000
      pipelines:
      - name: app-to-splunk
        inputRefs:
        - limited-app-logs
        outputRefs:
        - limited-splunk
    Input rate limit (inputs[].application.tuning.rateLimitPerContainer)

    Limits the number of log records per second from each container that matches this input. This is a per-container limit. For example, if you set maxRecordsPerSecond: 100 and 10 containers match the input selector, the total input rate could be up to 1000 records per second (100 per container × 10 containers).

    Use case: Site reliability engineers can use input rate limits to prevent noisy applications from overwhelming the log collector and consuming excessive cluster resources.

    Output rate limit (outputs[].rateLimit)

    Limits the total number of log records per second that the collector forwards to this output from a single collector pod. This is an aggregate limit across all pipelines that reference this output. Generally, one collector pod runs per cluster node.

    Use case: Developers can use output rate limits to stay within the ingestion quotas imposed by third-party log aggregation services, preventing overage charges or throttling.

    Important

    When rate limits are exceeded, the collector drops log records. The collector increments the observability_log_forwarder_output_rate_limited_total metric for each dropped record. Monitor this metric to determine if your rate limits are too restrictive.

    Rate limit only on output

    spec:
      outputs:
      - name: rate-limited-kafka
        type: kafka
        kafka:
          brokers:
          - kafka.example.com:9092
          topic: logs
        rateLimit:
          maxRecordsPerSecond: 5000
      pipelines:
      - name: all-logs-to-kafka
        inputRefs:
        - application
        - infrastructure
        outputRefs:
        - rate-limited-kafka

    Rate limit only on input

    spec:
      inputs:
      - name: high-volume-namespace
        type: application
        application:
          includes:
          - namespace: "production"
          tuning:
            rateLimitPerContainer:
              maxRecordsPerSecond: 500
      pipelines:
      - name: production-to-loki
        inputRefs:
        - high-volume-namespace
        outputRefs:
        - default-lokistack

    Different rate limits for different outputs

    spec:
      outputs:
      - name: expensive-splunk
        type: splunk
        splunk:
          url: https://splunk.example.com:8088
          authentication:
            token:
              key: token
              secretName: splunk-secret
        rateLimit:
          maxRecordsPerSecond: 500
      - name: cheap-s3
        type: s3
        s3:
          url: https://s3.us-east-1.amazonaws.com
          bucket: log-archive
        rateLimit:
          maxRecordsPerSecond: 10000
      pipelines:
      - name: critical-to-splunk
        inputRefs:
        - audit
        outputRefs:
        - expensive-splunk
      - name: bulk-to-s3
        inputRefs:
        - application
        - infrastructure
        outputRefs:
        - cheap-s3
  2. Apply the updated ClusterLogForwarder CR by running the following command:

    $ oc apply -f <filename>.yaml

Verification

  • Verify that the collector pods restarted by running the following command:

    $ oc get pods -n openshift-logging -l app.kubernetes.io/component=collector

5.2. Tune log payloads and delivery

The tuning spec in the ClusterLogForwarder custom resource (CR) provides a means of configuring your deployment to prioritize either throughput or durability of logs.

For example, if you need to reduce the possibility of log loss when the collector restarts, or you require collected log messages to survive a collector restart to support regulatory mandates, you can tune your deployment to prioritize log durability. If you use outputs that have hard limitations on the size of batches they can receive, you might want to tune your deployment to prioritize log throughput.

You can tune both inputs and outputs in the ClusterLogForwarder CR.

5.2.1. Tune inputs

You can tune application and infrastructure inputs to control message size limits and rate limiting. These settings apply to container log collection and help prevent resource exhaustion from high-volume logging workloads.

The following example shows the ClusterLogForwarder CR options that you can change to tune log forwarder inputs:

Example ClusterLogForwarder CR input tuning options

apiVersion: observability.openshift.io/v1
kind: ClusterLogForwarder
metadata:
# ...
spec:
  # ...
  inputs:
  - name: application
    type: application
    application:
      tuning:
        container:
          maxMessageSize: 16Ki
          rateLimitPerContainer:
            maxRecordsPerSecond: 1000
  - name: infrastructure
    type: infrastructure
    infrastructure:
      tuning:
        container:
          maxMessageSize: 16Ki
          rateLimitPerContainer:
            maxRecordsPerSecond: 1000

maxMessageSize
Specifies the maximum message length in bytes that a single log event can be when all partial log lines merge. Messages exceeding this limit are dropped. You can specify this value as an integer or as a string with units such as Ki or Mi.
rateLimitPerContainer.maxRecordsPerSecond
Specifies the maximum number of log records allowed per second for each container. This limit is applied per collector deployment. When a container exceeds this rate, the collector drops excess log records until the rate falls below the limit.

5.2.2. Tune outputs

The following example shows the ClusterLogForwarder CR options that you can change to tune log forwarder outputs:

Example ClusterLogForwarder CR tuning options

apiVersion: observability.openshift.io/v1
kind: ClusterLogForwarder
metadata:
# ...
spec:
  # ...
  outputs:
  - name: default-lokistack
    type: lokiStack
    lokiStack:
      tuning:
        deliveryMode: AtLeastOnce
        compression: gzip
        maxWrite: 3Mi
        minRetryDuration: 2
        maxRetryDuration: 300

deliveryMode

Specify the delivery mode for log forwarding. When left unset, the system defaults to using an in-memory buffer, which offers the highest performance due to low latency but does not provide durability. Buffered data is lost on process termination or failure.

  • AtLeastOnce delivery means that if the log forwarder crashes or restarts, the collector re-sends any logs it read before the crash but did not send to their destination. The collector might duplicate some logs after a crash.
  • AtMostOnce delivery means that the log forwarder makes no effort to recover logs lost during a crash. This mode gives better throughput, but might result in greater log loss.
compression
Specifying a compression configuration causes the collector to compress data before sending it over the network. Note that not all output types support compression, and if the specified compression type is not supported by the output, this results in an error. For more information, see "Supported compression types for tuning outputs". When left unset, the collector does not apply compression.
maxWrite
Specifies a limit for the maximum payload in bytes of a single send operation to the output. You can specify this value as an integer or as a string with units such as Ki (kibibyte), Mi (mebibyte), or Gi (gibibyte). For example: 1048576, "1Mi", or "3Mi". For LokiStack outputs, the default value is 3Mi when not specified.
minRetryDuration
Specifies a minimum duration in seconds to wait between attempts before retrying delivery after a failure. This value is an integer representing seconds. For example, 2 means 2 seconds.
maxRetryDuration
Specifies a maximum duration in seconds to wait between attempts before retrying delivery after a failure. This value is an integer representing seconds. For example, 300 means 300 seconds (5 minutes).
Table 5.1. Supported compression types for tuning outputs
Compression algorithmSplunkAmazon CloudWatchElasticsearch 8LokiStackApache KafkaHTTPSyslogGoogle CloudMicrosoft Azure MonitoringAmazon S3

gzip

X

X

X

X

 

X

   

X

snappy

 

X

 

X

X

X

    

zlib

 

X

X

  

X

    

zstd

 

X

  

X

X

    

lz4

    

X

     

5.3. Set the collector log level

Set the collector log level by adding the observability.openshift.io/log-level annotation to the ClusterLogForwarder custom resource (CR).

Prerequisites

  • You have a working ClusterLogForwarder CR.
  • You have cluster-admin permissions.

Procedure

  1. Set the log level by running the following command:

    $ oc annotate clusterlogforwarder instance -n openshift-logging \
      observability.openshift.io/log-level=debug --overwrite

    The supported log levels are trace, debug, info, warn, error, and off. The default level is info.

  2. Verify that the collector pod restarted with the new log level by running the following command:

    $ oc logs -n openshift-logging -l app.kubernetes.io/component=collector --tail=5

    At the debug level, entries begin with DEBUG.

    Note

    Use debug or trace only for troubleshooting. These levels increase log volume significantly and can affect collector performance. Reset the level to info after troubleshooting.

5.4. Set the collector resource limits

Set CPU and memory resource limits by modifying the spec.collector.resources stanza in the ClusterLogForwarder custom resource (CR).

Prerequisites

  • You have a working ClusterLogForwarder CR.
  • You have cluster-admin permissions.

Procedure

  1. Patch the ClusterLogForwarder CR by running the following command:

    $ oc patch clusterlogforwarder instance -n openshift-logging \
      --type=merge \
      -p '{"spec":{"collector":{"resources":{"requests":{"cpu":"100m","memory":"256Mi"},"limits":{"cpu":"500m","memory":"512Mi"}}}}}'
  2. Verify that the collector pod restarted with the updated resources by running the following command:

    $ oc get pods -n openshift-logging -l app.kubernetes.io/component=collector

    The pod age should show a recent restart.

    Note

    If you do not set resource limits explicitly, the collector applies default limits: 500m CPU and 64Mi memory for requests, and 6000m CPU and 2048Mi memory for limits. Setting explicit limits prevents the collector from consuming more resources than expected on nodes with high log volume.

5.5. Create the log file metric exporter

Create a LogFileMetricExporter custom resource (CR) to generate metrics about the logs produced by running containers. The Operator does not deploy the exporter by default, so you must create it manually.

Note

If you do not create the LogFileMetricExporter CR, the Produced Logs field in the OpenShift Container Platform web console dashboard shows No datapoints found.

Prerequisites

  • You have administrator permissions.
  • Ensure that you installed the Red Hat OpenShift Logging Operator.
  • You have installed the OpenShift CLI (oc).

Procedure

  1. Create a LogFileMetricExporter CR as a YAML file:

    apiVersion: logging.openshift.io/v1alpha1
    kind: LogFileMetricExporter
    metadata:
      name: instance
      namespace: openshift-logging
    spec:
      nodeSelector: {}
      resources:
        limits:
          cpu: 500m
          memory: 256Mi
        requests:
          cpu: 200m
          memory: 128Mi
      tolerations: []
    spec.nodeSelector
    Optional: Define the nodes that the exporter pods run on.
    spec.resources
    Optional: Define CPU and memory resource limits and requests for the exporter.
    spec.tolerations

    Optional: Define tolerations that the exporter pods accept.

    Note

    The LogFileMetricExporter is a singleton. The Operator only honors openshift-logging/instance for the namespace and name.

  2. Run the following command to apply the LogFileMetricExporter CR:

    $ oc apply -f <filename>.yaml

Verification

  • Run the following command to verify that the logfilesmetricexporter pods are running:

    $ oc get pods -l app.kubernetes.io/component=logfilesmetricexporter \
      -n openshift-logging

    Example output

    NAME                           READY   STATUS    RESTARTS   AGE
    logfilesmetricexporter-9qbjj   1/1     Running   0          2m46s
    logfilesmetricexporter-cbc4v   1/1     Running   0          2m46s

    A logfilesmetricexporter pod runs concurrently with a collector pod on each node.

Red Hat logoGithubRedditYoutubeTwitter

Learn

Try, buy, & sell

Communities

About Red Hat

We deliver hardened solutions that make it easier for enterprises to work across platforms and environments, from the core datacenter to the network edge.

Making open source more inclusive

Red Hat is committed to replacing problematic language in our code, documentation, and web properties. For more details, see the Red Hat Blog.

About Red Hat Documentation

Legal Notice

Theme

© 2026 Red Hat
Back to top