This documentation is for a release that is no longer maintained
See documentation for the latest supported version 3 or the latest supported version 4.Este conteúdo não está disponível no idioma selecionado.
Chapter 7. Forwarding logs to third-party systems
By default, OpenShift Logging sends container and infrastructure logs to the default internal Elasticsearch log store defined in the ClusterLogging custom resource. However, it does not send audit logs to the internal store because it does not provide secure storage. If this default configuration meets your needs, you do not need to configure the Cluster Log Forwarder.
To send logs to other log aggregators, you use the OpenShift Container Platform Cluster Log Forwarder. This API enables you to send container, infrastructure, and audit logs to specific endpoints within or outside your cluster. In addition, you can send different types of logs to various systems so that various individuals can access each type. You can also enable Transport Layer Security (TLS) support to send logs securely, as required by your organization.
To send audit logs to the internal log store, use the Cluster Log Forwarder as described in Forward audit logs to the log store.
When you forward logs externally, the Red Hat OpenShift Logging Operator creates or modifies a Fluentd config map to send logs using your desired protocols. You are responsible for configuring the protocol on the external log aggregator.
Alternatively, you can create a config map to use the Fluentd forward protocol or the syslog protocol to send logs to external systems. However, these methods for forwarding logs are deprecated in OpenShift Container Platform and will be removed in a future release.
You cannot use the config map methods and the Cluster Log Forwarder in the same cluster.
7.1. About forwarding logs to third-party systems Copiar o linkLink copiado para a área de transferência!
Forwarding cluster logs to external third-party systems requires a combination of outputs and pipelines specified in a ClusterLogForwarder custom resource (CR) to send logs to specific endpoints inside and outside of your OpenShift Container Platform cluster. You can also use inputs to forward the application logs associated with a specific project to an endpoint.
An output is the destination for log data that you define, or where you want the logs sent. An output can be one of the following types:
-
elasticsearch. An external Elasticsearch 6 (all releases) instance. Theelasticsearchoutput can use a TLS connection. -
fluentdForward. An external log aggregation solution that supports Fluentd. This option uses the Fluentd forward protocols. ThefluentForwardoutput can use a TCP or TLS connection and supports shared-key authentication by providing a shared_key field in a secret. Shared-key authentication can be used with or without TLS. -
syslog. An external log aggregation solution that supports the syslog RFC3164 or RFC5424 protocols. Thesyslogoutput can use a UDP, TCP, or TLS connection. -
kafka. A Kafka broker. Thekafkaoutput can use a TCP or TLS connection. -
default. The internal OpenShift Container Platform Elasticsearch instance. You are not required to configure the default output. If you do configure adefaultoutput, you receive an error message because thedefaultoutput is reserved for the Red Hat OpenShift Logging Operator.
If the output URL scheme requires TLS (HTTPS, TLS, or UDPS), then TLS server-side authentication is enabled. To also enable client authentication, the output must name a secret in the
openshift-loggingproject. The secret must have keys of: tls.crt, tls.key, and ca-bundle.crt that point to the respective certificates that they represent.-
A pipeline defines simple routing from one log type to one or more outputs, or which logs you want 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. Logs generated by auditd, the node audit system, and the audit logs from the Kubernetes API server and the OpenShift API server.
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 are forwarded to others data centers or label the logs by type. Labels that are added to objects are also forwarded with the log message.-
- An input forwards the application logs associated with a specific project to a pipeline.
In the pipeline, you define which log types to forward using an inputRef parameter and where to forward the logs to using an outputRef parameter.
Note the following:
-
If a
ClusterLogForwarderCR object exists, logs are not forwarded to the default Elasticsearch instance, unless there is a pipeline with thedefaultoutput. -
By default, OpenShift Logging sends container and infrastructure logs to the default internal Elasticsearch log store defined in the
ClusterLoggingcustom resource. However, it does not send audit logs to the internal store because it does not provide secure storage. If this default configuration meets your needs, do not configure the Log Forwarding API. -
If you do not define a pipeline for a log type, the logs of the undefined types are dropped. For example, if you specify a pipeline for the
applicationandaudittypes, but do not specify a pipeline for theinfrastructuretype,infrastructurelogs are dropped. -
You can use multiple types of outputs in the
ClusterLogForwardercustom resource (CR) to send logs to servers that support different protocols. - The internal OpenShift Container Platform Elasticsearch instance does not provide secure storage for audit logs. We recommend you ensure that the system to which you forward audit logs is compliant with your organizational and governmental regulations and is properly secured. OpenShift Logging does not comply with those regulations.
- You are responsible for creating and maintaining any additional configurations that external destinations might require, such as keys and secrets, service accounts, port openings, or global proxy configuration.
The following example forwards the audit logs to a secure external Elasticsearch instance, the infrastructure logs to an insecure external Elasticsearch instance, the application logs to a Kafka broker, and the application logs from the my-apps-logs project to the internal Elasticsearch instance.
Sample log forwarding outputs and pipelines
- 1
- The name of the
ClusterLogForwarderCR must beinstance. - 2
- The namespace for the
ClusterLogForwarderCR must beopenshift-logging. - 3
- Configuration for an secure Elasticsearch output using a secret with a secure URL.
- A name to describe the output.
-
The type of output:
elasticsearch. - The secure URL and port of the Elasticsearch instance as a valid absolute URL, including the prefix.
-
The secret required by the endpoint for TLS communication. The secret must exist in the
openshift-loggingproject.
- 4
- Configuration for an insecure Elasticsearch output:
- A name to describe the output.
-
The type of output:
elasticsearch. - The insecure URL and port of the Elasticsearch instance as a valid absolute URL, including the prefix.
- 5
- Configuration for a Kafka output using a client-authenticated TLS communication over a secure URL
- A name to describe the output.
-
The type of output:
kafka. - Specify the URL and port of the Kafka broker as a valid absolute URL, including the prefix.
- 6
- Configuration for an input to filter application logs from the
my-projectnamespace. - 7
- Configuration for a pipeline to send audit logs to the secure external Elasticsearch instance:
- Optional. A name to describe the pipeline.
-
The
inputRefsis the log type, in this exampleaudit. -
The
outputRefsis the name of the output to use, in this exampleelasticsearch-secureto forward to the secure Elasticsearch instance anddefaultto forward to the internal Elasticsearch instance. - Optional: Labels to add to the logs.
- 8
- Optional: Forward structured JSON log entries as JSON objects in the
structuredfield. The log entry must contain valid structured JSON; otherwise, OpenShift Logging removes thestructuredfield and instead sends the log entry to the default index,app-00000x. - 9
- Optional: String. One or more labels to add to the logs. Quote values like "true" so they are recognized as string values, not as a boolean.
- 10
- Configuration for a pipeline to send infrastructure logs to the insecure external Elasticsearch instance.
- 11
- Configuration for a pipeline to send logs from the
my-projectproject to the internal Elasticsearch instance.- Optional. A name to describe the pipeline.
-
The
inputRefsis a specific input:my-app-logs. -
The
outputRefsisdefault. - Optional: String. One or more labels to add to the logs.
- 12
- Configuration for a pipeline to send logs to the Kafka broker, with no pipeline name:
-
The
inputRefsis the log type, in this exampleapplication. -
The
outputRefsis the name of the output to use. - Optional: String. One or more labels to add to the logs.
-
The
Fluentd log handling when the external log aggregator is unavailable
If your external logging aggregator becomes unavailable and cannot receive logs, Fluentd continues to collect logs and stores them in a buffer. When the log aggregator becomes available, log forwarding resumes, including the buffered logs. If the buffer fills completely, Fluentd stops collecting logs. OpenShift Container Platform rotates the logs and deletes them. You cannot adjust the buffer size or add a persistent volume claim (PVC) to the Fluentd daemon set or pods.
7.2. Supported log data output types Copiar o linkLink copiado para a área de transferência!
Red Hat OpenShift Logging 5.0 provides the following output types and protocols for sending log data to target log collectors.
Red Hat tests each of the combinations shown in the following table. However, you should be able to send log data to a wider range target log collectors that ingest these protocols.
| Output types | Protocols | Tested with |
|---|---|---|
| fluentdForward | fluentd forward v1 | fluentd 1.7.4 logstash 7.10.1 |
| elasticsearch | elasticsearch | Elasticsearch 6.8.1 Elasticsearch 7.10.1 |
| syslog | RFC-3164, RFC-5424 | rsyslog 8.37.0-9.el7 |
| kafka | kafka 0.11 | kafka 2.4.1 |
Previously, the syslog output supported only RFC-3164. The current syslog output adds support for RFC-5424.
7.3. Forwarding logs to an external Elasticsearch instance Copiar o linkLink copiado para a área de transferência!
You can optionally forward logs to an external Elasticsearch instance in addition to, or instead of, the internal OpenShift Container Platform Elasticsearch instance. You are responsible for configuring the external log aggregator to receive log data from OpenShift Container Platform.
To configure log forwarding to an external Elasticsearch instance, create a ClusterLogForwarder custom resource (CR) with an output to that instance and a pipeline that uses the output. The external Elasticsearch output can use the HTTP (insecure) or HTTPS (secure HTTP) connection.
To forward logs to both an external and the internal Elasticsearch instance, create outputs and pipelines to the external instance and a pipeline that uses the default output to forward logs to the internal instance. You do not need to create a default output. If you do configure a default output, you receive an error message because the default output is reserved for the Red Hat OpenShift Logging Operator.
If you want to forward logs to only the internal OpenShift Container Platform Elasticsearch instance, you do not need to create a ClusterLogForwarder CR.
Prerequisites
- You must have a logging server that is configured to receive the logging data using the specified protocol or format.
Procedure
Create a
ClusterLogForwarderCR YAML file similar to the following:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- The name of the
ClusterLogForwarderCR must beinstance. - 2
- The namespace for the
ClusterLogForwarderCR must beopenshift-logging. - 3
- Specify a name for the output.
- 4
- Specify the
elasticsearchtype. - 5
- Specify the URL and port of the external Elasticsearch instance as a valid absolute URL. You can use the
http(insecure) orhttps(secure HTTP) protocol. If the cluster-wide proxy using the CIDR annotation is enabled, the output must be a server name or FQDN, not an IP Address. - 6
- If using an
httpsprefix, you must specify the name of the secret required by the endpoint for TLS communication. The secret must exist in theopenshift-loggingproject and must have keys of: tls.crt, tls.key, and ca-bundle.crt that point to the respective certificates that they represent. - 7
- Optional: Specify a name for the pipeline.
- 8
- Specify which log types should be forwarded using that pipeline:
application,infrastructure, oraudit. - 9
- Specify the output to use with that pipeline for forwarding the logs.
- 10
- Optional: Specify the
defaultoutput to send the logs to the internal Elasticsearch instance. - 11
- Optional: Forward structured JSON log entries as JSON objects in the
structuredfield. The log entry must contain valid structured JSON; otherwise, OpenShift Logging removes thestructuredfield and instead sends the log entry to the default index,app-00000x. - 12
- Optional: String. One or more labels to add to the logs.
- 13
- Optional: Configure multiple outputs to forward logs to other external log aggregators of any supported type:
- Optional. A name to describe the pipeline.
-
The
inputRefsis the log type to forward using that pipeline:application,infrastructure, oraudit. -
The
outputRefsis the name of the output to use. - Optional: String. One or more labels to add to the logs.
Create the CR object:
oc create -f <file-name>.yaml
$ oc create -f <file-name>.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow
The Red Hat OpenShift Logging Operator redeploys the Fluentd pods. If the pods do not redeploy, you can delete the Fluentd pods to force them to redeploy.
oc delete pod --selector logging-infra=fluentd
$ oc delete pod --selector logging-infra=fluentd
7.4. Forwarding logs using the Fluentd forward protocol Copiar o linkLink copiado para a área de transferência!
You can use the Fluentd forward protocol to send a copy of your logs to an external log aggregator configured to accept the protocol instead of, or in addition to, the default Elasticsearch log store. You are responsible for configuring the external log aggregator to receive the logs from OpenShift Container Platform.
To configure log forwarding using the forward protocol, create a ClusterLogForwarder custom resource (CR) with one or more outputs to the Fluentd servers and pipelines that use those outputs. The Fluentd output can use a TCP (insecure) or TLS (secure TCP) connection.
Alternately, you can use a config map to forward logs using the forward protocols. However, this method is deprecated in OpenShift Container Platform and will be removed in a future release.
Prerequisites
- You must have a logging server that is configured to receive the logging data using the specified protocol or format.
Procedure
Create a
ClusterLogForwarderCR YAML file similar to the following:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- The name of the
ClusterLogForwarderCR must beinstance. - 2
- The namespace for the
ClusterLogForwarderCR must beopenshift-logging. - 3
- Specify a name for the output.
- 4
- Specify the
fluentdForwardtype. - 5
- Specify the URL and port of the external Fluentd instance as a valid absolute URL. You can use the
tcp(insecure) ortls(secure TCP) protocol. If the cluster-wide proxy using the CIDR annotation is enabled, the output must be a server name or FQDN, not an IP address. - 6
- If using a
tlsprefix, you must specify the name of the secret required by the endpoint for TLS communication. The secret must exist in theopenshift-loggingproject and must have keys of: tls.crt, tls.key, and ca-bundle.crt that point to the respective certificates that they represent. - 7
- Optional. Specify a name for the pipeline.
- 8
- Specify which log types should be forwarded using that pipeline:
application,infrastructure, oraudit. - 9
- Specify the output to use with that pipeline for forwarding the logs.
- 10
- Optional. Specify the
defaultoutput to forward logs to the internal Elasticsearch instance. - 11
- Optional: Forward structured JSON log entries as JSON objects in the
structuredfield. The log entry must contain valid structured JSON; otherwise, OpenShift Logging removes thestructuredfield and instead sends the log entry to the default index,app-00000x. - 12
- Optional: String. One or more labels to add to the logs.
- 13
- Optional: Configure multiple outputs to forward logs to other external log aggregators of any supported type:
- Optional. A name to describe the pipeline.
-
The
inputRefsis the log type to forward using that pipeline:application,infrastructure, oraudit. -
The
outputRefsis the name of the output to use. - Optional: String. One or more labels to add to the logs.
Create the CR object:
oc create -f <file-name>.yaml
$ oc create -f <file-name>.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow
The Red Hat OpenShift Logging Operator redeploys the Fluentd pods. If the pods do not redeploy, you can delete the Fluentd pods to force them to redeploy.
oc delete pod --selector logging-infra=fluentd
$ oc delete pod --selector logging-infra=fluentd
7.5. Forwarding logs using the syslog protocol Copiar o linkLink copiado para a área de transferência!
You can use the syslog RFC3164 or RFC5424 protocol to send a copy of your logs to an external log aggregator configured to accept the protocol instead of, or in addition to, the default Elasticsearch log store. You are responsible for configuring the external log aggregator, such as a syslog server, to receive the logs from OpenShift Container Platform.
To configure log forwarding using the syslog protocol, create a ClusterLogForwarder custom resource (CR) with one or more outputs to the syslog servers and pipelines that use those outputs. The syslog output can use a UDP, TCP, or TLS connection.
Alternately, you can use a config map to forward logs using the syslog RFC3164 protocols. However, this method is deprecated in OpenShift Container Platform and will be removed in a future release.
Prerequisites
- You must have a logging server that is configured to receive the logging data using the specified protocol or format.
Procedure
Create a
ClusterLogForwarderCR YAML file similar to the following:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- The name of the
ClusterLogForwarderCR must beinstance. - 2
- The namespace for the
ClusterLogForwarderCR must beopenshift-logging. - 3
- Specify a name for the output.
- 4
- Specify the
syslogtype. - 5
- Optional. Specify the syslog parameters, listed below.
- 6
- Specify the URL and port of the external syslog instance. You can use the
udp(insecure),tcp(insecure) ortls(secure TCP) protocol. If the cluster-wide proxy using the CIDR annotation is enabled, the output must be a server name or FQDN, not an IP address. - 7
- If using a
tlsprefix, you must specify the name of the secret required by the endpoint for TLS communication. The secret must exist in theopenshift-loggingproject and must have keys of: tls.crt, tls.key, and ca-bundle.crt that point to the respective certificates that they represent. - 8
- Optional: Specify a name for the pipeline.
- 9
- Specify which log types should be forwarded using that pipeline:
application,infrastructure, oraudit. - 10
- Specify the output to use with that pipeline for forwarding the logs.
- 11
- Optional: Specify the
defaultoutput to forward logs to the internal Elasticsearch instance. - 12
- Optional: Forward structured JSON log entries as JSON objects in the
structuredfield. The log entry must contain valid structured JSON; otherwise, OpenShift Logging removes thestructuredfield and instead sends the log entry to the default index,app-00000x. - 13
- Optional: String. One or more labels to add to the logs. Quote values like "true" so they are recognized as string values, not as a boolean.
- 14
- Optional: Configure multiple outputs to forward logs to other external log aggregators of any supported type:
- Optional. A name to describe the pipeline.
-
The
inputRefsis the log type to forward using that pipeline:application,infrastructure, oraudit. -
The
outputRefsis the name of the output to use. - Optional: String. One or more labels to add to the logs.
Create the CR object:
oc create -f <file-name>.yaml
$ oc create -f <file-name>.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow
The Red Hat OpenShift Logging Operator redeploys the Fluentd pods. If the pods do not redeploy, you can delete the Fluentd pods to force them to redeploy.
oc delete pod --selector logging-infra=fluentd
$ oc delete pod --selector logging-infra=fluentd
7.5.1. Syslog parameters Copiar o linkLink copiado para a área de transferência!
You can configure the following for the syslog outputs. For more information, see the syslog RFC3164 or RFC5424 RFC.
facility: The syslog facility. The value can be a decimal integer or a case-insensitive keyword:
-
0orkernfor kernel messages -
1oruserfor user-level messages, the default. -
2ormailfor the mail system -
3ordaemonfor system daemons -
4orauthfor security/authentication messages -
5orsyslogfor messages generated internally by syslogd -
6orlprfor the line printer subsystem -
7ornewsfor the network news subsystem -
8oruucpfor the UUCP subsystem -
9orcronfor the clock daemon -
10orauthprivfor security authentication messages -
11orftpfor the FTP daemon -
12orntpfor the NTP subsystem -
13orsecurityfor the syslog audit log -
14orconsolefor the syslog alert log -
15orsolaris-cronfor the scheduling daemon -
16–23orlocal0–local7for locally used facilities
-
Optional.
payloadKey: The record field to use as payload for the syslog message.NoteConfiguring the
payloadKeyparameter prevents other parameters from being forwarded to the syslog.- rfc: The RFC to be used for sending logs using syslog. The default is RFC5424.
severity: The syslog severity to set on outgoing syslog records. The value can be a decimal integer or a case-insensitive keyword:
-
0orEmergencyfor messages indicating the system is unusable -
1orAlertfor messages indicating action must be taken immediately -
2orCriticalfor messages indicating critical conditions -
3orErrorfor messages indicating error conditions -
4orWarningfor messages indicating warning conditions -
5orNoticefor messages indicating normal but significant conditions -
6orInformationalfor messages indicating informational messages -
7orDebugfor messages indicating debug-level messages, the default
-
- tag: Tag specifies a record field to use as a tag on the syslog message.
- trimPrefix: Remove the specified prefix from the tag.
7.5.2. Additional RFC5424 syslog parameters Copiar o linkLink copiado para a área de transferência!
The following parameters apply to RFC5424:
-
appName: The APP-NAME is a free-text string that identifies the application that sent the log. Must be specified for
RFC5424. -
msgID: The MSGID is a free-text string that identifies the type of message. Must be specified for
RFC5424. -
procID: The PROCID is a free-text string. A change in the value indicates a discontinuity in syslog reporting. Must be specified for
RFC5424.
7.6. Forwarding logs to a Kafka broker Copiar o linkLink copiado para a área de transferência!
You can forward logs to an external Kafka broker in addition to, or instead of, the default Elasticsearch log store.
To configure log forwarding to an external Kafka instance, create a ClusterLogForwarder custom resource (CR) with an output to that instance and a pipeline that uses the output. You can include a specific Kafka topic in the output or use the default. The Kafka output can use a TCP (insecure) or TLS (secure TCP) connection.
Procedure
Create a
ClusterLogForwarderCR YAML file similar to the following:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- The name of the
ClusterLogForwarderCR must beinstance. - 2
- The namespace for the
ClusterLogForwarderCR must beopenshift-logging. - 3
- Specify a name for the output.
- 4
- Specify the
kafkatype. - 5
- Specify the URL and port of the Kafka broker as a valid absolute URL, optionally with a specific topic. You can use the
tcp(insecure) ortls(secure TCP) protocol. If the cluster-wide proxy using the CIDR annotation is enabled, the output must be a server name or FQDN, not an IP address. - 6
- If using a
tlsprefix, you must specify the name of the secret required by the endpoint for TLS communication. The secret must exist in theopenshift-loggingproject and must have keys of: tls.crt, tls.key, and ca-bundle.crt that point to the respective certificates that they represent. - 7
- Optional: To send an insecure output, use a
tcpprefix in front of the URL. Also omit thesecretkey and itsnamefrom this output. - 8
- Optional: Specify a name for the pipeline.
- 9
- Specify which log types should be forwarded using that pipeline:
application,infrastructure, oraudit. - 10
- Specify the output to use with that pipeline for forwarding the logs.
- 11
- Optional: Forward structured JSON log entries as JSON objects in the
structuredfield. The log entry must contain valid structured JSON; otherwise, OpenShift Logging removes thestructuredfield and instead sends the log entry to the default index,app-00000x. - 12
- Optional: String. One or more labels to add to the logs.
- 13
- Optional: Configure multiple outputs to forward logs to other external log aggregators of any supported type:
- Optional. A name to describe the pipeline.
-
The
inputRefsis the log type to forward using that pipeline:application,infrastructure, oraudit. -
The
outputRefsis the name of the output to use. - Optional: String. One or more labels to add to the logs.
- 14
- Optional: Specify
defaultto forward logs to the internal Elasticsearch instance.
Optional: To forward a single output to multiple Kafka brokers, specify an array of Kafka brokers as shown in this example:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Create the CR object:
oc create -f <file-name>.yaml
$ oc create -f <file-name>.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow
The Red Hat OpenShift Logging Operator redeploys the Fluentd pods. If the pods do not redeploy, you can delete the Fluentd pods to force them to redeploy.
oc delete pod --selector logging-infra=fluentd
$ oc delete pod --selector logging-infra=fluentd
7.7. Forwarding application logs from specific projects Copiar o linkLink copiado para a área de transferência!
You can use the Cluster Log Forwarder to send a copy of the application logs from specific projects to an external log aggregator. You can do this in addition to, or instead of, using the default Elasticsearch log store. You must also configure the external log aggregator to receive log data from OpenShift Container Platform.
To configure forwarding application logs from a project, create a ClusterLogForwarder custom resource (CR) with at least one input from a project, optional outputs for other log aggregators, and pipelines that use those inputs and outputs.
Prerequisites
- You must have a logging server that is configured to receive the logging data using the specified protocol or format.
Procedure
Create a
ClusterLogForwarderCR YAML file similar to the following:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- The name of the
ClusterLogForwarderCR must beinstance. - 2
- The namespace for the
ClusterLogForwarderCR must beopenshift-logging. - 3
- Specify a name for the output.
- 4
- Specify the output type:
elasticsearch,fluentdForward,syslog, orkafka. - 5
- Specify the URL and port of the external log aggregator as a valid absolute URL. If the cluster-wide proxy using the CIDR annotation is enabled, the output must be a server name or FQDN, not an IP address.
- 6
- If using a
tlsprefix, you must specify the name of the secret required by the endpoint for TLS communication. The secret must exist in theopenshift-loggingproject and have tls.crt, tls.key, and ca-bundle.crt keys that each point to the certificates they represent. - 7
- Configuration for an input to filter application logs from the specified projects.
- 8
- Configuration for a pipeline to use the input to send project application logs to an external Fluentd instance.
- 9
- The
my-app-logsinput. - 10
- The name of the output to use.
- 11
- Optional: Forward structured JSON log entries as JSON objects in the
structuredfield. The log entry must contain valid structured JSON; otherwise, OpenShift Logging removes thestructuredfield and instead sends the log entry to the default index,app-00000x. - 12
- Optional: String. One or more labels to add to the logs.
- 13
- Configuration for a pipeline to send logs to other log aggregators.
- Optional: Specify a name for the pipeline.
-
Specify which log types should be forwarded using that pipeline:
application,infrastructure, oraudit. - Specify the output to use with that pipeline for forwarding the logs.
-
Optional: Specify the
defaultoutput to forward logs to the internal Elasticsearch instance. - Optional: String. One or more labels to add to the logs.
Create the CR object:
oc create -f <file-name>.yaml
$ oc create -f <file-name>.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow
7.8. Forwarding application logs from specific pods Copiar o linkLink copiado para a área de transferência!
As a cluster administrator, you can use Kubernetes pod labels to gather log data from specific pods and forward it to a log collector.
Suppose that you have an application composed of pods running alongside other pods in various namespaces. If those pods have labels that identify the application, you can gather and output their log data to a specific log collector.
To specify the pod labels, you use one or more matchLabels key-value pairs. If you specify multiple key-value pairs, the pods must match all of them to be selected.
Procedure
-
Create a
ClusterLogForwardercustom resource (CR) YAML file. In the YAML file, specify the pod labels using simple equality-based selectors under
inputs[].name.application.selector.matchLabels, as shown in the following example.Example
ClusterLogForwarderCR YAML fileCopy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- The name of the
ClusterLogForwarderCR must beinstance. - 2
- The namespace for the
ClusterLogForwarderCR must beopenshift-logging. - 3
- Specify one or more comma-separated values from
inputs[].name. - 4
- Specify one or more comma-separated values from
outputs[]. - 5
- Optional: Forward structured JSON log entries as JSON objects in the
structuredfield. The log entry must contain valid structured JSON; otherwise, OpenShift Logging removes thestructuredfield and instead sends the log entry to the default index,app-00000x. - 6
- Define a unique
inputs[].namefor each application that has a unique set of pod labels. - 7
- Specify the key-value pairs of pod labels whose log data you want to gather. You must specify both a key and value, not just a key. To be selected, the pods must match all the key-value pairs.
- 8
- Optional: Specify one or more namespaces.
- 9
- Specify one or more outputs to forward your log data to. The optional
defaultoutput shown here sends log data to the internal Elasticsearch instance.
-
Optional: To restrict the gathering of log data to specific namespaces, use
inputs[].name.application.namespaces, as shown in the preceding example. Optional: You can send log data from additional applications that have different pod labels to the same pipeline.
-
For each unique combination of pod labels, create an additional
inputs[].namesection similar to the one shown. -
Update the
selectorsto match the pod labels of this application. Add the new
inputs[].namevalue toinputRefs. For example:- inputRefs: [ myAppLogData, myOtherAppLogData ]
- inputRefs: [ myAppLogData, myOtherAppLogData ]Copy to Clipboard Copied! Toggle word wrap Toggle overflow
-
For each unique combination of pod labels, create an additional
Create the CR object:
oc create -f <file-name>.yaml
$ oc create -f <file-name>.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow
7.9. Forwarding logs using the legacy Fluentd method Copiar o linkLink copiado para a área de transferência!
You can use the Fluentd forward protocol to send logs to destinations outside of your OpenShift Container Platform cluster by creating a configuration file and config map. You are responsible for configuring the external log aggregator to receive log data from OpenShift Container Platform.
This method for forwarding logs is deprecated in OpenShift Container Platform and will be removed in a future release.
To send logs using the Fluentd forward protocol, create a configuration file called secure-forward.conf, that points to an external log aggregator. Then, use that file to create a config map called called secure-forward in the openshift-logging project, which OpenShift Container Platform uses when forwarding the logs.
Prerequisites
- You must have a logging server that is configured to receive the logging data using the specified protocol or format.
Sample Fluentd configuration file
Procedure
To configure OpenShift Container Platform to forward logs using the legacy Fluentd method:
Create a configuration file named
secure-forwardand specify parameters similar to the following within the<store>stanza:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Enter the shared key between nodes.
- 2
- Specify
tlsto enable TLS validation. - 3
- Set to
trueto verify the server cert hostname. Set tofalseto ignore server cert hostname. - 4
- Specify the path to the private CA certificate file as
/etc/ocp-forward/ca_cert.pem. - 5
- Specify the Fluentd buffer parameters as needed.
- 6
- Optionally, enter a name for this server.
- 7
- Specify the hostname or IP of the server.
- 8
- Specify the host label of the server.
- 9
- Specify the port of the server.
- 10
- Optionally, add additional servers. If you specify two or more servers, forward uses these server nodes in a round-robin order.
To use Mutual TLS (mTLS) authentication, see the Fluentd documentation for information about client certificate, key parameters, and other settings.
Create a config map named
secure-forwardin theopenshift-loggingproject from the configuration file:oc create configmap secure-forward --from-file=secure-forward.conf -n openshift-logging
$ oc create configmap secure-forward --from-file=secure-forward.conf -n openshift-loggingCopy to Clipboard Copied! Toggle word wrap Toggle overflow
The Red Hat OpenShift Logging Operator redeploys the Fluentd pods. If the pods do not redeploy, you can delete the Fluentd pods to force them to redeploy.
oc delete pod --selector logging-infra=fluentd
$ oc delete pod --selector logging-infra=fluentd
7.10. Forwarding logs using the legacy syslog method Copiar o linkLink copiado para a área de transferência!
You can use the syslog RFC3164 protocol to send logs to destinations outside of your OpenShift Container Platform cluster by creating a configuration file and config map. You are responsible for configuring the external log aggregator, such as a syslog server, to receive the logs from OpenShift Container Platform.
This method for forwarding logs is deprecated in OpenShift Container Platform and will be removed in a future release.
There are two versions of the syslog protocol:
- out_syslog: The non-buffered implementation, which communicates through UDP, does not buffer data and writes out results immediately.
- out_syslog_buffered: The buffered implementation, which communicates through TCP and buffers data into chunks.
To send logs using the syslog protocol, create a configuration file called syslog.conf, with the information needed to forward the logs. Then, use that file to create a config map called syslog in the openshift-logging project, which OpenShift Container Platform uses when forwarding the logs.
Prerequisites
- You must have a logging server that is configured to receive the logging data using the specified protocol or format.
Sample syslog configuration file
You can configure the following syslog parameters. For more information, see the syslog RFC3164.
facility: The syslog facility. The value can be a decimal integer or a case-insensitive keyword:
-
0orkernfor kernel messages -
1oruserfor user-level messages, the default. -
2ormailfor the mail system -
3ordaemonfor the system daemons -
4orauthfor the security/authentication messages -
5orsyslogfor messages generated internally by syslogd -
6orlprfor the line printer subsystem -
7ornewsfor the network news subsystem -
8oruucpfor the UUCP subsystem -
9orcronfor the clock daemon -
10orauthprivfor security authentication messages -
11orftpfor the FTP daemon -
12orntpfor the NTP subsystem -
13orsecurityfor the syslog audit logs -
14orconsolefor the syslog alert logs -
15orsolaris-cronfor the scheduling daemon -
16–23orlocal0–local7for locally used facilities
-
- payloadKey: The record field to use as payload for the syslog message.
- rfc: The RFC to be used for sending logs using syslog.
severity: The syslog severity to set on outgoing syslog records. The value can be a decimal integer or a case-insensitive keyword:
-
0orEmergencyfor messages indicating the system is unusable -
1orAlertfor messages indicating action must be taken immediately -
2orCriticalfor messages indicating critical conditions -
3orErrorfor messages indicating error conditions -
4orWarningfor messages indicating warning conditions -
5orNoticefor messages indicating normal but significant conditions -
6orInformationalfor messages indicating informational messages -
7orDebugfor messages indicating debug-level messages, the default
-
- tag: The record field to use as a tag on the syslog message.
- trimPrefix: The prefix to remove from the tag.
Procedure
To configure OpenShift Container Platform to forward logs using the legacy configuration methods:
Create a configuration file named
syslog.confand specify parameters similar to the following within the<store>stanza:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Specify the protocol to use, either:
syslogorsyslog_buffered. - 2
- Specify the FQDN or IP address of the syslog server.
- 3
- Specify the port of the syslog server.
- 4
- Optional: Specify the appropriate syslog parameters, for example:
-
Parameter to remove the specified
tagfield from the syslog prefix. - Parameter to set the specified field as the syslog key.
- Parameter to specify the syslog log facility or source.
- Parameter to specify the syslog log severity.
-
Parameter to use the severity and facility from the record if available. If
true, thecontainer_name,namespace_name, andpod_nameare included in the output content. -
Parameter to specify the key to set the payload of the syslog message. Defaults to
message.
-
Parameter to remove the specified
- 5
- With the legacy syslog method, you must specify
3164for therfcvalue.
Create a config map named
syslogin theopenshift-loggingproject from the configuration file:oc create configmap syslog --from-file=syslog.conf -n openshift-logging
$ oc create configmap syslog --from-file=syslog.conf -n openshift-loggingCopy to Clipboard Copied! Toggle word wrap Toggle overflow
The Red Hat OpenShift Logging Operator redeploys the Fluentd pods. If the pods do not redeploy, you can delete the Fluentd pods to force them to redeploy.
oc delete pod --selector logging-infra=fluentd
$ oc delete pod --selector logging-infra=fluentd