apiVersion: "config.istio.io/v1alpha2" # 指标 instance 的配置
kind: metric
metadata:
name: doublerequestcount
namespace: istio-system
spec:
value: "2" # 每个请求计数两次
dimensions:
source: source.service | "unknown"
destination: destination.service | "unknown"
message: '"twice the fun!"'
monitored_resource_type: '"UNSPECIFIED"'
---
apiVersion: "config.istio.io/v1alpha2" # prometheus handler 的配置
kind: prometheus
metadata:
name: doublehandler
namespace: istio-system
spec:
metrics:
- name: double_request_count # Prometheus 指标名称
instance_name: doublerequestcount.metric.istio-system # Mixer Instance 名称(全限定名称)
kind: COUNTER
label_names:
- source
- destination
- message
---
apiVersion: "config.istio.io/v1alpha2" # 将指标 Instance 发送给 prometheus handler 的 rule 对象
kind: rule
metadata:
name: doubleprom
namespace: istio-system
spec:
actions:
- handler: doublehandler.prometheus
instances:
- doublerequestcount.metric
$ kubectl -n istio-system port-forward service/prometheus 9090:9090 &
$ kubectl -n istio-system port-forward service/jaeger-query 16686:16686 &
$ kubectl -n istio-system port-forward service/grafana 3000:3000 &
$ kubectl -n istio-system port-forward $(kubectl -n istio-system get pod -l app=servicegraph -o jsonpath='{.items[0].metadata.name}') 8088:8088 &