You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Blackbox Exporter Helm Chart未创建ServiceMonitor问题求助

问题

尝试安装Blackbox Exporter,仅在Helm Chart的values.yaml中修改了以下配置:

namespaceOverride: "monitoring"

serviceMonitor:
  ## If true, a ServiceMonitor CRD is created for a prometheus operator
  ## https://github.com/coreos/prometheus-operator for blackbox-exporter itself
  ##
  selfMonitor:
    enabled: false
    additionalMetricsRelabels: {}
    additionalRelabeling: []
    labels: {}
    interval: 30s
    scrapeTimeout: 30s

  ## If true, a ServiceMonitor CRD is created for a prometheus operator
  ## https://github.com/coreos/prometheus-operator for each target
  ##
  enabled: true

仅修改了serviceMonitor.enabled: true并覆盖默认命名空间,但ServiceMonitor始终未创建,甚至执行helm template也未输出预期的servicemonitor.yaml。使用的是prometheus-stack,集群资源状态信息如下:

NAME                                                                  READY   STATUS    RESTARTS   AGE
pod/alertmanager-monitoring-prometheus-stac-alertmanager-0            2/2     Running   1          26m
pod/monitoring-black-box-exporter-prometheus-blackbox-exporter6c4fw   1/1     Running   0          26m
pod/monitoring-prometheus-stac-operator-85779b977b-9qm87              1/1     Running   0          26m
pod/monitoring-prometheus-stack-grafana-65884866bd-wb5tg              3/3     Running   0          26m
pod/monitoring-prometheus-stack-kube-state-metrics-8bc9fdfdc-btb6k    1/1     Running   0          26m
pod/monitoring-prometheus-stack-prometheus-node-exporter-5kfx5        1/1     Running   0          26m
pod/monitoring-prometheus-stack-prometheus-node-exporter-ggkzg        1/1     Running   0          26m
pod/prometheus-monitoring-prometheus-stac-prometheus-0                2/2     Running   0          26m

NAME                                                                 TYPE           CLUSTER-IP       EXTERNAL-IP   PORT(S)                      AGE
service/alertmanager-operated                                        ClusterIP      None             <none>        9093/TCP,9094/TCP,9094/UDP   26m
service/monitoring-black-box-exporter-prometheus-blackbox-exporter   ClusterIP      10.96.129.197    <none>        9115/TCP                     26m
service/monitoring-prometheus-stac-alertmanager                      ClusterIP      10.102.199.86    <none>        9093/TCP                     26m
service/monitoring-prometheus-stac-operator                          ClusterIP      10.99.153.124    <none>        443/TCP                      26m
service/monitoring-prometheus-stac-prometheus                        LoadBalancer   10.96.255.5      <pending>     9090:31686/TCP               26m
service/monitoring-prometheus-stack-grafana                          ClusterIP      10.108.117.184   <none>        80/TCP                       26m
service/monitoring-prometheus-stack-kube-state-metrics               ClusterIP      10.104.194.135   <none>        8080/TCP                     26m
service/monitoring-prometheus-stack-prometheus-node-exporter         ClusterIP      10.98.194.5      <none>        9100/TCP                     26m
service/prometheus-operated                                          ClusterIP      None             <none>        9090/TCP                     26m

NAME                                                                  DESIRED   CURRENT   READY   UP-TO-DATE   AVAILABLE   NODE SELECTOR   AGE
daemonset.apps/monitoring-prometheus-stack-prometheus-node-exporter   2         2         2       2            2           <none>          26m

NAME                                                                         READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/monitoring-black-box-exporter-prometheus-blackbox-exporter   1/1     1            1           26m
deployment.apps/monitoring-prometheus-stac-operator                          1/1     1            1           26m
deployment.apps/monitoring-prometheus-stack-grafana                          1/1     1            1           26m
deployment.apps/monitoring-prometheus-stack-kube-state-metrics               1/1     1            1           26m

NAME                                                                                   DESIRED   CURRENT   READY   AGE
replicaset.apps/monitoring-black-box-exporter-prometheus-blackbox-exporter-5ff87bdc7   1         1         1       26m
replicaset.apps/monitoring-prometheus-stac-operator-85779b977b                         1         1         1       26m
replicaset.apps/monitoring-prometheus-stack-grafana-65884866bd                         1         1         1       26m
replicaset.apps/monitoring-prometheus-stack-kube-state-metrics-8bc9fdfdc               1         1         1       26m

NAME                                                                    READY   AGE
statefulset.apps/alertmanager-monitoring-prometheus-stac-alertmanager   1/1     26m
statefulset.apps/prometheus-monitoring-prometheus-stac-prometheus       1/1     26m

请问是否遗漏了文档中的某些配置?

排查方向
  • 检查targets配置是否存在:开启serviceMonitor.enabled=true后,Helm只会为定义好的监控目标生成ServiceMonitor。如果values.yaml中没有配置targets列表,不会生成任何相关资源。示例配置如下:

    targets:
      example:
        labels:
          module: http_2xx
        url: http://example.com
    
  • 确认ServiceMonitor CRD是否已安装:虽然prometheus-stack通常自带该CRD,但可以手动验证:

    kubectl get crd servicemonitors.monitoring.coreos.com
    

    如果不存在,需确认prometheus-operator是否已正确部署并创建该CRD。

  • 检查Chart版本兼容性:不同版本的blackbox-exporter Helm Chart与prometheus-stack的兼容性可能存在差异,确保使用的Chart版本与当前prometheus-stack版本匹配。部分旧版本可能需要额外开启prometheusOperator.enabled=true等参数。

  • 验证命名空间权限:确认Helm部署使用的ServiceAccount拥有在monitoring命名空间创建ServiceMonitor的权限,可通过以下命令查看:

    kubectl describe sa <helm-service-account> -n monitoring
    
  • 查看模板生成条件:直接查看blackbox-exporter Chart的templates目录下的servicemonitor模板文件,确认生成逻辑是否仅依赖serviceMonitor.enabled和targets配置。若模板存在其他隐藏条件(比如prometheusOperator.enabled),需在values.yaml中对应开启。

内容的提问来源于stack exchange,提问作者Ruslan Pylypiuk

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.05 03:21:36