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:

  1. 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.

    dkp get workspaces
    CODE

    Copy the value under the NAMESPACE column for your workspace. This may NOT be identical to the Display Name of the Workspace.

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

    export WORKSPACE_NAMESPACE=<WORKSPACE_NAMESPACE>
    CODE
  3. Get the namespace of your project:

    kubectl get projects --namespace ${WORKSPACE_NAMESPACE}
    CODE

    Copy the value under the PROJECT NAMESPACE column for your workspace. This may NOT be identical to the Display Name of the Project.

  4. Set the PROJECT_NAMESPACE variable to the namespace copied in the previous step:

    export PROJECT_NAMESPACE=<PROJECT_NAMESPACE>
    CODE
  5. 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 under 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: project-grafana-loki-custom-overrides
      namespace: ${PROJECT_NAMESPACE}
    data:
      values.yaml: |
        loki:
          structuredConfig:
            limits_config:
              retention_period: 360h
    EOF
    CODE
  6. Run the following command on the management cluster to reference the configOverrides in the project-grafana-loki AppDeployment:

    cat <<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.4
        kind: ClusterApp
      configOverrides:
        name: project-grafana-loki-custom-overrides
    EOF
    CODE