Override ConfigMap to Modify the Storage Retention Period in Project Grafana Loki
DKP configures Project Grafana Loki to retain log metadata and logs for 1 week, using the Compactor. This retention policy can be customized.
The minimum retention period is 24h.
To customize the retention policy using configOverrides
, run these commands on the management cluster:
Determine the namespace of the workspace that your project is in. You can use the
dkp get workspaces
command to see the list of workspace names and their corresponding namespaces.CODEdkp get workspaces
Copy the value under the
NAMESPACE
column for your workspace. This may NOT be identical to the Display Name of theWorkspace
.Set the
WORKSPACE_NAMESPACE
variable to the namespace copied in the previous step:CODEexport WORKSPACE_NAMESPACE=<WORKSPACE_NAMESPACE>
Get the namespace of your project:
CODEkubectl get projects --namespace ${WORKSPACE_NAMESPACE}
Copy the value under the
PROJECT NAMESPACE
column for your workspace. This may NOT be identical to the Display Name of theProject
.Set the
PROJECT_NAMESPACE
variable to the namespace copied in the previous step:CODEexport PROJECT_NAMESPACE=<PROJECT_NAMESPACE>
Create a
ConfigMap
with custom configuration values for Grafana Loki. Since the retention configuration is nested in aconfig
string, you must copy the entire block. The following example sets the retention period under to 360 hours (15 days). Refer to Grafana Loki’s Retention Configuration documentation for more information about this field.CODEcat <<EOF | kubectl apply -f - apiVersion: v1 kind: ConfigMap metadata: name: project-grafana-loki-custom-overrides namespace: ${PROJECT_NAMESPACE} data: values.yaml: | loki: structuredConfig: limits_config: retention_period: 360h EOF
Run the following command on the management cluster to reference the
configOverrides
in theproject-grafana-loki
AppDeployment:CODEcat <<EOF | kubectl apply -f - apiVersion: apps.kommander.d2iq.io/v1alpha3 kind: AppDeployment metadata: name: project-grafana-loki namespace: ${PROJECT_NAMESPACE} spec: appRef: name: project-grafana-loki-0.48.6 kind: ClusterApp configOverrides: name: project-grafana-loki-custom-overrides EOF