【问题标题】:Monitoring custom Stream apps in Spring Cloud data flow在 Spring Cloud 数据流中监控自定义 Stream 应用程序
【发布时间】:2019-07-23 14:49:05
【问题描述】:

我正在尝试使用 prometheus 和 grafana 进行 scdf 及其监控。我遵循了可用的文档并能够部署示例流并能够在 grafana 中查看指标。

我已经创建了一个带有一些自定义流应用程序的流(除了提供的 rabbit mq 入门应用程序)。

流: htt |参与者 |日志

但我无法在 gafana 中看到“参与者”应用程序指标。但能看到http和log应用的指标。​​

在 application.properties 中添加了以下属性。

management.endpoint.metrics.enabled=true
management.endpoints.web.exposure.include=*
management.endpoint.prometheus.enabled=true
management.metrics.export.prometheus.enabled=true
spring.cloud.streamapp.security.enabled=false

添加以下依赖项:

<dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
    <!--&lt;!&ndash; https://mvnrepository.com/artifact/org.springframework.cloud.stream.app/app-starters-common &ndash;&gt;-->
    <!--<dependency>-->
        <!--<groupId>org.springframework.cloud.stream.app</groupId>-->
        <!--<artifactId>app-starters-common</artifactId>-->
        <!--<version>2.1.1.RELEASE</version>-->
        <!--<type>pom</type>-->
    <!--</dependency>-->

    <dependency>
        <groupId>io.micrometer</groupId>
        <artifactId>micrometer-registry-prometheus</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-amqp</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-stream</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-stream-binder-rabbit</artifactId>
    </dependency>

添加app-starters-common:org.springframework.cloud.stream.app依赖localhost:/后打开登录页面。

【问题讨论】:

    标签: spring-cloud-dataflow


    【解决方案1】:

    我认为您的应用需要app-starters-micrometer-common 依赖,其中adds 一些千分尺标签。此依赖项旨在供 Spring 云流应用程序启动器使用,我相信您也可以在自定义应用程序中使用它。

    【讨论】:

    • 我已经添加了 app-starters-micrometer-common 依赖项,但仍然没有运气。在此localhost:25340/actuator 端点显示登录页面之后。
    • 我在应用程序属性下面添加了。但仍然显示逻辑页面。 security.basic.enabled=false management.security.enabled=false 如何禁用安全性。 ?
    【解决方案2】:

    我在寻找相同的答案时遇到了这个问题。

    这是我的工作代码 sn-p:-

    Pom.xml

        <dependency>
                <groupId>org.springframework.cloud.stream.app</groupId>
                <artifactId>app-starters-micrometer-common</artifactId>
                <version>2.1.2.RELEASE</version>
        </dependency>
        <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
            <dependency>
                <groupId>io.micrometer</groupId>
                <artifactId>micrometer-registry-prometheus</artifactId>
        </dependency>
        <dependency>
                <groupId>io.micrometer</groupId>
                <artifactId>micrometer-registry-jmx</artifactId>
        </dependency>
    

    应用程序属性更改以启用 prometheus 并禁用安全性(登录页面)

    management.endpoints.web.exposure.include=*
    management.metrics.export.prometheus.enabled=true
    

    --这个去掉安全性(登录页面),由app-starter-micrometre-common依赖自动添加。

    spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfiguration, org.springframework.boot.actuate.autoconfigure.security.servlet.ManagementWebSecurityAutoConfiguration
    

    或

    排除依赖项,我排除了 config-client 和其他一些,因为我的应用程序中不需要它们。

    <dependency>
                <groupId>org.springframework.cloud.stream.app</groupId>
                <artifactId>app-starters-micrometer-common</artifactId>
                <version>2.1.2.RELEASE</version>
                <exclusions>
                    <exclusion>
                        <artifactId>spring-security-config</artifactId>
                        <groupId>org.springframework.security</groupId>
                    </exclusion>
                    <exclusion>
                        <artifactId>spring-cloud-services-starter-config-client</artifactId>
                        <groupId>io.pivotal.spring.cloud</groupId>
                    </exclusion>
                    <exclusion>
                        <artifactId>*</artifactId>
                        <groupId>org.springframework.boot</groupId>
                    </exclusion>
                </exclusions>
            </dependency>
    

    【讨论】:

      【解决方案3】:

      使用更高版本的 Data Flow 2.3.x,您需要将以下依赖项添加到您的处理器:

      <dependency>
          <groupId>org.springframework.cloud.stream.app</groupId>
          <artifactId>app-starters-micrometer-common</artifactId>
          <version>2.1.2.RELEASE</version>
      </dependency>
      <dependency>
          <groupId>io.micrometer</groupId>
          <artifactId>micrometer-registry-prometheus</artifactId>
      </dependency>    
      <dependency>
          <groupId>io.micrometer.prometheus</groupId>
          <artifactId>prometheus-rsocket-spring</artifactId>
          <version>0.9.0</version>
      </dependency>
      

      app-starters-micrometer-common 注入特定于 DataFlow 的标签,例如 stream.name、application.name、application.type,所有这些标签都被仪表板用于聚合所需的指标。

      此外,您还可以按照示例项目中的说明操作,展示如何构建自定义 Source、Processor 和 Sink 应用并启用 prometheus 监控: https://github.com/spring-cloud/spring-cloud-dataflow-samples/tree/master/monitoring-samples/stream-apps

      【讨论】:

        猜你喜欢
        • 2017-02-10
        • 2019-01-23
        • 1970-01-01
        • 2018-11-27
        • 1970-01-01
        • 2020-12-22
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多