dennis159753 @codingnow

问题原因是 kube-state-metrics 指标重复,

found duplicate series for the match group;
many-to-many matching not allowed: matching labels must be unique on one side

具体应该是环境上采集了两份 kube-state-metrics 的指标数据,一份是来自于kubesphere-monitoring-system 的kube-state-metrics, 一份看日志应该是 {service=“tke-kube-state-metrics”}, 所以计算时指标重复冲突,可以根据需求保留一份采集就行。

    15 天 后

    frezes 我的是单位错误,显示的是Ki,数值对应的G,这个单位在哪里设置知道吗

      frezes

      这里单位给的Y轴单位是Ki,监控显示占用27.61Ki,实际使用kubectl top查看到的使用的是27.61G的内存

        cqwang9

        你把这个请求响应返回的 json 贴一下,单位不支持设置,这里可能是前端数据单位转换的bug?

          frezes

          {
           "results": [
            {
             "metric_name": "pod_net_bytes_received",
             "data": {
              "resultType": "vector"
             }
            },
            {
             "metric_name": "pod_memory_usage_wo_cache",
             "data": {
              "resultType": "vector",
              "result": [
               {
                "metric": {
                 "namespace": "phm-prod",
                 "pod": "phm-collect-app-6f44bfbcbc-jnfv7"
                },
                "value": [
                 1728699460,
                 "28292.3984375"
                ],
                "min_value": "",
                "max_value": "",
                "avg_value": "",
                "sum_value": "",
                "fee": "",
                "resource_unit": "",
                "currency_unit": ""
               }
              ]
             }
            },
            {
             "metric_name": "pod_cpu_usage",
             "data": {
              "resultType": "vector",
              "result": [
               {
                "metric": {
                 "namespace": "phm-prod",
                 "pod": "phm-collect-app-6f44bfbcbc-jnfv7"
                },
                "value": [
                 1728699460,
                 "1.005"
                ],
                "min_value": "",
                "max_value": "",
                "avg_value": "",
                "sum_value": "",
                "fee": "",
                "resource_unit": "",
                "currency_unit": ""
               }
              ]
             }
            },
            {
             "metric_name": "pod_net_bytes_transmitted",
             "data": {
              "resultType": "vector"
             }
            }
           ]
          }

          cqwang9

          将prometheus 的9090 端口设置为nodeport,访问页面,查询下这个表达式

          sum by (namespace,pod)(container_memory_working_set_bytes{image!="",job="kubelet",metrics_path="/metrics/cadvisor",pod="prom-agent-k8s-0"})

          把这里的 pod="prom-agent-k8s-0" 换成你的pod name, 查询下原始表达式。 后端返回默认不带单位,返回28292,所以会处理为27Ki,但看起来和 top 结果不符合。所以需要查询下原始值。