Chapter 1. Create the LokiStack
Create a LokiStack custom resource (CR) to deploy the log store for application, audit, and infrastructure-related logs.
1.1. Prerequisites Copy linkLink copied to clipboard!
- You have installed the Loki Operator.
- You have chosen an initial deployment size based on your cluster size. You will adjust the size after installation based on observed log volume.
- You have configured object storage for LokiStack.
Loki is a horizontally scalable, highly available, multitenant log aggregation system offered as a GA log store for logging for Red Hat OpenShift that can be visualized with the OpenShift Observability UI. The Loki configuration provided by OpenShift Logging is a short-term log store designed to enable users to perform fast troubleshooting with the collected logs. For that purpose, the logging for Red Hat OpenShift configuration of Loki has short-term storage, and is optimized for very recent queries.
For long-term storage or queries over a long time period, users should look to log stores external to their cluster. Loki sizing is only tested and supported for short term storage, for a maximum of 30 days.
1.2. Create a LokiStack custom resource by using the web console Copy linkLink copied to clipboard!
You can create a LokiStack custom resource (CR) 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 the Loki Operator.
Procedure
-
Go to the Operators
Installed Operators page. Click the All instances tab. - From the Create new drop-down list, select LokiStack.
Select YAML view, and then use the following template to create a
LokiStackCR:apiVersion: loki.grafana.com/v1 kind: LokiStack metadata: name: logging-loki namespace: openshift-logging spec: size: 1x.small storage: schemas: - effectiveDate: '2023-10-15' version: v13 secret: name: logging-loki-s3 type: s3 credentialMode: storageClassName: <storage_class_name> tenants: mode: openshift-logging- metadata.name
-
Use the name
logging-loki. - spec.size
-
Specify the deployment size. In the logging 5.8 and later versions, the supported size options for production instances of Loki are
1x.extra-small,1x.small, or1x.medium. - spec.storage.secret.name
- Specify the secret used for your log storage.
- spec.storage.secret.type
- Specify the corresponding storage type.
- spec.storage.secret.credentialMode
-
Optional field, logging 5.9 and later. Supported user-configured values are as follows:
staticis the default authentication mode available for all supported object storage types that use credentials stored in a Secret.tokenfor short-lived tokens retrieved from a credential source. In this mode the static configuration does not contain credentials needed for the object storage. Instead, they are generated during runtime by using a service, which provides shorter-lived credentials and more granular control. This authentication mode is not supported for all object storage types.token-ccois the default value when Loki is running on managed STS mode and using CCO on STS or WIF clusters. - spec.storageClassName
-
Enter the name of a storage class for temporary storage. For best performance, specify a storage class that allocates block storage. Available storage classes for your cluster can be listed by using the
oc get storageclassescommand.
1.3. Calculate sizing after installation Copy linkLink copied to clipboard!
After the logging stack is running, calculate the correct deployment size based on observed metrics rather than estimates.
Prerequisites
- The LokiStack is deployed and collecting logs
- At least 24 hours have passed since installation to capture representative log volume patterns
Procedure
Query the actual log ingestion rate at the Loki distributor using Prometheus:
sum(increase(loki_distributor_bytes_received_total[24h])) / 1024 / 1024 / 1024This query returns the total GB ingested per day. The measurement occurs at the Loki distributor, which is the entry point for all logs. Using a 24-hour window provides a more accurate daily average than shorter sampling periods.
Compare the result against the sizing table and choose the appropriate size:
# Example: The query returns 421 GB # → Requires 1x.small (500 GB per day capacity) # # If the value falls between sizes (for example, 550 GB): # → Either choose 1x.medium (2 TB per day capacity) # → Or choose 1x.small and scale individual components based on observed bottleneckWhen choosing between a larger t-shirt size and scaling individual components, use the observed bottleneck as your guide:
-
If log ingestion is slow or distributors are dropping logs, increase
distributorandingesterreplicas. -
If queries are slow but ingestion is working correctly, increase
querierandqueryFrontendreplicas. If both are struggling, move to the next t-shirt size to scale all components proportionally.
For more information, see LokiStack sizing versus component scaling.
-
If log ingestion is slow or distributors are dropping logs, increase
Update the
LokiStackCR with the new size if needed:spec: size: 1x.small # Updated from initial 1x.extra-smallMonitor CPU and memory utilization to ensure the deployment is not resource-constrained.
NoteResizing a
LokiStacktriggers a rolling restart of components. Plan resizing during maintenance windows.