Este contenido no está disponible en el idioma seleccionado.
Chapter 14. Performance and reliability tuning
14.1. Flow control mechanisms Copiar enlaceEnlace copiado en el portapapeles!
If logs are produced faster than they can be collected, it can be difficult to predict or control the volume of logs being sent to an output. Not being able to predict or control the volume of logs being sent to an output can result in logs being lost. If there is a system outage and log buffers are accumulated without user control, this can also cause long recovery times and high latency when the connection is restored.
As an administrator, you can limit logging rates by configuring flow control mechanisms for your logging.
14.1.1. Benefits of flow control mechanisms Copiar enlaceEnlace copiado en el portapapeles!
- The cost and volume of logging can be predicted more accurately in advance.
- Noisy containers cannot produce unbounded log traffic that drowns out other containers.
- Ignoring low-value logs reduces the load on the logging infrastructure.
- High-value logs can be preferred over low-value logs by assigning higher rate limits.
14.1.2. Configuring rate limits Copiar enlaceEnlace copiado en el portapapeles!
Rate limits are configured per collector, which means that the maximum rate of log collection is the number of collector instances multiplied by the rate limit.
Because logs are collected from each node’s file system, a collector is deployed on each cluster node. For example, in a 3-node cluster, with a maximum rate limit of 10 records per second per collector, the maximum rate of log collection is 30 records per second.
Because the exact byte size of a record as written to an output can vary due to transformations, different encodings, or other factors, rate limits are set in number of records instead of bytes.
You can configure rate limits in the ClusterLogForwarder custom resource (CR) in two ways:
- Output rate limit
- Limit the rate of outbound logs to selected outputs, for example, to match the network or storage capacity of an output. The output rate limit controls the aggregated per-output rate.
- Input rate limit
- Limit the per-container rate of log collection for selected containers.
14.1.3. Configuring log forwarder output rate limits Copiar enlaceEnlace copiado en el portapapeles!
You can limit the rate of outbound logs to a specified output by configuring the ClusterLogForwarder custom resource (CR).
Prerequisites
- You have installed the Red Hat OpenShift Logging Operator.
- You have administrator permissions.
Procedure
Add a
maxRecordsPerSecondlimit value to theClusterLogForwarderCR for a specified output.The following example shows how to configure a per collector output rate limit for a Kafka broker output named
kafka-example:Example
ClusterLogForwarderCRCopy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- The output name.
- 2
- The type of output.
- 3
- The log output rate limit. This value sets the maximum Quantity of logs that can be sent to the Kafka broker per second. This value is not set by default. The default behavior is best effort, and records are dropped if the log forwarder cannot keep up. If this value is
0, no logs are forwarded.
Apply the
ClusterLogForwarderCR:Example command
oc apply -f <filename>.yaml
$ oc apply -f <filename>.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow
14.1.4. Configuring log forwarder input rate limits Copiar enlaceEnlace copiado en el portapapeles!
You can limit the rate of incoming logs that are collected by configuring the ClusterLogForwarder custom resource (CR). You can set input limits on a per-container or per-namespace basis.
Prerequisites
- You have installed the Red Hat OpenShift Logging Operator.
- You have administrator permissions.
Procedure
Add a
maxRecordsPerSecondlimit value to theClusterLogForwarderCR for a specified input.The following examples show how to configure input rate limits for different scenarios:
Example
ClusterLogForwarderCR that sets a per-container limit for containers with certain labelsCopy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- The input name.
- 2
- A list of labels. If these labels match labels that are applied to a pod, the per-container limit specified in the
maxRecordsPerSecondfield is applied to those containers. - 3
- Configures the rate limit. Setting the
maxRecordsPerSecondfield to0means that no logs are collected for the container. Setting themaxRecordsPerSecondfield to some other value means that a maximum of that number of records per second are collected for the container.
Example
ClusterLogForwarderCR that sets a per-container limit for containers in selected namespacesCopy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- The input name.
- 2
- A list of namespaces. The per-container limit specified in the
maxRecordsPerSecondfield is applied to all containers in the namespaces listed. - 3
- Configures the rate limit. Setting the
maxRecordsPerSecondfield to10means that a maximum of 10 records per second are collected for each container in the namespaces listed.
Apply the
ClusterLogForwarderCR:Example command
oc apply -f <filename>.yaml
$ oc apply -f <filename>.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow
14.2. Filtering logs by content Copiar enlaceEnlace copiado en el portapapeles!
Collecting all logs from a cluster might produce a large amount of data, which can be expensive to transport and store.
You can reduce the volume of your log data by filtering out low priority data that does not need to be stored. Logging provides content filters that you can use to reduce the volume of log data.
Content filters are distinct from input selectors. input selectors select or ignore entire log streams based on source metadata. Content filters edit log streams to remove and modify records based on the record content.
Log data volume can be reduced by using one of the following methods:
14.2.1. Configuring content filters to drop unwanted log records Copiar enlaceEnlace copiado en el portapapeles!
When the drop filter is configured, the log collector evaluates log streams according to the filters before forwarding. The collector drops unwanted log records that match the specified configuration.
Prerequisites
- You have installed the Red Hat OpenShift Logging Operator.
- You have administrator permissions.
-
You have created a
ClusterLogForwardercustom resource (CR).
Procedure
Add a configuration for a filter to the
filtersspec in theClusterLogForwarderCR.The following example shows how to configure the
ClusterLogForwarderCR to drop log records based on regular expressions:Example
ClusterLogForwarderCRCopy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Specifies the type of filter. The
dropfilter drops log records that match the filter configuration. - 2
- Specifies configuration options for applying the
dropfilter. - 3
- Specifies the configuration for tests that are used to evaluate whether a log record is dropped.
- If all the conditions specified for a test are true, the test passes and the log record is dropped.
-
When multiple tests are specified for the
dropfilter configuration, if any of the tests pass, the record is dropped. - If there is an error evaluating a condition, for example, the field is missing from the log record being evaluated, that condition evaluates to false.
- 4
- Specifies a dot-delimited field path, which is a path to a field in the log record. The path can contain alpha-numeric characters and underscores (
a-zA-Z0-9_), for example,.kubernetes.namespace_name. If segments contain characters outside of this range, the segment must be in quotes, for example,.kubernetes.labels."foo.bar-bar/baz". You can include multiple field paths in a singletestconfiguration, but they must all evaluate to true for the test to pass and thedropfilter to be applied. - 5
- Specifies a regular expression. If log records match this regular expression, they are dropped. You can set either the
matchesornotMatchescondition for a singlefieldpath, but not both. - 6
- Specifies a regular expression. If log records do not match this regular expression, they are dropped. You can set either the
matchesornotMatchescondition for a singlefieldpath, but not both. - 7
- Specifies the pipeline that the
dropfilter is applied to.
Apply the
ClusterLogForwarderCR by running the following command:oc apply -f <filename>.yaml
$ oc apply -f <filename>.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Additional examples
The following additional example shows how you can configure the drop filter to only keep higher priority log records:
In addition to including multiple field paths in a single test configuration, you can also include additional tests that are treated as OR checks. In the following example, records are dropped if either test configuration evaluates to true. However, for the second test configuration, both field specs must be true for it to be evaluated to true:
14.2.2. Configuring content filters to prune log records Copiar enlaceEnlace copiado en el portapapeles!
When the prune filter is configured, the log collector evaluates log streams according to the filters before forwarding. The collector prunes log records by removing low value fields such as pod annotations.
Prerequisites
- You have installed the Red Hat OpenShift Logging Operator.
- You have administrator permissions.
-
You have created a
ClusterLogForwardercustom resource (CR).
Procedure
Add a configuration for a filter to the
prunespec in theClusterLogForwarderCR.The following example shows how to configure the
ClusterLogForwarderCR to prune log records based on field paths:ImportantIf both are specified, records are pruned based on the
notInarray first, which takes precedence over theinarray. After records have been pruned by using thenotInarray, they are then pruned by using theinarray.Example
ClusterLogForwarderCRCopy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Specify the type of filter. The
prunefilter prunes log records by configured fields. - 2
- Specify configuration options for applying the
prunefilter. TheinandnotInfields are specified as arrays of dot-delimited field paths, which are paths to fields in log records. These paths can contain alpha-numeric characters and underscores (a-zA-Z0-9_), for example,.kubernetes.namespace_name. If segments contain characters outside of this range, the segment must be in quotes, for example,.kubernetes.labels."foo.bar-bar/baz". - 3
- Optional: Any fields that are specified in this array are removed from the log record.
- 4
- Optional: Any fields that are not specified in this array are removed from the log record.
- 5
- Specify the pipeline that the
prunefilter is applied to.
Apply the
ClusterLogForwarderCR by running the following command:oc apply -f <filename>.yaml
$ oc apply -f <filename>.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow
14.3. Filtering logs by metadata Copiar enlaceEnlace copiado en el portapapeles!
You can filter logs in the ClusterLogForwarder CR to select or ignore an entire log stream based on the metadata by using the input selector. As an administrator or developer, you can include or exclude the log collection to reduce the memory and CPU load on the collector.
You can use this feature only if the Vector collector is set up in your logging deployment.
input spec filtering is different from content filtering. input selectors select or ignore entire log streams based on the source metadata. Content filters edit the log streams to remove and modify the records based on the record content.
14.3.1. Filtering application logs at input by including or excluding the namespace or container name Copiar enlaceEnlace copiado en el portapapeles!
You can include or exclude the application logs based on the namespace and container name by using the input selector.
Prerequisites
- You have installed the Red Hat OpenShift Logging Operator.
- You have administrator permissions.
-
You have created a
ClusterLogForwardercustom resource (CR).
Procedure
Add a configuration to include or exclude the namespace and container names in the
ClusterLogForwarderCR.The following example shows how to configure the
ClusterLogForwarderCR to include or exclude namespaces and container names:Example
ClusterLogForwarderCRCopy to Clipboard Copied! Toggle word wrap Toggle overflow Apply the
ClusterLogForwarderCR by running the following command:oc apply -f <filename>.yaml
$ oc apply -f <filename>.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow
The excludes option takes precedence over includes.
14.3.2. Filtering application logs at input by including either the label expressions or matching label key and values Copiar enlaceEnlace copiado en el portapapeles!
You can include the application logs based on the label expressions or a matching label key and its values by using the input selector.
Prerequisites
- You have installed the Red Hat OpenShift Logging Operator.
- You have administrator permissions.
-
You have created a
ClusterLogForwardercustom resource (CR).
Procedure
Add a configuration for a filter to the
inputspec in theClusterLogForwarderCR.The following example shows how to configure the
ClusterLogForwarderCR to include logs based on label expressions or matched label key/values:Example
ClusterLogForwarderCRCopy to Clipboard Copied! Toggle word wrap Toggle overflow Apply the
ClusterLogForwarderCR by running the following command:oc apply -f <filename>.yaml
$ oc apply -f <filename>.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow
14.3.3. Filtering the audit and infrastructure log inputs by source Copiar enlaceEnlace copiado en el portapapeles!
You can define the list of audit and infrastructure sources to collect the logs by using the input selector.
Prerequisites
- You have installed the Red Hat OpenShift Logging Operator.
- You have administrator permissions.
-
You have created a
ClusterLogForwardercustom resource (CR).
Procedure
Add a configuration to define the
auditandinfrastructuresources in theClusterLogForwarderCR.The following example shows how to configure the
ClusterLogForwarderCR to defineaduitandinfrastructuresources:Example
ClusterLogForwarderCRCopy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Specifies the list of infrastructure sources to collect. The valid sources include:
-
node: Journal log from the node -
container: Logs from the workloads deployed in the namespaces
-
- 2
- Specifies the list of audit sources to collect. The valid sources include:
-
kubeAPI: Logs from the Kubernetes API servers -
openshiftAPI: Logs from the OpenShift API servers -
auditd: Logs from a node auditd service -
ovn: Logs from an open virtual network service
-
Apply the
ClusterLogForwarderCR by running the following command:oc apply -f <filename>.yaml
$ oc apply -f <filename>.yamlCopy to Clipboard Copied! Toggle word wrap Toggle overflow