Skip to main content
Skip table of contents

Override ConfigMap to Modify the Storage Retention Period in Workspace Grafana Loki

DKP configures 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:

  1. Execute the following command to get the namespace of your workspace:

    CODE
    dkp get workspaces

    Copy the value under the NAMESPACE column for your workspace.

  2. Set the WORKSPACE_NAMESPACE variable to the namespace copied in the previous step:

    CODE
    export WORKSPACE_NAMESPACE=<WORKSPACE_NAMESPACE>
  3. Create a ConfigMap with custom configuration values for Grafana Loki. Since the retention configuration is nested in a config string, you must copy the entire block. The following example sets the retention period to 360 hours (15 days). Refer to Grafana Loki’s Retention Configuration documentation for more information about this field.

    CODE
    cat <<EOF | kubectl apply -f -
    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: grafana-loki-custom-overrides
      namespace: ${WORKSPACE_NAMESPACE}
    data:
      values.yaml: |
        loki:
          structuredConfig:
            limits_config:
              retention_period: 360h
    EOF
  4. Edit the grafana-loki AppDeployment to set the value of spec.configOverrides.name to grafana-loki-custom-overrides(Refer to Deploy a service with a custom configuration for more information).

    CODE
    dkp edit appdeployment -n ${WORKSPACE_NAMESPACE} grafana-loki

    After your editing is complete, the AppDeployment resembles this example:

    CODE
    apiVersion: apps.kommander.d2iq.io/v1alpha3
    kind: AppDeployment
    metadata:
      name: grafana-loki
      namespace: ${WORKSPACE_NAMESPACE}
    spec:
      appRef:
        name: grafana-loki-0.69.10
        kind: ClusterApp
      configOverrides:
        name: grafana-loki-custom-overrides
JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.