如何配置Istio Helm Chart对接外部kube-prometheus-stack?
Istio指标未被Prometheus采集、Kiali无拓扑的排查修复方案
- 校验Istio部署的指标开关配置
执行helm get values istiod -n istio-system确认以下配置项均为true,如果存在配置项未开启,通过helm upgrade更新istiod版本:
配置生效后执行helm upgrade istiod istio/istiod -n istio-system \ --set prometheus.enabled=true \ --set telemetry.enabled=true \ --set telemetry.v2.prometheus.enabled=true \ --set prometheus.serviceMonitor.enabled=truekubectl get servicemonitor -n istio-system,确认返回结果中存在istiod、istio-mesh、istio-envoy三类ServiceMonitor资源,缺失则说明Helm参数未正确生效。 - 校验Prometheus的资源监听范围
kube-prometheus-stack默认通过ServiceMonitor CRD发现抓取目标,执行kubectl get prometheus -n <kube-prometheus-stack所在命名空间> -o yaml查看spec.serviceMonitorNamespaceSelector配置:- 如果配置了
matchLabels匹配规则,需要给istio-system命名空间打上对应匹配标签,例如规则要求标签prometheus=scrape,则执行kubectl label ns istio-system prometheus=scrape - 如果配置为空选择器,默认监听所有命名空间的ServiceMonitor,无需额外调整
- 如果配置了
- 校验指标端点可用性
- 验证istiod指标端点:随机选取一个istiod Pod执行端口转发
kubectl port-forward pod/<istiod-pod名称> -n istio-system 15014:15014,本地访问http://localhost:15014/metrics,确认可以返回istio_requests_total等Istio标准指标 - 验证业务侧Envoy指标:选取一个已接入网格的业务Pod执行端口转发
kubectl port-forward pod/<业务pod名称> -n <业务命名空间> 15020:15020,本地访问http://localhost:15020/stats/prometheus,确认可以返回Envoy代理相关指标。如果访问失败,先检查业务Pod是否注入了istio-proxysidecar容器,未注入则给对应业务命名空间打上istio-injection=enabled标签后重建业务Pod。
- 验证istiod指标端点:随机选取一个istiod Pod执行端口转发
- 校验Prometheus抓取状态
打开Prometheus UI进入Status > Targets页面,查看Istio相关抓取目标的状态:- 目标未出现在列表中:回到上一步检查ServiceMonitor资源、Prometheus命名空间监听配置是否正确
- 目标状态为
Down且报错连接拒绝:检查对应Pod的指标端口是否正常监听,同时排查GKE集群NetworkPolicy、VPC防火墙规则是否放通Prometheus组件到istiod 15014端口、业务Pod 15020端口的访问 - 目标状态为
Down且报403错误:检查Istio AuthorizationPolicy、PeerAuthentication规则是否拦截了Prometheus的抓取请求,可选择为Prometheus注入Istio sidecar支持mTLS认证,或配置专门的鉴权豁免规则放行Prometheus的访问
- 校验Kiali数据源配置
当Prometheus UI中可以正常查询到istio_requests_total指标后,执行kubectl get configmap kiali -n istio-system -o yaml,确认config.prometheus.url配置为集群内可访问的Prometheus服务地址,例如http://kube-prometheus-stack-prometheus.monitoring.svc:9090,配置错误则修改ConfigMap后重启Kiali Pod即可恢复拓扑展示。
内容的提问来源于stack exchange,提问作者Chirag Patel
相关产品推荐
相关产品推荐

