istio 遥测
来源:原创
时间:2022-04-09
作者:脚本小站
分类:云原生
查看istio-proxy指标的方法:
curl 127.0.0.1:15000/stats curl 127.0.0.1:15000/stats/prometheus kubectl exec -it demoappv10-5c497c6f7c-76gs7 -c istio-proxy -- pilot-agent request GET /stats/prometheus
查看启用的统计指标:
istioctl proxy-config bootstrap demoappv10-5c497c6f7c-76gs7.default | jq .bootstrap.statsConfig
在网格上配置代理级指标:
全局配置:
apiVersion: install.istio.io/v1alpha1 kind: IstioOperator spec: profile: default # 在命令行用--set=default定义也可以 meshConfig: defaultConfig: proxyStatsMatcher: inclusionRegexps: # 以正则模式包含匹配到的指标 - ".*circuit_breakers.*" # 指标中包含这个名称的指标都收集过来 inclusionPrefixes: # 以前缀的方式指定指标 - "upstream_rq_retry" # 启用重试相关的指标 - "upstream_cx" # 启用上游连接信息指标
应用配置:istioctl的install指令相当于apply。
istioctl install -f istioOperator.yaml # --dry-run
单个工作负载的配置:可在pod、deployment等资源上定义(不推荐)
apiVersion: apps/v1 kind: Deployment metadata: labels: app: nginx name: nginx spec: replicas: 1 selector: matchLabels: app: nginx template: metadata: labels: app: nginx annotations: # 在这配置 proxy.istio.io/config: |- proxyStatsMatcher: inclusionRegexps: - ".*circuit_breakers.*" inclusionPrefixes: - "upstream_rq_retry" - "upstream_cx" spec: containers: - image: nginx name: nginx
获取配置:保存下来改改再应用即可。
istioctl profile dump demo > istio-profile-demo.yaml
或者直接应用要修改的内容即可:
apiVersion: install.istio.io/v1alpha1 kind: IstioOperator spec: profile: default meshConfig: defaultConfig: proxyStatsMatcher: inclusionRegexps: - ".*circuit_breakers.*" inclusionPrefixes: - "upstream_rq_retry" - "upstream_cx"
查看指标是否被启用:
curl PodIP:15020/stats/prometheus | grep circuit
服务基本指标使用telemetry v2:
apiVersion: install.istio.io/v1alpha1 kind: IstioOperator spec: profile: demo values: telemetry: v2: prometheus: configOverride: inboundSidecar: metrics: - name: requests_total dimensions: request_host: request.host request_method: request.method tags_to_remove: - request_protocol outboundSidecar: metrics: - name: requests_total dimensions: request_host: request.host request_method: request.method tags_to_remove: - request_protocol gateway: metrics: - name: requests_total dimensions: request_host: request.host request_method: request.method tags_to_remove: - request_protocol
应用配置:
istioctl install -f istioOperator.yaml