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 Copy linkLink copied to clipboard!
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-operators
catalog to theOperatorHub
custom resource (CR) as shown in "Configuring OpenShift Container Platform to use Red Hat Operators".
1.2. Installation by using the CLI Copy linkLink copied to clipboard!
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 Copy linkLink copied to clipboard!
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
Namespace
object for Loki Operator:Example
Namespace
objectCopy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- You must specify
openshift-operators-redhat
as the namespace. To enable monitoring for the operator, configure Cluster Monitoring Operator to scrape metrics from theopenshift-operators-redhat
namespace and not theopenshift-operators
namespace. Theopenshift-operators
namespace 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 the
openshift-operators-redhat
namespace.
Apply the
Namespace
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 Create an
OperatorGroup
object.Example
OperatorGroup
objectCopy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- You must specify
openshift-operators-redhat
as the namespace.
Apply the
OperatorGroup
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 Create a
Subscription
object for Loki Operator:Example
Subscription
objectCopy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- You must specify
openshift-operators-redhat
as the namespace. - 2
- Specify
stable-6.<y>
as the channel. - 3
- 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 toManual
, you must manually approve pending updates. - 4
- Specify
redhat-operators
as the value. If your OpenShift Container Platform cluster is installed on a restricted network, also known as a disconnected cluster, specify the name of theCatalogSource
object that you created when you configured Operator Lifecycle Manager (OLM).
Apply the
Subscription
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 Create a
namespace
object for deploy the LokiStack:Example
namespace
objectCopy to Clipboard Copied! Toggle word wrap Toggle overflow Apply the
namespace
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 Create a secret with the credentials to access the object storage. For example, create a secret to access Amazon Web Services (AWS) s3.
Example
Secret
objectCopy to Clipboard Copied! Toggle word wrap Toggle overflow ImportantIf 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
Secret
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 Create a
LokiStack
CR:Example
LokiStack
CRCopy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Use the name
logging-loki
. - 2
- You must specify
openshift-logging
as the namespace. - 3
- Specify the deployment size. Supported size options for production instances of Loki are
1x.extra-small
,1x.small
, or1x.medium
. Additionally,1x.pico
is 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 the
oc get storageclasses
command. - 8
- The
openshift-logging
mode 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
LokiStack
CR 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 Copy linkLink copied to clipboard!
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-logging
namespace.
Procedure
Create an
OperatorGroup
object:Example
OperatorGroup
objectCopy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- You must specify
openshift-logging
as the namespace.
Apply the
OperatorGroup
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 Create a
Subscription
object for Red Hat OpenShift Logging Operator:Example
Subscription
objectCopy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- You must specify
openshift-logging
as the namespace. - 2
- Specify
stable-6.<y>
as the channel. - 3
- 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 toManual
, you must manually approve pending updates. - 4
- Specify
redhat-operators
as the value. If your OpenShift Container Platform cluster is installed on a restricted network, also known as a disconnected cluster, specify the name of theCatalogSource
object that you created when you configured Operator Lifecycle Manager (OLM).
Apply the
Subscription
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 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
ClusterLogForwarder
CR:Example
ClusterLogForwarder
CRCopy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- You must specify the
openshift-logging
namespace. - 2
- Specify the name of the service account created before.
- 3
- Select the
lokiStack
output type to send logs to theLokiStack
instance. - 4
- Point the
ClusterLogForwarder
to theLokiStack
instance created earlier. - 5
- Select the log output types you want to send to the
LokiStack
instance.
Apply the
ClusterLogForwarder CR
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.3. Installing the logging UI plugin by using the CLI Copy linkLink copied to clipboard!
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
UIPlugin
custom resource (CR):Example
UIPlugin
CRCopy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Set
name
tologging
. - 2
- Set
type
toLogging
. - 3
- The
name
value must match the name of your LokiStack instance. If you did not install LokiStack in theopenshift-logging
namespace, set the LokiStack namespace under thelokiStack
configuration. - 4
schema
is one ofotel
,viaq
, orselect
. The default isviaq
if no value is specified. When you chooseselect
, you can select the mode in the UI when you run a query.
NoteThese are the known issues for the logging UI plugin - for more information, see OU-587.
-
The
schema
feature 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 theviaq
attribute, ignoring any other values that might be set. -
Non-administrator users cannot query logs using the
otel
attribute 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_text
Otel attribute is not set.
Apply the
UIPlugin
CR 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 Copy linkLink copied to clipboard!
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 Copy linkLink copied to clipboard!
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.
ImportantThe 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 theNamespace
object. You must select this option to ensure that cluster monitoring scrapes theopenshift-operators-redhat
namespace.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.
NoteAn Operator might display a
Failed
status before the installation completes. If the Operator install completes with anInstallSucceeded
message, 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-logging
namespace:Example
namespace
objectCopy 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
Secret
objectCopy to Clipboard Copied! Toggle word wrap Toggle overflow ImportantIf 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
LokiStack
CR:Example
LokiStack
CRCopy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Use the name
logging-loki
. - 2
- You must specify
openshift-logging
as the namespace. - 3
- Specify the deployment size. Supported size options for production instances of Loki are
1x.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 the
oc get storageclasses
command. - 7
- The
openshift-logging
mode 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
LokiStack
instance. -
In the Status column, verify that you see the message
Condition: Ready
with a green checkmark.
1.3.2. Installing Red Hat OpenShift Logging Operator by using the web console Copy linkLink copied to clipboard!
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 theNamespace
object. You must select this option to ensure that cluster monitoring scrapes theopenshift-logging
namespace.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.
NoteAn Operator might display a
Failed
status before the installation completes. If the operator installation completes with anInstallSucceeded
message, 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
ServiceAccount
objectapiVersion: 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
ClusterRoleBinding
objects 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
ClusterRoleBinding
resources.Example
ClusterRoleBinding
resourcesCopy 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
ClusterLogForwarder
CR:Example
ClusterLogForwarder
CRCopy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- You must specify
openshift-logging
as the namespace. - 2
- Specify the name of the service account created earlier.
- 3
- Select the
lokiStack
output type to send logs to theLokiStack
instance. - 4
- Point the
ClusterLogForwarder
to theLokiStack
instance created earlier. - 5
- Select the log output types you want to send to the
LokiStack
instance.
- Click Create.
Verification
-
In the ClusterLogForwarder tab verify that you see your
ClusterLogForwarder
instance. 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 Copy linkLink copied to clipboard!
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
UIPlugin
resource and click Create Instance. Select the YAML view, and then use the following template to create a
UIPlugin
custom resource (CR):Example
UIPlugin
CRCopy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- Set
name
tologging
. - 2
- Set
type
toLogging
. - 3
- The
name
value must match the name of your LokiStack instance. If you did not install LokiStack in theopenshift-logging
namespace, set the LokiStack namespace under thelokiStack
configuration. - 4
schema
is one ofotel
,viaq
, orselect
. The default isviaq
if no value is specified. When you chooseselect
, you can select the mode in the UI when you run a query.
NoteThese are the known issues for the logging UI plugin - for more information, see OU-587.
-
The
schema
feature 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 theviaq
attribute, ignoring any other values that might be set. -
Non-administrator users cannot query logs using the
otel
attribute 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_text
Otel 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.