简体   繁体   English

如何在 Istio 中为现有的 prometheus 指标添加新标签?

[英]How to add new labels to existing prometheus metric in Istio?

I'm trying to add a new label source_ip to the prometheus metric requestcount我正在尝试将新的 label source_ip添加到普罗米修斯指标requestcount
I've added the attribute to prom handler我已将属性添加到舞会处理程序

params:
    metrics:
    - instance_name: requestcount.instance.istio-system
      kind: COUNTER
      label_names:
      - reporter
      - source_ip
      - source_app

and added a dimension to requestcount instance并向requestcount实例添加了一个维度

compiledTemplate: metric
  params:
    dimensions:
      reporter: conditional((context.reporter.kind | "inbound") == "outbound", "source", "destination")
      source_app: source.labels["app"] | "unknown"
      source_ip: source.ip | "unknown"

and added an attribute_binding to the attributes instance并向attributes实例添加了一个attribute_binding

spec:
  attributeBindings:
    destination.workload.namespace: $out.destination_workload_namespace | "unknown"
    destination.workload.uid: $out.destination_workload_uid | "unknown"
    source.ip: $out.source_pod_ip | ip("0.0.0.0")

yet, source_ip label is not included in the istio_request_total metric reported by prometheus, am I missing something here?然而, source_ip label 未包含在 prometheus 报告的istio_request_total指标中,我在这里遗漏了什么吗?

About mixer and documentation you use关于您使用的混音器和文档

I'm using istio 1.5 and upgrading might take me some considerable time.我正在使用 istio 1.5,升级可能需要相当长的时间。

That documentation you mentioned won't work on istio 1.5 as it uses mixer which is deprecated since istio 1.5, as mentioned in below docs you might re-enable it but I couldn't find any documentation about that.您提到的该文档不适用于 istio 1.5,因为它使用了自 istio 1.5 以来已弃用的混音器,如下面的文档中所述,您可能会重新启用它,但我找不到任何相关文档。

As mentioned here and hereherehere所述

Mixer is deprecated.混合器已弃用。 The functionality provided by Mixer is being moved into the Envoy proxies. Mixer 提供的功能正在转移到 Envoy 代理中。 Use of Mixer with Istio will only be supported through the 1.7 release of Istio.只有 Istio 1.7 版本才支持将 Mixer 与 Istio 一起使用。

Mixer deprecation混合器弃用

Mixer, the process behind the istio-telemetry and istio-policy deployments, has been deprecated with the 1.5 release. Mixer 是 istio-telemetry 和 istio-policy 部署背后的过程,在 1.5 版本中已被弃用。 istio-policy was disabled by default since Istio 1.3 and istio-telemetry is disabled by default in Istio 1.5.从 Istio 1.3 开始,默认禁用 istio-policy,在 Istio 1.5 中默认禁用 istio-telemetry。

Telemetry is collected using an in-proxy extension mechanism (Telemetry V2) that does not require Mixer.遥测是使用不需要 Mixer 的代理内扩展机制 (Telemetry V2) 收集的。

If you depend on specific Mixer features like out of process adapters, you may re-enable Mixer.如果您依赖于特定的 Mixer 功能,例如进程外适配器,您可以重新启用 Mixer。 Mixer will continue receiving bug fixes and security fixes until Istio 1.7.在 Istio 1.7 之前,Mixer 将继续接收错误修复和安全修复。 Many features supported by Mixer have alternatives as specified in the Mixer Deprecation document including the in-proxy extensions based on the WebAssembly sandbox API. Mixer 支持的许多功能都有 Mixer Deprecation 文档中指定的替代方案,包括基于 WebAssembly 沙箱 API 的代理内扩展

If you rely on a Mixer feature that does not have an equivalent, we encourage you to open issues and discuss in the community.如果您依赖的 Mixer 功能没有等效功能,我们鼓励您打开问题并在社区中讨论。


About upgrade关于升级

About the upgrade, I would say if that was older version of istio then it might be harder to upgrade, but since it's 1.5 I would say it might be easy to upgrade to 1.6 with istioctl upgrade .关于升级,我会说如果那是 istio 的旧版本,那么升级可能会更困难,但由于它是 1.5,我会说使用istioctl upgrade升级到 1.6 可能很容易。 I would suggest to test it first on some test environment.我建议先在一些测试环境中测试它。

About the main question关于主要问题

Istio configures prometheus with a 'kubernetes-pods' job. Istio 使用“kubernetes-pods”作业配置 prometheus。 At least while using the 'demo' profile.至少在使用“演示”配置文件时。 In this prometheus job config, there is a relabel_configs which gets the pod labels.在这个 prometheus 作业配置中,有一个 relabel_configs 用于获取 pod 标签。

relabel_configs: 
...
- action: labelmap
  regex: __meta_kubernetes_pod_label_(.+)

If you want to use it then use meshConfig.enablePrometheusMerge=true option, it will append the labels to the istio metrics.如果您想使用它,请使用 meshConfig.enablePrometheusMerge=true 选项,它将 append 标记到 istio 指标。 There is related documentation about that.有相关的文档 Just a notice that this option is newly introduced in Istio 1.6 and is considered alpha at this time.请注意,此选项是 Istio 1.6 中新引入的,目前被视为 alpha。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM