Skip to content

Commit 5df8a8f

Browse files
authored
Merge pull request #95675 from eromanova97/manual-cp-of-95075-to-6.0
[standalone-logging-docs-6.0] OBSDOCS-1857: Fix Loki retention module and remove duplicate
2 parents ec8ca4a + 47551d2 commit 5df8a8f

File tree

3 files changed

+39
-134
lines changed

3 files changed

+39
-134
lines changed

configuring/configuring-lokistack-storage.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ include::snippets/loki-statement-snip.adoc[leveloffset=+1]
2424
include::modules/loki-rbac-rules-permissions.adoc[leveloffset=+2]
2525
include::modules/enabling-loki-alerts.adoc[leveloffset=+2]
2626
include::modules/loki-memberlist-ip.adoc[leveloffset=+2]
27-
include::modules/loki-retention.adoc[leveloffset=+2]
27+
include::modules/logging-loki-retention.adoc[leveloffset=+2]
2828
include::modules/loki-pod-placement.adoc[leveloffset=+2]
2929

3030
[id="performance_{context}"]
Lines changed: 38 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,37 @@
11
// Module included in the following assemblies:
22
//
33
// * observability/logging/log_storage/cluster-logging-loki.adoc
4+
// * configuring/configuring-the-log-store.adoc
45

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

9-
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.
10+
You can configure retention policies based on log streams. You can set retention rules globally, per-tenant, or both. If you configure both, tenant rules apply before global rules.
1011

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

1314
[NOTE]
1415
====
15-
Although logging version 5.9 and higher supports schema v12, v13 is recommended.
16+
* Although logging version 5.9 and later supports schema `v12`, schema `v13` is recommended for future compatibility.
17+
18+
* For cost-effective log pruning, configure retention policies directly on the object storage provider. Use the lifecycle management features of the storage provider to ensure automatic deletion of old logs. This also avoids extra processing from Loki and delete requests to S3.
19+
+
20+
If the object storage does not support lifecycle policies, you must configure LokiStack to enforce retention internally. The supported retention period is up to 30 days.
1621
====
1722

18-
. To enable stream-based retention, create a `LokiStack` CR:
23+
.Prerequisites
24+
25+
* You have administrator permissions.
26+
* You have installed the {loki-op}.
27+
* You have installed the {oc-first}.
28+
29+
.Procedure
30+
31+
. To enable stream-based retention, create a `LokiStack` CR and save it as a YAML file. In the following example, it is called `lokistack.yaml`.
1932
+
20-
.Example global stream-based retention for AWS
33+
--
34+
.Example global stream-based retention for S3
2135
[source,yaml]
2236
----
2337
apiVersion: loki.grafana.com/v1
@@ -27,13 +41,13 @@ metadata:
2741
namespace: openshift-logging
2842
spec:
2943
limits:
30-
global: <1>
31-
retention: <2>
44+
global: # <1>
45+
retention: # <2>
3246
days: 20
3347
streams:
3448
- days: 4
3549
priority: 1
36-
selector: '{kubernetes_namespace_name=~"test.+"}' <3>
50+
selector: '{kubernetes_namespace_name=~"test.+"}' # <3>
3751
- days: 1
3852
priority: 1
3953
selector: '{log_type="infrastructure"}'
@@ -43,20 +57,20 @@ spec:
4357
storage:
4458
schemas:
4559
- effectiveDate: "2020-10-11"
46-
version: v11
60+
version: v13
4761
secret:
4862
name: logging-loki-s3
49-
type: aws
63+
type: s3
5064
storageClassName: gp3-csi
5165
tenants:
5266
mode: openshift-logging
5367
----
54-
<1> Sets retention policy for all log streams. *Note: This field does not impact the retention period for stored logs in object storage.*
55-
<2> Retention is enabled in the cluster when this block is added to the CR.
56-
<3> Contains the link:https://grafana.com/docs/loki/latest/logql/query_examples/#query-examples[LogQL query] used to define the log stream.spec:
57-
limits:
58-
59-
.Example per-tenant stream-based retention for AWS
68+
<1> Set the retention policy for all log streams. This policy does not impact the retention period for stored logs in object storage.
69+
<2> Enable retention in the cluster by adding the `retention` block to the CR.
70+
<3> Specify the link:https://grafana.com/docs/loki/latest/logql/query_examples/#query-examples[LogQL query] to match log streams to the retention rule.
71+
--
72+
+
73+
.Example per-tenant stream-based retention for S3
6074
[source,yaml]
6175
----
6276
apiVersion: loki.grafana.com/v1
@@ -69,13 +83,13 @@ spec:
6983
global:
7084
retention:
7185
days: 20
72-
tenants: <1>
86+
tenants: # <1>
7387
application:
7488
retention:
7589
days: 1
7690
streams:
7791
- days: 4
78-
selector: '{kubernetes_namespace_name=~"test.+"}' <2>
92+
selector: '{kubernetes_namespace_name=~"test.+"}' # <2>
7993
infrastructure:
8094
retention:
8195
days: 5
@@ -88,20 +102,20 @@ spec:
88102
storage:
89103
schemas:
90104
- effectiveDate: "2020-10-11"
91-
version: v11
105+
version: v13
92106
secret:
93107
name: logging-loki-s3
94-
type: aws
108+
type: s3
95109
storageClassName: gp3-csi
96110
tenants:
97111
mode: openshift-logging
98112
----
99-
<1> Sets retention policy by tenant. Valid tenant types are `application`, `audit`, and `infrastructure`.
100-
<2> Contains the link:https://grafana.com/docs/loki/latest/logql/query_examples/#query-examples[LogQL query] used to define the log stream.
101-
102-
2 Apply the `LokiStack` CR:
113+
<1> Set the retention policy per-tenant. Valid tenant types are `application`, `audit`, and `infrastructure`.
114+
<2> Specify the link:https://grafana.com/docs/loki/latest/logql/query_examples/#query-examples[LogQL query] to match log streams to the retention rule.
103115

116+
. Apply the `LokiStack` CR:
117+
+
104118
[source,terminal]
105119
----
106-
$ oc apply -f <filename>.yaml
120+
$ oc apply -f lokistack.yaml
107121
----

modules/loki-retention.adoc

Lines changed: 0 additions & 109 deletions
This file was deleted.

0 commit comments

Comments
 (0)