- 此任务说明如何配置 Istio 以自动收集网格中服务的遥测。 在此任务结束时,将为网格中的服务调用启用新的指标。在整个任务中,Bookinfo 将作为示例应用程序
- 前提:
安装 Istio 到您的集群并部署一个应用。该任务假定 Mixer 已经用默认配置(--configDefaultNamespace=istio-system
)设置好了。如果您使用的不同的值,请更新本任务中的配置和命令以匹配该值。
- 采集新的指标
3.1 应用配置新指标的 YAML 文件,该指标将由 Istio 自动生成和采集
[root@master istio-1.6.3]# cat samples/bookinfo/telemetry/metrics.yaml
# Configuration for metric instances
apiVersion: config.istio.io/v1alpha2
kind: instance
metadata:
name: doublerequestcount
namespace: istio-system
spec:
compiledTemplate: metric
params:
value: "2" # count each request twice
dimensions:
reporter: conditional((context.reporter.kind | "inbound") == "outbound", "client", "server")
source: source.workload.name | "unknown"
destination: destination.workload.name | "unknown"
message: '"twice the fun!"'
monitored_resource_type: '"UNSPECIFIED"'
---
# Configuration for a Prometheus handler
apiVersion: config.istio.io/v1alpha2
kind: handler
metadata:
name: doublehandler
namespace: istio-system
spec:
compiledAdapter: prometheus
params:
metrics:
- name: double_request_count # Prometheus metric name
instance_name: doublerequestcount.instance.istio-system # Mixer instance name (fully-qualified)
kind: COUNTER
label_names:
- reporter
- source
- destination
- message
---
# Rule to send metric instances to a Prometheus handler
apiVersion: config.istio.io/v1alpha2
kind: rule
metadata:
name: doubleprom
namespace: istio-system
spec:
actions:
- handler: doublehandler
instances: [ doublerequestcount ]
[root@master istio-1.6.3]#
网友评论