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:
Execute the following command to get the namespace of your workspace:
CODEdkp get workspaces
Copy the value under the
NAMESPACE
column for your workspace.Set the
WORKSPACE_NAMESPACE
variable to the namespace copied in the previous step:CODEexport WORKSPACE_NAMESPACE=<WORKSPACE_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 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: grafana-loki-custom-overrides namespace: ${WORKSPACE_NAMESPACE} data: values.yaml: | loki: structuredConfig: limits_config: retention_period: 360h EOF
Edit the
grafana-loki
AppDeployment to set the value ofspec.configOverrides.name
tografana-loki-custom-overrides
(Refer to Deploy a service with a custom configuration for more information).CODEdkp edit appdeployment -n ${WORKSPACE_NAMESPACE} grafana-loki
After your editing is complete, the AppDeployment resembles this example:
CODEapiVersion: 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