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:

    dkp get workspaces
    CODE

    Copy the value under the NAMESPACE column for your workspace.

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

    export WORKSPACE_NAMESPACE=<WORKSPACE_NAMESPACE>
    CODE
  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.

    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
    CODE
  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).

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

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

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