11.4 调用链追踪

上一章

11.6 服务调用树

下一章

更多图书

11.5 服务指标可视化

Istio默认情况下使用Prometheus来收集存储指标数据,并使用Grafana来可视化指标数据。当我们安装好Istio之后,Istio已经自动收集了常用的指标数据并创建了常用的仪表板来可视化指标数据。当Istio默认配置的图无法满足需求时,我们还可以自定义相关的指标数据图。

【实验】

1)查看是否部署了Prometheus:


$ kubectl get deploy prometheus -n istio-system
NAME          DESIRED      CURRENT         UP-TO-DATE    AVAILABLE    AGE
prometheus    1            1               1             1            21d
$ kubectl get svc prometheus -n istio-system
NAME          TYPE         CLUSTER-IP      EXTERNAL-IP   PORT(S)      AGE
prometheus    ClusterIP    10.99.177.169   <none>        9090/TCP     21d

上面的命令结果表示Prometheus已经部署。

2)查看是否部署了Grafana:


$ kubectl get deploy grafana -n istio-system
NAME          DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE
grafana       1            1               1               1           21d
$ kubectl get svc grafana -n istio-system
NAME          TYPE         CLUSTER-IP      EXTERNAL-IP     PORT(S)     AGE
grafana       ClusterIP    10.99.125.166   <none>          3000/TCP    21d

如上的命令结果表示Grafana已经部署。

3)创建用于请求的Pod:


$ kubectl apply -f kubernetes/fortio.yaml

4)暴露Grafana的Web服务:


$ kubectl apply -f kubernetes/istio-grafana-service.yaml

5)并发请求服务:


$ kubectl exec fortio -c fortio /usr/local/bin/fortio -- load -curl http://service-python/env
HTTP/1.1 200 OK
content-type: application/json
content-length: 177
server: envoy
date: Fri, 18 Jan 2019 14:36:22 GMT
x-envoy-upstream-service-time: 2317
{"message":"python v1","upstream":[{"message":"lua v2","response_time":0.03},{"message":"node v2","response_time":0.1,"upstream":[{"message":"go v1","response_time":"0.02"}]}]}
$ kubectl exec fortio -c fortio /usr/local/bin/fortio -- load -qps 10 -n 100 -loglevel Error http://service-python/env
14:36:54 I logger.go:97> Log level is now 4 Error (was 2 Info)
Fortio 1.0.1 running at 10 queries per second, 2->2 procs, for 100 calls: http://service-python/env
Aggregated Sleep Time : count 96 avg -57.921022 +/- 33.4 min -131.227050538 max -2.920655649 sum -5560.41808
# range, mid point, percentile, count
>= -131.227 <= -2.92066 , -67.0739 , 100.00, 96
# target 50% -67.7491
WARNING 100.00% of sleep were falling behind
Aggregated Function Time : count 100 avg 5.493663 +/- 2.894 min 0.01501075 max 13.482176793 sum 549.366298
# target 50%      4.78947
# target 75%      7.77778
# target 90%      9.86111
# target 99%     13.0953
# target 99.9%   13.4435
Sockets used: 6 (for perfect keepalive, would be 4)
Code 200 : 98 (98.0 %)
Code 503 : 2 (2.0 %)
All done 100 calls (plus 0 warmup) 5493.663 ms avg, 0.7 qps

6)在Grafana UI上查看指标数据。访问地址http://11.11.11.111:32143/ ,首页如图11-15所示。

图11-15 首页

查看Istio默认创建的仪表板,Home下拉菜单的istio文件夹下Dashboard均为Istio默认创建,如图11-16所示。

图11-16 Istio默认创建的仪表板

查看Istio服务网格整体指标,如图11-17所示。

图11-17 Istio服务网格整体指标

查看Istio性能指标,如图11-18所示。

查看Mixer组件的性能指标,如图11-19所示。

查看Pilot组件的性能指标,如图11-20所示。

查看service-python服务的请求指标,如图11-21所示。

图11-18 性能指标

图11-19 Mixer组件的性能指标

图11-20 Pilot组件的性能指标

图11-21 service-python服务的请求指标

7)清理:


$ kubectl delete -f kubernetes/fortio.yaml
$ kubectl delete -f kubernetes/istio-grafana-service.yaml