Este conteúdo não está disponível no idioma selecionado.
Chapter 1. Installing Logging
OpenShift Container Platform Operators use custom resources (CRs) to manage applications and their components. You provide high-level configuration and settings through the CR. The Operator translates high-level directives into low-level actions, based on best practices embedded within the logic of the Operator. A custom resource definition (CRD) defines a CR and lists all the configurations available to users of the Operator. Installing an Operator creates the CRDs to generate CRs.
To get started with logging, you must install the following Operators:
- Loki Operator to manage your log store.
- Red Hat OpenShift Logging Operator to manage log collection and forwarding.
- Cluster Observability Operator (COO) to manage visualization.
You can use either the OpenShift Container Platform web console or the OpenShift Container Platform CLI to install or configure logging.
You must configure the Red Hat OpenShift Logging Operator after the Loki Operator.
1.1. Prerequisites
- If you are using OKD, you have downloaded the pull secret from Red Hat OpenShift Cluster Manager as shown in "Obtaining the installation program" in the installation documentation for your platform. - If you have the pull secret, add the - redhat-operatorscatalog to the- OperatorHubcustom resource (CR) as shown in "Configuring OpenShift Container Platform to use Red Hat Operators".
1.2. Installation by using the CLI
The following sections describe installing the Loki Operator and the Red Hat OpenShift Logging Operator by using the CLI.
1.2.1. Installing the Loki Operator by using the CLI
					Install Loki Operator on your OpenShift Container Platform cluster to manage the log store Loki by using the OpenShift Container Platform command-line interface (CLI). You can deploy and configure the Loki log store by reconciling the resource LokiStack with the Loki Operator.
				
Prerequisites
- You have administrator permissions.
- 
							You installed the OpenShift CLI (oc).
- You have access to a supported object store. For example: AWS S3, Google Cloud Storage, Azure, Swift, Minio, or OpenShift Data Foundation.
Procedure
- Create a - Namespaceobject for Loki Operator:- Example - Namespaceobject- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - 1
- You must specifyopenshift-operators-redhatas the namespace. To enable monitoring for the operator, configure Cluster Monitoring Operator to scrape metrics from theopenshift-operators-redhatnamespace and not theopenshift-operatorsnamespace. Theopenshift-operatorsnamespace might contain community operators, which are untrusted and could publish a metric with the same name as an OpenShift Container Platform metric, causing conflicts.
- 2
- A string value that specifies the label as shown to ensure that cluster monitoring scrapes theopenshift-operators-redhatnamespace.
 
- Apply the - Namespaceobject by running the following command:- oc apply -f <filename>.yaml - $ oc apply -f <filename>.yaml- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Create an - OperatorGroupobject.- Example - OperatorGroupobject- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - 1
- You must specifyopenshift-operators-redhatas the namespace.
 
- Apply the - OperatorGroupobject by running the following command:- oc apply -f <filename>.yaml - $ oc apply -f <filename>.yaml- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Create a - Subscriptionobject for Loki Operator:- Example - Subscriptionobject- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - 1
- You must specifyopenshift-operators-redhatas the namespace.
- 2
- Specifystable-6.<y>as the channel.
- 3
- If the approval strategy in the subscription is set toAutomatic, the update process initiates as soon as a new operator version is available in the selected channel. If the approval strategy is set toManual, you must manually approve pending updates.
- 4
- Specifyredhat-operatorsas the value. If your OpenShift Container Platform cluster is installed on a restricted network, also known as a disconnected cluster, specify the name of theCatalogSourceobject that you created when you configured Operator Lifecycle Manager (OLM).
 
