Skip to main content
Skip table of contents

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:

  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.

    CODE
    dkp get workspaces

    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:

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

    CODE
    kubectl 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 the Project.

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

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

    CODE
    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
  6. Run the following command on the management cluster to reference the configOverrides in the project-grafana-loki AppDeployment:

    CODE
    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.6
        kind: ClusterApp
      configOverrides:
        name: project-grafana-loki-custom-overrides
    EOF
JavaScript errors detected

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

If this problem persists, please contact our support.