在Istio中,我们通过kiali监控微服务,除了显示微服务之间的流量线以外,还有一些不需要的红线(不是实际微服务流量),例如我们监控一个三层微服务,下图看起来会比痛苦。
多余的红线出现的根源就是:
prometheus会访问各个个微服务。
我们需要在istio的rules.config.istio.io中屏蔽显示。
查看项目中的rules.config.istio.io:
因为显示与http相关,我们修改promhttp。
在配置的尾部,增加 && (match((request.useragent | "-"), "Prometheus*") == false)内容即可。
从而实现通过规则来过滤掉此流量Prometheus收集request.useragent的流量。
[root@master ~]# oc edit rules.config.istio.io promhttp -n istio-system
全部内容如下所示:
apiVersion: config.istio.io/v1alpha2
kind: rule
metadata:
creationTimestamp: 2019-04-23T05:58:58Z
generation: 1
labels:
app: mixer
chart: mixer
heritage: Tiller
maistra-version: 0.10.0
release: istio
name: promhttp
namespace: istio-system
ownerReferences:
- apiVersion: istio.openshift.com/v1alpha3
blockOwnerDeletion: true
controller: true
kind: ControlPlane
name: basic-install
uid: 875b8445-6589-11e9-8216-000c2981d8ae
resourceVersion: "299644"
selfLink: /apis/config.istio.io/v1alpha2/namespaces/istio-system/rules/promhttp
uid: e2c2f4f6-658c-11e9-8d3b-000c2981d8ae
spec:
actions:
- handler: prometheus
instances:
- requestcount.metric
- requestduration.metric
- requestsize.metric
- responsesize.metric
match: (context.protocol == "http" || context.protocol == "grpc") && (match((request.useragent
| "-"), "kube-probe*") == false) &&
(match((request.useragent | "-"), "Prometheus*") == false)
配置完毕以后,再次收集监控数据,没有红线出现。但线的连接还在。
我们在为微服务配置ingressgateway和destinationrule以后,流量从ingress进入,多余的线就不会出现了。如下图所示。这样,入口流量也不会像上图那样显示unknown了。