- Apply the - Subscriptionobject by running the following command:- oc apply -f <filename>.yaml - $ oc apply -f <filename>.yaml- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Create a - namespaceobject for deploy the LokiStack:- Example - namespaceobject- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Apply the - namespaceobject by running the following command:- oc apply -f <filename>.yaml - $ oc apply -f <filename>.yaml- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Create a secret with the credentials to access the object storage. For example, create a secret to access Amazon Web Services (AWS) s3. - Example - Secretobject- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow Important- If there is no retention period defined on the s3 bucket or in the LokiStack custom resource (CR), then the logs are not pruned and they stay in the s3 bucket forever, which might fill up the s3 storage. 
- Apply the - Secretobject by running the following command:- oc apply -f <filename>.yaml - $ oc apply -f <filename>.yaml- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Create a - LokiStackCR:- Example - LokiStackCR- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - 1
- Use the namelogging-loki.
- 2
- You must specifyopenshift-loggingas the namespace.
- 3
- Specify the deployment size. Supported size options for production instances of Loki are1x.extra-small,1x.small, or1x.medium. Additionally,1x.picois supported starting with logging 6.1.
- 4
- For new installations this date should be set to the equivalent of "yesterday", as this will be the date from when the schema takes effect.
- 5
- Specify the name of your log store secret.
- 6
- Specify the corresponding storage type.
- 7
- Specify the name of a storage class for temporary storage. For best performance, specify a storage class that allocates block storage. You can list the available storage classes for your cluster by using theoc get storageclassescommand.
- 8
- Theopenshift-loggingmode is the default tenancy mode where a tenant is created for log types, such as audit, infrastructure, and application. This enables access control for individual users and user groups to different log streams.
 
- Apply the - LokiStackCR object by running the following command:- oc apply -f <filename>.yaml - $ oc apply -f <filename>.yaml- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
Verification
- Verify the installation by running the following command: - oc get pods -n openshift-logging - $ oc get pods -n openshift-logging- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - Example output - Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
1.2.2. Installing Red Hat OpenShift Logging Operator by using the CLI
					Install Red Hat OpenShift Logging Operator on your OpenShift Container Platform cluster to collect and forward logs to a log store by using the OpenShift CLI (oc).
				
Prerequisites
- You have administrator permissions.
- 
							You installed the OpenShift CLI (oc).
- You installed and configured Loki Operator.
- 
							You have created the openshift-loggingnamespace.
Procedure
- Create an - OperatorGroupobject:- Example - OperatorGroupobject- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - 1
- You must specifyopenshift-loggingas the namespace.
 
- Apply the - OperatorGroupobject by running the following command:- oc apply -f <filename>.yaml - $ oc apply -f <filename>.yaml- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Create a - Subscriptionobject for Red Hat OpenShift Logging Operator:- Example - Subscriptionobject- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - 1
- You must specifyopenshift-loggingas the namespace.
- 2
- Specifystable-6.<y>as the channel.
- 3
- If the approval strategy in the subscription is set toAutomatic, the update process initiates as soon as a new operator version is available in the selected channel. If the approval strategy is set toManual, you must manually approve pending updates.
- 4
- Specifyredhat-operatorsas the value. If your OpenShift Container Platform cluster is installed on a restricted network, also known as a disconnected cluster, specify the name of theCatalogSourceobject that you created when you configured Operator Lifecycle Manager (OLM).
 
- Apply the - Subscriptionobject by running the following command:- oc apply -f <filename>.yaml - $ oc apply -f <filename>.yaml- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Create a service account to be used by the log collector: - oc create sa logging-collector -n openshift-logging - $ oc create sa logging-collector -n openshift-logging- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Assign the necessary permissions to the service account for the collector to be able to collect and forward logs. In this example, the collector is provided permissions to collect logs from both infrastructure and application logs. - oc adm policy add-cluster-role-to-user logging-collector-logs-writer -z logging-collector -n openshift-logging oc adm policy add-cluster-role-to-user collect-application-logs -z logging-collector -n openshift-logging oc adm policy add-cluster-role-to-user collect-infrastructure-logs -z logging-collector -n openshift-logging - $ oc adm policy add-cluster-role-to-user logging-collector-logs-writer -z logging-collector -n openshift-logging $ oc adm policy add-cluster-role-to-user collect-application-logs -z logging-collector -n openshift-logging $ oc adm policy add-cluster-role-to-user collect-infrastructure-logs -z logging-collector -n openshift-logging- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Create a - ClusterLogForwarderCR:- Example - ClusterLogForwarderCR- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - 1
- You must specify theopenshift-loggingnamespace.
- 2
- Specify the name of the service account created before.
- 3
- Select thelokiStackoutput type to send logs to theLokiStackinstance.
- 4
- Point theClusterLogForwarderto theLokiStackinstance created earlier.
- 5
- Select the log output types you want to send to theLokiStackinstance.
 
