需要粘贴到vim的代码如下:
# 指标 instance 的配置 apiVersion: "config.istio.io/v1alpha2" kind: metric metadata: name: doublerequestcount namespace: istio-system spec: value: "2" # 每个请求计数两次 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"' --- # prometheus handler 的配置 apiVersion: "config.istio.io/v1alpha2" 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: - reporter - source - destination - message --- # 将指标 Instance 发送给 prometheus handler 的 rule 对象 apiVersion: "config.istio.io/v1alpha2" kind: rule metadata: name: doubleprom namespace: istio-system spec: actions: - handler: doublehandler.prometheus instances: - doublerequestcount.metric
按照默认的方式,打开vim,使用insert模式粘贴出现下面的情况
解决方案:
在命令模式下输入:set paste,然后进入insert(paste)模式,再次粘贴,成功解决
转载请注明:MitNick » 使用vim粘贴代码时格式变乱,自动缩进,自动加注释解决方案