|
| 1 | +// Module included in the following assemblies: |
| 2 | +// |
| 3 | +// * monitoring/configuring-the-monitoring-stack.adoc |
| 4 | + |
| 5 | +:_content-type: PROCEDURE |
| 6 | +[id="modifying-the-retention-time-for-thanos-ruler-metrics-data_{context}"] |
| 7 | += Modifying the retention time for Thanos Ruler metrics data |
| 8 | + |
| 9 | +By default, for user-defined projects, Thanos Ruler automatically retains metrics data for 24 hours. |
| 10 | +You can modify the retention time to change how long this data is retained by specifying a time value in the `user-workload-monitoring-config` config map in the `openshift-user-workload-monitoring` namespace. |
| 11 | + |
| 12 | +.Prerequisites |
| 13 | + |
| 14 | +* You have installed the OpenShift CLI (`oc`). |
| 15 | +* A cluster administrator has enabled monitoring for user-defined projects. |
| 16 | +* You have access to the cluster as a user with the `cluster-admin` role or as a user with the `user-workload-monitoring-config-edit` role in the `openshift-user-workload-monitoring` project. |
| 17 | +* You have created the `user-workload-monitoring-config` `ConfigMap` object. |
| 18 | +
|
| 19 | +[WARNING] |
| 20 | +==== |
| 21 | +Saving changes to a monitoring config map might restart monitoring processes and redeploy the pods and other resources in the related project. |
| 22 | +The running monitoring processes in that project might also restart. |
| 23 | +==== |
| 24 | + |
| 25 | +.Procedure |
| 26 | + |
| 27 | +. Edit the `user-workload-monitoring-config` `ConfigMap` object in the `openshift-user-workload-monitoring` project: |
| 28 | ++ |
| 29 | +[source,terminal] |
| 30 | +---- |
| 31 | +$ oc -n openshift-user-workload-monitoring edit configmap user-workload-monitoring-config |
| 32 | +---- |
| 33 | + |
| 34 | +. Add the retention time configuration under `data/config.yaml`: |
| 35 | ++ |
| 36 | +[source,yaml] |
| 37 | +---- |
| 38 | +apiVersion: v1 |
| 39 | +kind: ConfigMap |
| 40 | +metadata: |
| 41 | + name: user-workload-monitoring-config |
| 42 | + namespace: openshift-user-workload-monitoring |
| 43 | +data: |
| 44 | + config.yaml: | |
| 45 | + thanosRuler: |
| 46 | + retention: <time_specification> <1> |
| 47 | +---- |
| 48 | ++ |
| 49 | +<1> Specify the retention time in the following format: a number directly followed by `ms` (milliseconds), `s` (seconds), `m` (minutes), `h` (hours), `d` (days), `w` (weeks), or `y` (years). |
| 50 | +You can also combine time values for specific times, such as `1h30m15s`. |
| 51 | +The default is `24h`. |
| 52 | ++ |
| 53 | +The following example sets the retention time to 10 days for Thanos Ruler data: |
| 54 | ++ |
| 55 | +[source,yaml] |
| 56 | +---- |
| 57 | +apiVersion: v1 |
| 58 | +kind: ConfigMap |
| 59 | +metadata: |
| 60 | + name: user-workload-monitoring-config |
| 61 | + namespace: openshift-user-workload-monitoring |
| 62 | +data: |
| 63 | + config.yaml: | |
| 64 | + thanosRuler: |
| 65 | + retention: 10d |
| 66 | +---- |
| 67 | + |
| 68 | +. Save the file to apply the changes. The pods affected by the new configuration automatically restart. |
0 commit comments