- Apply the - ClusterLogForwarder CRobject by running the following command:- oc apply -f <filename>.yaml - $ oc apply -f <filename>.yaml- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
Verification
- Verify the installation by running the following command: - oc get pods -n openshift-logging - $ oc get pods -n openshift-logging- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - Example output - Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
1.2.3. Installing the logging UI plugin by using the CLI
Install the logging UI plugin by using the command-line interface (CLI) so that you can visualize logs.
Prerequisites
- You have administrator permissions.
- 
							You installed the OpenShift CLI (oc).
- You installed and configured Loki Operator.
Procedure
- Install the Cluster Observability Operator. For more information, see Installing the Cluster Observability Operator.
- Create a - UIPlugincustom resource (CR):- Example - UIPluginCR- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - 1
- Setnametologging.
- 2
- SettypetoLogging.
- 3
- Thenamevalue must match the name of your LokiStack instance. If you did not install LokiStack in theopenshift-loggingnamespace, set the LokiStack namespace under thelokiStackconfiguration.
- 4
- schemais one of- otel,- viaq, or- select. The default is- viaqif no value is specified. When you choose- select, you can select the mode in the UI when you run a query.
 Note- These are the known issues for the logging UI plugin - for more information, see OU-587. - 
										The schemafeature is only supported in Red Hat OpenShift Logging 4.15 and later. In earlier versions of Red Hat OpenShift Logging, the logging UI plugin will only use theviaqattribute, ignoring any other values that might be set.
- 
										Non-administrator users cannot query logs using the otelattribute with logging for Red Hat OpenShift versions 5.8 to 6.2. This issue will be fixed in a future logging release. (LOG-6589)
- 
										In logging for Red Hat OpenShift version 5.9, the severity_textOtel attribute is not set.
 
- Apply the - UIPluginCR object by running the following command:- oc apply -f <filename>.yaml - $ oc apply -f <filename>.yaml- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
Verification
- Access the Red Hat OpenShift Logging web console, and refresh the page if a pop-up message instructs you to do so.
- 
							Navigate to the Observe Logs panel, where you can run LogQL queries. You can also query logs for individual pods from the Aggregated Logs tab of a specific pod. 
1.3. Installation by using the web console
The following sections describe installing the Loki Operator and the Red Hat OpenShift Logging Operator by using the web console.
1.3.1. Installing Loki Operator by using the web console
					Install Loki Operator on your OpenShift Container Platform cluster to manage the log store Loki from the OperatorHub by using the OpenShift Container Platform web console. You can deploy and configure the Loki log store by reconciling the resource LokiStack with the Loki Operator.
				
Prerequisites
- You have administrator permissions.
- You have access to the OpenShift Container Platform web console.
- You have access to a supported object store (AWS S3, Google Cloud Storage, Azure, Swift, Minio, OpenShift Data Foundation).
Procedure
- 
							In the OpenShift Container Platform web console Administrator perspective, go to Operators OperatorHub. 
