Skip to content

Commit c994f66

Browse files
authored
Merge pull request #55237 from libander/RHDEVDOCS-4426-mod
RHDEVDOCS-4426 - Loki Retention
2 parents f3c5ed6 + b6242bb commit c994f66

File tree

4 files changed

+123
-0
lines changed

4 files changed

+123
-0
lines changed

logging/.meta-logging-quickref.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Files referenced only apply to versions 5.5+ of logging.
3131
** logging-rn-5.5.2.adoc
3232
** logging-rn-5.5.1.adoc
3333
** logging-rn-5.5.0.adoc
34+
** logging-loki-retention.adoc
3435

3536

3637
* Snippets
@@ -42,3 +43,4 @@ Files referenced only apply to versions 5.5+ of logging.
4243
** logging-supported-config-snip.adoc[]
4344
** logging-approval-strategy-snip.adoc[]
4445
** logging-subscription-object-snip.adoc[
46+
** logging-create-apply-cr-snip.adoc[]

logging/cluster-logging-loki.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ include::modules/cluster-logging-loki-about.adoc[leveloffset=+1]
1010

1111
include::modules/cluster-logging-loki-deploy.adoc[leveloffset=+1]
1212

13+
include::modules/logging-loki-retention.adoc[leveloffset=+1]
14+
1315
include::modules/cluster-logging-forwarding-lokistack.adoc[leveloffset=+1]
1416

1517
include::modules/cluster-logging-troubleshooting-loki-entry-out-of-order-errors.adoc[leveloffset=+2]

modules/logging-loki-retention.adoc

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
// Module included in the following assemblies:
2+
//
3+
:_content-type: PROCEDURE
4+
[id="logging-loki-retention_{context}"]
5+
= Enabling stream-based retention with Loki
6+
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.
7+
8+
. To enable stream-based retention, create or edit the `LokiStack` custom resource (CR):
9+
10+
include::snippets/logging-create-apply-cr-snip.adoc[lines=9..12]
11+
12+
. You can refer to the examples below to configure your LokiStack CR.
13+
14+
.Example global stream-based retention
15+
[source,yaml]
16+
----
17+
apiVersion: loki.grafana.com/v1
18+
kind: LokiStack
19+
metadata:
20+
name: lokistack-sample
21+
namespace: openshift-logging
22+
spec:
23+
limits:
24+
global: <1>
25+
retention: <2>
26+
days: 20
27+
streams:
28+
- days: 4
29+
priority: 1
30+
selector: '{kubernetes_namespace_name=~"test.+"}' <3>
31+
- days: 1
32+
priority: 1
33+
selector: '{log_type="infrastructure"}'
34+
managementState: Managed
35+
replicationFactor: 1
36+
size: 1x.small
37+
storage:
38+
schemas:
39+
- effectiveDate: "2020-10-11"
40+
version: v11
41+
secret:
42+
name: gcs-secret
43+
type: gcstest
44+
storageClassName: standard
45+
tenants:
46+
mode: openshift-logging
47+
----
48+
<1> Sets retention policy for all log streams. *Note: This field does not impact the retention period for stored logs in object storage.*
49+
<2> Retention is enabled in the cluster when this block is added to the CR.
50+
<3> Contains the link:https://grafana.com/docs/loki/latest/logql/query_examples/#query-examples[LogQL query] used to define the log stream.
51+
52+
.Example per-tenant stream-based retention
53+
[source,yaml]
54+
----
55+
apiVersion: loki.grafana.com/v1
56+
kind: LokiStack
57+
metadata:
58+
name: lokistack-sample
59+
namespace: openshift-logging
60+
spec:
61+
limits:
62+
global:
63+
retention:
64+
days: 20
65+
tenants: <1>
66+
application:
67+
retention:
68+
days: 1
69+
streams:
70+
- days: 4
71+
selector: '{kubernetes_namespace_name=~"test.+"}' <2>
72+
infrastructure:
73+
retention:
74+
days: 5
75+
streams:
76+
- days: 1
77+
selector: '{kubernetes_namespace_name=~"openshift-cluster.+"}'
78+
managementState: Managed
79+
replicationFactor: 1
80+
size: 1x.small
81+
storage:
82+
schemas:
83+
- effectiveDate: "2020-10-11"
84+
version: v11
85+
secret:
86+
name: gcs-secret
87+
type: gcs
88+
storageClassName: standard
89+
tenants:
90+
mode: openshift-logging
91+
----
92+
<1> Sets retention policy by tenant. Valid tenant types are `application`, `audit`, and `infrastructure`.
93+
<2> Contains the link:https://grafana.com/docs/loki/latest/logql/query_examples/#query-examples[LogQL query] used to define the log stream.
94+
95+
. Then apply your configuration:
96+
97+
include::snippets/logging-create-apply-cr-snip.adoc[lines=14..17]
98+
99+
[NOTE]
100+
====
101+
This is not for managing the retention for stored logs. Global retention periods for stored logs to a supported maximum of 30 days is configured with your object storage.
102+
====
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Text snippet included in the following assemblies:
2+
//
3+
//
4+
// Text snippet included in the following modules:
5+
//
6+
//
7+
:_content-type: SNIPPET
8+
9+
[source,yaml]
10+
----
11+
oc create -f <file-name>.yaml
12+
----
13+
14+
[source,yaml]
15+
----
16+
oc apply -f <file-name>.yaml
17+
----

0 commit comments

Comments
 (0)