Chapter 1. Forward to third-party systems
You can forward logs to third-party systems by using various output types, including OTLP, HTTP, and external Loki instances. This section covers destination-specific configuration for external systems. For general ClusterLogForwarder setup, inputs, outputs, filters, and pipelines, see the Configure section.
1.1. External log forwarding destination compatibility Copy linkLink copied to clipboard!
The following table lists external log forwarding destinations tested and validated with Red Hat OpenShift Logging.
| Output type | Protocol | Tested versions | Logging versions |
|---|---|---|---|
| Elasticsearch v6 | HTTP 1.1 | 6.8.1 | 6.0+ |
| Elasticsearch v7 | HTTP 1.1 | 7.12.2 | 6.0+ |
| Elasticsearch v8 | HTTP 1.1 | 8.6.1 | 6.0+ |
| Elasticsearch v9 | HTTP 1.1 | 9.3.3 | 6.0+ |
| Google Cloud Logging | REST over HTTPS | Latest | 6.0+ |
| HTTP (Generic) | HTTP 1.1 | Vector 0.28-1, 0.34-1 | 6.0+ |
| Kafka | Kafka 0.11 | 2.4.1, 2.7.0 | 6.0+ |
| Loki (External) | REST over HTTP/HTTPS | 2.3.0 | 6.0+ |
| OTLP | HTTP/HTTPS | OpenTelemetry Collector 0.88+ | 6.1+ |
| Splunk | HEC | 9.0.0 | 6.0+ |
| Syslog | RFC3164, RFC5424 | rsyslog 8.39.0 | 6.0+ |
| Amazon CloudWatch | REST over HTTPS | Latest | 6.0+ |
| Amazon S3 | REST over HTTPS | Latest | 6.0+ |
| Azure Monitor Logs | REST over HTTPS | Latest | 6.0+ |
This table lists versions that Red Hat has tested. Other versions might work but Red Hat has not validated them. For Red Hat OpenShift Logging managed destinations (LokiStack), version compatibility is managed automatically.
1.2. Log forwarding to third-party systems Copy linkLink copied to clipboard!
To send logs to specific endpoints inside and outside your OpenShift Container Platform cluster, you specify a combination of outputs and pipelines in a ClusterLogForwarder custom resource (CR). You can also use inputs to forward the application logs associated with a specific project to an endpoint. A Kubernetes Secret object provides authentication.
- pipeline
Defines simple routing from one log type to one or more outputs, or the logs to send. The log types are one of the following:
-
application. Container logs generated by user applications running in the cluster, except infrastructure container applications. -
infrastructure. Container logs from pods that run in theopenshift*,kube*, ordefaultprojects and journal logs sourced from node file system. -
audit. Audit logs generated by the node audit system,auditd, Kubernetes API server, OpenShift API server, and OVN network.
You can add labels to outbound log messages by using
key:valuepairs in the pipeline. For example, you might add a label to messages that the collector forwards to other data centers or label the logs by type. The collector also forwards labels added to objects with the log message.-
- input
Forwards the application logs associated with a specific project to a pipeline.
In the pipeline, you define the input sources to forward using an
inputRefparameter and where to forward the logs to using anoutputRefparameter.- Secret
-
A
key:value mapthat has confidential data such as user credentials.
Note the following:
-
You can use many types of outputs in the
ClusterLogForwardercustom resource (CR) to send logs to servers that support different protocols.
The following example forwards the audit logs to a secure external Elasticsearch instance.
Sample log forwarding outputs and pipelines
kind: ClusterLogForwarder
apiVersion: observability.openshift.io/v1
metadata:
name: instance
namespace: openshift-logging
spec:
serviceAccount:
name: logging-admin
outputs:
- name: external-es
type: elasticsearch
elasticsearch:
url: <elasticsearch_url>
version: 8
index: '{.log_type||"undefined"}'
authentication:
username:
key: username
secretName: es-secret
password:
key: password
secretName: es-secret
tls:
ca:
key: ca-bundle.crt
secretName: es-secret
certificate:
key: tls.crt
secretName: es-secret
key:
key: tls.key
secretName: es-secret
pipelines:
- name: my-logs
inputRefs:
- application
- infrastructure
outputRefs:
- external-es
version-
Forwarding to an external Elasticsearch of version 8.x or greater requires you to specify the
versionfield. index-
The
indexfield reads the.log_typefield value and falls back to "unknown" if not found. secretName- Use username and password to authenticate to the server
ca- Enable Mutual Transport Layer Security (mTLS) between collector and Elasticsearch. The spec identifies the keys and secret for the certificates that they represent.
1.3. Create a secret by using the CLI Copy linkLink copied to clipboard!
Create a secret by using the CLI.
You can create a secret by using the OpenShift CLI (oc).
Prerequisites
- You have administrator permissions.
- You installed the Loki Operator.
-
You installed the OpenShift CLI (
oc).
Procedure
Create a secret in the directory that contains your certificate and key files by running the following command:
$ oc create secret generic -n openshift-logging <your_secret_name> \ --from-file=tls.key=<your_key_file> \ --from-file=tls.crt=<your_crt_file> \ --from-file=ca-bundle.crt=<your_bundle_file> \ --from-literal=username=<your_username> \ --from-literal=password=<your_password>NoteUse generic or opaque secrets for best results.
Verification
Verify that a secret was created by running the following command:
$ oc get secret -n openshift-logging
1.4. Configure OTLP output Copy linkLink copied to clipboard!
Cluster administrators can use the OpenTelemetry Protocol (OTLP) output to collect and forward logs to OTLP receivers. The OTLP output uses the specification defined by the OpenTelemetry Observability framework to send data over HTTP with JSON encoding.
Before implementing OTLP log forwarding, be aware of the following limitations:
Field name compatibility: The log collector uses the ViaQ data model internally and then translates to the OpenTelemetry data model before sending logs to OTLP receivers. Due to this internal translation, you must use ViaQ field names (not OpenTelemetry field names) in the following contexts:
-
Filters: When configuring prune, drop, or other filters in your
ClusterLogForwardercustom resource, use ViaQ field names such askubernetes.pod_name. The filter operates on the internal ViaQ representation before translating to OpenTelemetry. Filters do not work with OpenTelemetry field names such ask8s.pod_name. -
Alerting rules: When creating log-based alerting rules, use ViaQ field names. For authorization purposes, your filter must include
kubernetes_namespace_name, notk8s_namespace_name.
-
Filters: When configuring prune, drop, or other filters in your
- Data model translation: Although logs are stored and queried in OpenTelemetry format, the internal ViaQ-to-OpenTelemetry translation means that some OpenTelemetry-native features might not work as expected.
Procedure
Create or edit a
ClusterLogForwardercustom resource (CR) to enable forwarding using OTLP.apiVersion: observability.openshift.io/v1 kind: ClusterLogForwarder metadata: name: clf-otlp spec: serviceAccount: name: <service_account_name> outputs: - name: otlp type: otlp otlp: tuning: compression: gzip deliveryMode: AtLeastOnce maxRetryDuration: 20 maxWrite: 10M minRetryDuration: 5 url: <otlp_url> pipelines: - inputRefs: - application - infrastructure - audit name: otlp-logs outputRefs: - otlpurl- This URL must be absolute and is a placeholder for the OTLP endpoint where logs are sent.
tuning.compression-
Compression algorithm to use. Valid values are
gzip,snappy, ornone. tuning.deliveryMode-
Delivery mode for log forwarding. Valid values are
AtLeastOnceorAtMostOnce. tuning.maxRetryDuration- Maximum time in seconds to retry failed deliveries.
tuning.maxWrite- Maximum size of a single write request.
tuning.minRetryDurationMinimum time in seconds between retries.
NoteThe OTLP output uses the OpenTelemetry data model, which is different from the ViaQ data model that is used by other output types. For more information, see OpenTelemetry Semantic Conventions.
Apply the
ClusterLogForwardercustom resource:$ oc apply -f <filename>.yaml
Verification
Verify that the
ClusterLogForwarderstatus showsReady:$ oc get clusterlogforwarder clf-otlp -n openshift-logging \ -o jsonpath='{.status.conditions[?(@.type=="Ready")].status}'The output should show
True.Verify that OTLP is functioning correctly by checking the LokiStack metrics dashboard:
-
In the OpenShift Container Platform web console, navigate to Observe
Dashboards. - From the Dashboard dropdown, select OpenShift Logging / LokiStack / Writes.
- Check the Distributor - structured metadata panel for incoming OTLP log records.
-
In the OpenShift Container Platform web console, navigate to Observe
1.5. Forward logs to an external Loki logging system Copy linkLink copied to clipboard!
To configure log forwarding to Loki, you must create a ClusterLogForwarder custom resource (CR) with an output to Loki, and a pipeline that uses the output. The output to Loki can use the HTTP (insecure) or HTTPS (secure HTTP) connection.
Prerequisites
- You have installed Red Hat OpenShift Logging Operator.
- You have administrator access to OpenShift Container Platform.
-
You have installed OpenShift CLI (
oc). -
You have a Loki logging system running at the URL specified in the
urlfield.
Procedure
Create or edit a YAML file that defines the
ClusterLogForwarderCR object:apiVersion: observability.openshift.io/v1 kind: ClusterLogForwarder metadata: name: <log_forwarder_name> namespace: <log_forwarder_namespace> spec: serviceAccount: name: <service_account_name> outputs: - name: loki-output type: loki loki: authentication: username: key: username secretName: to-loki-secret password: key: password secretName: to-loki-secret token: from: secret secret: key: ca-bundle.crt name: to-loki-secret labelKeys: - <label_keys> tenantKey: '{.kubernetes.namespace_name||"application"}' url: https://loki.example.com:3100 pipelines: - name: my-pipeline inputRefs: - application - audit outputRefs: - loki-outputserviceAccount.name- Specify the name of your service account.
outputs.name- Specify a name for the output.
type-
Specify the type as
loki. authentication- Specify the authentication information.
labelKeys-
Specify the log record keys to map to Loki stream labels. If you do not set the
labelKeysfield, theClusterLogForwarderCR uses these default keys:log_type,kubernetes.container_name,kubernetes.namespace_name,kubernetes.pod_name. tenantKey-
Specify the tenant for the logs. The value can be a combination of static and dynamic values consisting of field paths separated by
||. Encase dynamic values inside single curly brackets{}. Follow dynamic values with a static fallback value. url- Specify the URL for Loki.
inputRefs-
Specify the names of inputs defined in the
input.namefield for this pipeline. You can also use the built-in valuesapplication,infrastructure,audit. outputRefsSpecify the names of outputs defined in the
outputs.namefield for this pipeline.NoteBecause Loki requires log streams to be correctly ordered by timestamp,
labelKeysalways includes thekubernetes_hostlabel set, even if you do not specify it. This inclusion ensures that each stream originates from a single host, which prevents timestamps from becoming disordered due to clock differences on different hosts.
Apply the
ClusterLogForwarderCR object by running the following command:$ oc apply -f <filename>.yaml