• 告警通知
  • 3.1.1监控pod端口状态,内置的prometheus无法展示所有pod信息

创建部署问题时,请参考下面模板,你提供的信息越多,越容易及时获得解答。如果未按模板创建问题,管理员有权关闭问题。
确保帖子格式清晰易读,用 markdown code block 语法格式化代码块。
你只花一分钟创建的问题,不能指望别人花上半个小时给你解答。

操作系统信息
物理机

7.2.1511

Kubernetes版本信息
Client Version: version.Info{Major:“1”, Minor:“18”, GitVersion:“v1.18.4”, GitCommit:“c96aede7b5205121079932896c4ad89bb93260af”, GitTreeState:“clean”, BuildDate:“2020-06-17T11:41:22Z”, GoVersion:“go1.13.9”, Compiler:“gc”, Platform:“linux/amd64”}

Server Version: version.Info{Major:“1”, Minor:“18”, GitVersion:“v1.18.4”, GitCommit:“c96aede7b5205121079932896c4ad89bb93260af”, GitTreeState:“clean”, BuildDate:“2020-06-17T11:33:59Z”, GoVersion:“go1.13.9”, Compiler:“gc”, Platform:“linux/amd64”}

容器运行时

docker version / crictl version / nerdctl version 结果贴在下方

#docker version

Client:

 Version:           18.06.1-ce

 API version:       1.38

 Go version:        go1.10.3

 Git commit:        e68fc7a

 Built:             Tue Aug 21 17:23:03 2018

 OS/Arch:           linux/amd64

 Experimental:      false

Server:

 Engine:

  Version:          18.06.1-ce

  API version:      1.38 (minimum version 1.12)

  Go version:       go1.10.3

  Git commit:       e68fc7a

  Built:            Tue Aug 21 17:25:29 2018

  OS/Arch:          linux/amd64

  Experimental:     false

crictl version

Version:  0.1.0

RuntimeName:  docker

RuntimeVersion:  18.06.1-ce

RuntimeApiVersion:  1.38.0

nerdctl version

KubeSphere版本信息
v3.1.1 在线安装,在已有k8s上安装

问题是什么
在密钥"additional-scrape-configs"中添加抓取所有pod资源的配置,配置完成后prometheus中仅展示部分pod,并没有展示所有pod,已经检查过ClusterRole和ClusterRoleBinding,并未发现明显问题

additional-scrape-configs

- job_name: 'kubernetes-pods'
  scrape_interval: 15s
  kubernetes_sd_configs:
  - role: pod
  relabel_configs:
  - source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_scrape]
    action: keep
    regex: true
  - source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_path]
    action: replace
    target_label: __metrics_path__
    regex: (.+)
  - source_labels: [__address__, __meta_kubernetes_pod_annotation_prometheus_io_port]
    action: replace
    regex: ([^:]+)(?::\d+)?;(\d+)
    replacement: $1:$2
    target_label: __address__
  - action: labelmap
    regex: __meta_kubernetes_pod_label_(.+)
  - source_labels: [__meta_kubernetes_namespace]
    action: replace
    target_label: kubernetes_namespace
  - source_labels: [__meta_kubernetes_pod_name]
    action: replace
    target_label: kubernetes_pod_name

prometheu中target展示

clusterRole的配置内容

ClusterRoleBinding的内容