1

我正在将 SCDF 与 Spring Boot 2.x 指标和 SCDF 指标收集器一起使用,以从我的 Spring Boot 应用程序中收集指标。我真的不了解收集器关于aggregateMetrics数据的逻辑。

当我获取为我的流收集的指标列表时,我只有一个以开头的integration.channel.*,因此我只有平均值。我尝试了一切以查看其他指标,这些指标看起来像/actuator/prometheus端点公开的指标。

我想我误解了指标的聚合方式。我注意到 SCDF 会自动向指标添加一些属性,我想将这些属性应用于我公开的所有指标,以便将它们全部收集起来。

{
  "_embedded": {
    "streamMetricsList": [
      {
        "name": "poc-stream",
        "applications": [
          {
            "name": "poc-message-sink",
            "instances": [
              {
                "guid": "poc-stream-poc-message-sink-v7-75b8f4dcff-29fst",
                "key": "poc-stream.poc-message-sink.poc-stream-poc-message-sink-v7-75b8f4dcff-29fst",
                "properties": {
                  "spring.cloud.dataflow.stream.app.label": "poc-message-sink",
                  "spring.application.name": "poc-message-sink",
                  "spring.cloud.dataflow.stream.name": "poc-stream",
                  "spring.cloud.dataflow.stream.app.type": "sink",
                  "spring.cloud.application.guid": "poc-stream-poc-message-sink-v7-75b8f4dcff-29fst",
                  "spring.cloud.application.group": "poc-stream",
                  "spring.cloud.dataflow.stream.metrics.version": "2.0"
                },
                "metrics": [
                  {
                    "name": "integration.channel.input.send.mean",
                    "value": 0,
                    "timestamp": "2018-10-25T16:34:39.889Z"
                  }
                ]
              }
            ],
            "aggregateMetrics": [
              {
                "name": "integration.channel.input.send.mean",
                "value": 0,
                "timestamp": "2018-10-25T16:34:52.894Z"
              }
            ]
          },
...

我有一些Micrometer计数器,我想用 Metrics 收集器获取值。我知道它们暴露得很好,因为我已经正确设置了所有属性,我什至进入了启动的 Docker 容器以检查端点。

我读过

部署应用程序时,Data Flow 设置 spring.cloud.stream.metrics.properties 属性,如下例所示:

spring.cloud.stream.metrics.properties=spring.application.name,spring.application.index,spring.cloud.application.*,spring.cloud.dataflow.*

这些键的值被用作标签来执行聚合。对于 2.x 应用程序,这些键值直接映射到 Micrometer 库中的标签。属性 spring.cloud.application.guid 可用于追溯生成指标的特定应用程序实例。

这是否意味着我需要自己专门将这些属性添加到我所有指标的标签中?我知道我可以通过让 BeanMeterRegistryCustomizer返回以下内容来做到这一点:registry -> registry.config().commonTags(tags)使用标签作为 SCDF 通常为integration指标设置的属性。还是 SCDF 将属性添加到所有指标?

谢谢 !

4

1 回答 1

2

虽然您对 的观察MetricsCollector“通常”是正确的,但我相信有一种替代方法(也许更清洁)可以通过使用 SCDF Micrometer 指标收集方法来实现您一直在尝试的目标。我将尝试在下面解释这两种方法。

As the MetricsCollector precedes in time the Micrometer framework they both implement a quite different metrics processing flows. The primary goal for the Metrics Collector 2.x was to ensure backward compatibility with SpringBoot 1.x metrics. The MetricsCollector 2.x allows mixing metrics coming from both SpringBoot 1.x (pre micrometer) and Spring Boot 2.x (e.g. micrometer) app starters. The consequence of this decision is that the Collector 2.x supports only the common denominator of metrics available in Boot 1.x and 2.x. This requirement is enforced by pre-filtering only the integration.channel.* metrics. At the moment you would not be able to add more metrics without modifying the metrics collector code. If you think that supporting different Micrometer metrics is more important than having backward compatibility with Boot 1.x then please open an new issue in Metrics Collector project. Still I believe that the approach explained below is better suited for you case!

Unlike the MetricsCollector approach, the "pure" Micrometer metrics are send directly to the selected Metrics registry (such as Prometheus, InfluxDB, Atlas and so on). As illustrated in the sample, the collected metrics can be analyzed and visualized with tools such as Grafana. Follow the SCDF Metrics samples to setup your metrics collection via InfluxDB (or Prometheus) and Grafana. Later would allow you explore any out-of-the-box or custom Micrometer metrics. The downside of this approach (for the moment) is that you will not be able to visualize those metrics in the SCDF UI's pipeline. Still if you find it important to have such visualization inside the SCDF UI please open a new issue in the SCDF project (I have WIP for the Altals Micrometer Registry).

I hope that this sheds some light on the alternative approaches. We would be very interested to hear your feedback.

Cheers!

于 2018-10-29T10:32:56.407 回答