Skip to content

OBSDOCS-1857: Fix Loki retention module and remove the duplicate module #95075

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: standalone-logging-docs-main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion configuring/configuring-the-log-store.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ include::modules/loki-pod-placement.adoc[leveloffset=+2]

include::modules/logging-loki-reliability-hardening.adoc[leveloffset=+2]

include::modules/loki-retention.adoc[leveloffset=+2]
include::modules/logging-loki-retention.adoc[leveloffset=+2]


include::modules/loki-memberlist-ip.adoc[leveloffset=+2]
Expand Down
50 changes: 31 additions & 19 deletions modules/logging-loki-retention.adoc
Original file line number Diff line number Diff line change
@@ -1,23 +1,35 @@
// Module included in the following assemblies:
//
// * observability/logging/log_storage/cluster-logging-loki.adoc
// * configuring/configuring-the-log-store.adoc

:_mod-docs-content-type: PROCEDURE
[id="logging-loki-retention_{context}"]
= Enabling stream-based retention with Loki

With Logging version 5.6 and higher, you can configure retention policies based on log streams. Rules for these may be set globally, per tenant, or both. If you configure both, tenant rules apply before global rules.
With Logging version 5.6 and higher, you can configure retention policies based on log streams. Rules for these might be set globally, per-tenant, or both. If you configure both, tenant rules apply before global rules.

include::snippets/logging-retention-period-snip.adoc[]

[NOTE]
====
Although logging version 5.9 and higher supports schema v12, v13 is recommended.
* Although logging version 5.9 and higher supports schema v12, v13 is recommended.

* Stream-based retention does not manage the retention for stored logs. You can configure global retention periods for stored logs to a supported maximum of 30 days in your object storage.
====

.Prerequisites

* You have administrator permissions.
* You have installed the {loki-op}.
* You have installed the {oc-first}.

.Procedure

. To enable stream-based retention, create a `LokiStack` CR:
+
.Example global stream-based retention for AWS
--
.Example global stream-based retention for s3
[source,yaml]
----
apiVersion: loki.grafana.com/v1
Expand All @@ -27,13 +39,13 @@ metadata:
namespace: openshift-logging
spec:
limits:
global: <1>
retention: <2>
global: # <1>
retention: # <2>
days: 20
streams:
- days: 4
priority: 1
selector: '{kubernetes_namespace_name=~"test.+"}' <3>
selector: '{kubernetes_namespace_name=~"test.+"}' # <3>
- days: 1
priority: 1
selector: '{log_type="infrastructure"}'
Expand All @@ -43,20 +55,20 @@ spec:
storage:
schemas:
- effectiveDate: "2020-10-11"
version: v11
version: v13
secret:
name: logging-loki-s3
type: aws
type: s3
storageClassName: gp3-csi
tenants:
mode: openshift-logging
----
<1> Sets retention policy for all log streams. *Note: This field does not impact the retention period for stored logs in object storage.*
<1> Sets retention policy for all log streams. This field does not impact the retention period for stored logs in object storage.
<2> Retention is enabled in the cluster when this block is added to the CR.
<3> Contains the link:https://grafana.com/docs/loki/latest/logql/query_examples/#query-examples[LogQL query] used to define the log stream.spec:
limits:

.Example per-tenant stream-based retention for AWS
<3> Contains the link:https://grafana.com/docs/loki/latest/logql/query_examples/#query-examples[LogQL query] used to define the log stream `spec.limits`.
--
+
.Example per-tenant stream-based retention for s3
[source,yaml]
----
apiVersion: loki.grafana.com/v1
Expand All @@ -69,13 +81,13 @@ spec:
global:
retention:
days: 20
tenants: <1>
tenants: # <1>
application:
retention:
days: 1
streams:
- days: 4
selector: '{kubernetes_namespace_name=~"test.+"}' <2>
selector: '{kubernetes_namespace_name=~"test.+"}' # <2>
infrastructure:
retention:
days: 5
Expand All @@ -88,19 +100,19 @@ spec:
storage:
schemas:
- effectiveDate: "2020-10-11"
version: v11
version: v13
secret:
name: logging-loki-s3
type: aws
type: s3
storageClassName: gp3-csi
tenants:
mode: openshift-logging
----
<1> Sets retention policy by tenant. Valid tenant types are `application`, `audit`, and `infrastructure`.
<2> Contains the link:https://grafana.com/docs/loki/latest/logql/query_examples/#query-examples[LogQL query] used to define the log stream.

2 Apply the `LokiStack` CR:

. Apply the `LokiStack` CR:
+
[source,terminal]
----
$ oc apply -f <filename>.yaml
Expand Down
118 changes: 0 additions & 118 deletions modules/loki-retention.adoc

This file was deleted.