From f16277e8e04955c0f5749da173a7e8130c56eecf Mon Sep 17 00:00:00 2001
From: Arunprasad Rajkumar <arajkuma@redhat.com>
Date: Thu, 3 Feb 2022 17:50:22 +0530
Subject: [PATCH] Sanitize regex denylist in ksm-lite addon

The following metrics are missing from kube-state-metrics:
- kube_pod_container_status_terminated_reason
- kube_pod_init_container_status_terminated_reason
- kube_pod_status_scheduled_time

Previously, some metrics were removed from kube-state-metrics by adding the following --metric-denylist argument to the kube-state-metrics container

```
--metric-denylist=
kube_.+_created,
kube_.+_metadata_resource_version,
kube_replicaset_metadata_generation,
kube_replicaset_status_observed_generation,
kube_pod_restart_policy,
kube_pod_init_container_status_terminated,
kube_pod_init_container_status_running,
kube_pod_container_status_terminated,
kube_pod_container_status_running,
kube_pod_completion_time,
kube_pod_status_scheduled
```

--metric-denylist: Comma-separated list of metrics not to be enabled. This list comprises of exact metric names and/or regex patterns. The allowlist and denylist are mutually exclusive.

However, all the list of metrics is managed as RegEx, thus "kube_pod_container_status_terminated" denies .*kube_pod_container_status_terminated.*, that's why kube_pod_init_container_status_terminated_reason is missing

Co-authored-by: Florian Gleizes <fgleizes@redhat.com>
Signed-off-by: Arunprasad Rajkumar <arajkuma@redhat.com>
---
 jsonnet/kube-prometheus/addons/ksm-lite.libsonnet | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/jsonnet/kube-prometheus/addons/ksm-lite.libsonnet b/jsonnet/kube-prometheus/addons/ksm-lite.libsonnet
index cf06ebdc..dec2256f 100644
--- a/jsonnet/kube-prometheus/addons/ksm-lite.libsonnet
+++ b/jsonnet/kube-prometheus/addons/ksm-lite.libsonnet
@@ -21,12 +21,12 @@ local addArgs(args, name, containers) = std.map(
                 kube_replicaset_metadata_generation,
                 kube_replicaset_status_observed_generation,
                 kube_pod_restart_policy,
-                kube_pod_init_container_status_terminated,
+                kube_pod_init_container_status_terminated$,
                 kube_pod_init_container_status_running,
-                kube_pod_container_status_terminated,
+                kube_pod_container_status_terminated$,
                 kube_pod_container_status_running,
                 kube_pod_completion_time,
-                kube_pod_status_scheduled
+                kube_pod_status_scheduled$
               |||],
               'kube-state-metrics',
               super.containers
-- 
GitLab