Bug 2012039 - After upgrading cluster to 4.8 the kube-state-metrics service doesn't export namespace labels anymore
Summary: After upgrading cluster to 4.8 the kube-state-metrics service doesn't export ...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: OpenShift Container Platform
Classification: Red Hat
Component: Monitoring
Version: 4.8
Hardware: Unspecified
OS: Unspecified
medium
medium
Target Milestone: ---
: 4.8.z
Assignee: Jayapriya Pai
QA Contact: Junqi Zhao
URL:
Whiteboard:
Depends On: 2012029
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-10-08 04:43 UTC by Jayapriya Pai
Modified: 2021-10-27 08:15 UTC (History)
8 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of: 2011698
Environment:
Last Closed: 2021-10-27 08:15:28 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github openshift cluster-monitoring-operator pull 1436 0 None open Bug 2012039: Allow namespace label in metric allow list 2021-10-18 07:09:02 UTC
Red Hat Product Errata RHBA-2021:3927 0 None None None 2021-10-27 08:15:49 UTC

Comment 2 Junqi Zhao 2021-10-18 09:27:06 UTC
tested with the PR, issue is fixed
for example, namespace ns1 has namespace labels
# oc get ns ns1 -o jsonpath="{.metadata.labels"}
{"deploy.method":"user","kubernetes.io/metadata.name":"ns1","network.openshift.io/policy-group":"ns1"}

seach with "kube_namespace_labels{namespace="ns1"}", we can see the namespace's labels 
# token=`oc sa get-token prometheus-k8s -n openshift-monitoring`
# oc -n openshift-monitoring exec -c prometheus prometheus-k8s-0 -- curl -k -H "Authorization: Bearer $token" 'https://prometheus-k8s.openshift-monitoring.svc:9091/api/v1/query?query=kube_namespace_labels%7Bnamespace%3D%22ns1%22%7D' | jq
{
  "status": "success",
  "data": {
    "resultType": "vector",
    "result": [
      {
        "metric": {
          "__name__": "kube_namespace_labels",
          "container": "kube-rbac-proxy-main",
          "endpoint": "https-main",
          "job": "kube-state-metrics",
          "label_deploy_method": "user",
          "label_kubernetes_io_metadata_name": "ns1",
          "label_network_openshift_io_policy_group": "ns1",
          "namespace": "ns1",
          "service": "kube-state-metrics"
        },
        "value": [
          1634549085.821,
          "1"
        ]
      }
    ]
  }
}

# oc -n openshift-monitoring get deploy kube-state-metrics -oyaml | grep metric-labels-allowlis
        - --metric-labels-allowlist=pods=[*],node=[*],namespaces=[*]

Comment 7 errata-xmlrpc 2021-10-27 08:15:28 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (OpenShift Container Platform 4.8.17 bug fix update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2021:3927


Note You need to log in before you can comment on or make changes to this bug.