Spring 执行器指标在标签中保留 "dot"

Spring Actuator Metrics preserve "dot" in tags

我正在我的指标导出器中创建标签,方法是:

  metrics:
    export:
      elastic:
        host: "xx"
        index: "metricbeat-k8s-apps"
        user-name: "elastic"
        password: "xx"
        step: 30s
        connect-timeout: 10s
    tags:
      cluster: ${CLUSTER}
      kubernetes.pod.name: ${POD_NAME}
      kubernetes.namespace: ${POD_NAMESPACE}

但是我不知道为什么“kubernetes.pod.name”会被转换成“kubernetes_pod_name”,我怎样才能保留点呢?

Micrometer 中的单词分隔符是 'dot' (see docs), according to the Elastic naming conventions, the word separator is 'underscore' in Elastic. In Micrometer, every registry has a NamingConvention. For Elastic, it is ElasticNamingConvention.

正如您可以 see 那样 class,默认的命名约定是 snake_case:

public ElasticNamingConvention() {
    this(NamingConvention.snakeCase);
}

你可以看到 ElasticMeterRegistry uses this naming convention, but you can provide your own, please check the docs.