- Type Loki Operator in the Filter by keyword field. Click Loki Operator in the list of available Operators, and then click Install. Important- The Community Loki Operator is not supported by Red Hat. 
- Select stable-x.y as the Update channel. - The Loki Operator must be deployed to the global Operator group namespace - openshift-operators-redhat, so the Installation mode and Installed Namespace are already selected. If this namespace does not already exist, it will be created for you.
- Select Enable Operator-recommended cluster monitoring on this namespace. - This option sets the - openshift.io/cluster-monitoring: "true"label in the- Namespaceobject. You must select this option to ensure that cluster monitoring scrapes the- openshift-operators-redhatnamespace.
- For Update approval select Automatic, then click Install. - If the approval strategy in the subscription is set to Automatic, the update process initiates as soon as a new Operator version is available in the selected channel. If the approval strategy is set to Manual, you must manually approve pending updates. Note- An Operator might display a - Failedstatus before the installation completes. If the Operator install completes with an- InstallSucceededmessage, refresh the page.
- While the Operator installs, create the namespace to which the log store will be deployed. - Click + in the top right of the screen to access the Import YAML page.
- Add the YAML definition for the - openshift-loggingnamespace:- Example - namespaceobject- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Click Create.
 
- Create a secret with the credentials to access the object storage. - Click + in the top right of the screen to access the Import YAML page.
- Add the YAML definition for the secret. For example, create a secret to access Amazon Web Services (AWS) s3: - Example - Secretobject- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow Important- If there is no retention period defined on the s3 bucket or in the LokiStack custom resource (CR), then the logs are not pruned and they stay in the s3 bucket forever, which might fill up the s3 storage. 
- Click Create.
 
- Navigate to the Installed Operators page. Select the Loki Operator under the Provided APIs find the LokiStack resource and click Create Instance.
- Select YAML view, and then use the following template to create a - LokiStackCR:- Example - LokiStackCR- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - 1
- Use the namelogging-loki.
- 2
- You must specifyopenshift-loggingas the namespace.
- 3
- Specify the deployment size. Supported size options for production instances of Loki are1x.extra-small,1x.small, or1x.medium. Additionally, 1x.pico is supported starting with logging 6.1.
- 4
- Specify the name of your log store secret.
- 5
- Specify the corresponding storage type.
- 6
- Specify the name of a storage class for temporary storage. For best performance, specify a storage class that allocates block storage. You can list the available storage classes for your cluster by using theoc get storageclassescommand.
- 7
- Theopenshift-loggingmode is the default tenancy mode where a tenant is created for log types, such as audit, infrastructure, and application. This enables access control for individual users and user groups to different log streams.
 
- Click Create.
Verification
- 
							In the LokiStack tab veriy that you see your LokiStackinstance.
- 
							In the Status column, verify that you see the message Condition: Readywith a green checkmark.
1.3.2. Installing Red Hat OpenShift Logging Operator by using the web console
Install Red Hat OpenShift Logging Operator on your OpenShift Container Platform cluster to collect and forward logs to a log store from the OperatorHub by using the OpenShift Container Platform web console.
Prerequisites
- You have administrator permissions.
- You have access to the OpenShift Container Platform web console.
- You installed and configured Loki Operator.
Procedure
- 
							In the OpenShift Container Platform web console Administrator perspective, go to Operators OperatorHub. 
- Type Red Hat OpenShift Logging Operator in the Filter by keyword field. Click Red Hat OpenShift Logging Operator in the list of available Operators, and then click Install.
- Select stable-x.y as the Update channel. The latest version is already selected in the Version field. - The Red Hat OpenShift Logging Operator must be deployed to the logging namespace - openshift-logging, so the Installation mode and Installed Namespace are already selected. If this namespace does not already exist, it will be created for you.
- Select Enable Operator-recommended cluster monitoring on this namespace. - This option sets the - openshift.io/cluster-monitoring: "true"label in the- Namespaceobject. You must select this option to ensure that cluster monitoring scrapes the- openshift-loggingnamespace.
- For Update approval select Automatic, then click Install. - If the approval strategy in the subscription is set to Automatic, the update process initiates as soon as a new operator version is available in the selected channel. If the approval strategy is set to Manual, you must manually approve pending updates. Note- An Operator might display a - Failedstatus before the installation completes. If the operator installation completes with an- InstallSucceededmessage, refresh the page.
- While the operator installs, create the service account that will be used by the log collector to collect the logs. - Click the + in the top right of the screen to access the Import YAML page.
- Enter the YAML definition for the service account. - Example - ServiceAccountobject- apiVersion: v1 kind: ServiceAccount metadata: name: logging-collector namespace: openshift-logging - apiVersion: v1 kind: ServiceAccount metadata: name: logging-collector- 1 - namespace: openshift-logging- 2 - Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Click the Create button.
 
- Create the - ClusterRoleBindingobjects to grant the necessary permissions to the log collector for accessing the logs that you want to collect and to write the log store, for example infrastructure and application logs.- Click the + in the top right of the screen to access the Import YAML page.
- Enter the YAML definition for the - ClusterRoleBindingresources.- Example - ClusterRoleBindingresources- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow 
- Click the Create button.
 
- 
							Go to the Operators Installed Operators page. Select the operator and click the All instances tab. 
- After granting the necessary permissions to the service account, navigate to the Installed Operators page. Select the Red Hat OpenShift Logging Operator under the Provided APIs, find the ClusterLogForwarder resource and click Create Instance.
- Select YAML view, and then use the following template to create a - ClusterLogForwarderCR:- Example - ClusterLogForwarderCR- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - 1
- You must specifyopenshift-loggingas the namespace.
- 2
- Specify the name of the service account created earlier.
- 3
- Select thelokiStackoutput type to send logs to theLokiStackinstance.
- 4
- Point theClusterLogForwarderto theLokiStackinstance created earlier.
- 5
- Select the log output types you want to send to theLokiStackinstance.
 
- Click Create.
Verification
- 
							In the ClusterLogForwarder tab verify that you see your ClusterLogForwarderinstance.
- In the Status column, verify that you see the messages: - 
									Condition: observability.openshift.io/Authorized
- 
									observability.openshift.io/Valid, Ready
 
- 
									
1.3.3. Installing the logging UI plugin by using the web console
Install the logging UI plugin by using the web console so that you can visualize logs.
Prerequisites
- You have administrator permissions.
- You have access to the Red Hat OpenShift Logging web console.
- You installed and configured Loki Operator.
Procedure
- Install the Cluster Observability Operator. For more information, see Installing the Cluster Observability Operator.
- 
							Navigate to the Installed Operators page. Under Provided APIs, select ClusterObservabilityOperator. Find the UIPluginresource and click Create Instance.
- Select the YAML view, and then use the following template to create a - UIPlugincustom resource (CR):- Example - UIPluginCR- Copy to Clipboard Copied! - Toggle word wrap Toggle overflow - 1
- Setnametologging.
- 2
- SettypetoLogging.
- 3
- Thenamevalue must match the name of your LokiStack instance. If you did not install LokiStack in theopenshift-loggingnamespace, set the LokiStack namespace under thelokiStackconfiguration.
- 4
- schemais one of- otel,- viaq, or- select. The default is- viaqif no value is specified. When you choose- select, you can select the mode in the UI when you run a query.
 Note- These are the known issues for the logging UI plugin - for more information, see OU-587. - 
										The schemafeature is only supported in Red Hat OpenShift Logging 4.15 and later. In earlier versions of Red Hat OpenShift Logging, the logging UI plugin will only use theviaqattribute, ignoring any other values that might be set.
- 
										Non-administrator users cannot query logs using the otelattribute with logging for Red Hat OpenShift versions 5.8 to 6.2. This issue will be fixed in a future logging release. (LOG-6589)
- 
										In logging for Red Hat OpenShift version 5.9, the severity_textOtel attribute is not set.
 
- Click Create.
Verification
- Refresh the page when a pop-up message instructs you to do so.
- 
							Navigate to the Observe Logs panel, where you can run LogQL queries. You can also query logs for individual pods from the Aggregated Logs tab of a specific pod.