Files
spring-cloud-dataflow-samples/monitoring-samples/task-apps/task-demo-metrics-influxdb/README.md
Christian Tzolov f8078ed08f RSocket Proxy for Prometheus monitoring
- Rename spring-cloud-dataflow-samples/tree/master/micrometer to spring-cloud-dataflow-samples/tree/master/micrometer-samples
 - Rename spring-cloud-dataflow-samples/tree/master/micrometer/tasks to spring-cloud-dataflow-samples/tree/master/micrometer-samples/task-apps
 - Add the apps under spring-cloud-dataflow-samples/tree/master/micrometer/stream-apps
 - Describe or cross-link the description of the new architecture in the root README
 - Add microsite SCDF monitoring links

 Resolves #122
2019-11-06 16:29:17 +01:00

3.9 KiB

How to monitor Spring Cloud Task

The task-demo-metrics-influx project creates a sample Spring Cloud Task (and Spring Batch) with the monitoring infrastructure, so it can be monitored in Spring Cloud Data Flow.

Create custom Spring Cloud Task

If you use the provided task-demo-metrics-influx source code you can skip this section.

Otherwise follow the instructions below to build your own monitorable Task from scratch.

Bootstrap by follow the Task development instructions and then:

  • Set the parent POM version of Boot to 2.2.0.M6 or latest
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.2.0.M6</version>
    <relativePath/>
</parent>
  • Make sure that spring-cloud-dependencies version Hoxton.M2 or newer are imported:
<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-dependencies</artifactId>
            <version>Hoxton.M2</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
</dependencyManagement>
  • Add dependencies to enable the Spring Cloud Task (and optionally Spring Task Batch) functionality and to configure the jdbc dependencies for the task repository. Use version 2.2.0.M2 or newer!
<dependencies>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-task</artifactId>
        <version>2.2.0.M2</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-task-core</artifactId>
        <version>2.2.0.M2</version>
    </dependency>
    
    <!-- Required when Spring Batch is used -->
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-task-batch</artifactId>
        <version>2.2.0.M2</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-task-stream</artifactId>
        <version>2.2.0.M2</version>
    </dependency>
</dependencies>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-task-dependencies</artifactId>
            <version>2.2.0.M2</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>
  • Add dependencies to configure the jdbc dependencies for the task repository:
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
<dependency>
    <groupId>org.mariadb.jdbc</groupId>
    <artifactId>mariadb-java-client</artifactId>
    <scope>runtime</scope>
</dependency>
  • Add dependencies to configure Micrometer integration:

The Micrometer library uses the actuator internally:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

To enable InfuxDB metrics add the following dependencies in place of the prometheus one:

<dependency>
    <groupId>io.micrometer</groupId>
    <artifactId>micrometer-registry-influx</artifactId>
</dependency>

Build

Run

./mvnw clean install

Will produce task-demo-metrics-influx-0.0.1-SNAPSHOT.jar task application under the target folder.

Spring Cloud Data FLow server

Follow the Task Monitoring instructions to register, run and monitor the task sample using Influx or Prometheus on the desired platform.

Docker images

Build and publish docker image

./mvnw clean install docker:build
./mvnw docker:push