# How to monitor Spring Cloud Task
The `task-demo-metrics-prometheus` 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-prometheus` source code you can skip this section.
Otherwise, follow the instructions below to build your own `monitorable` Task from scratch.
Follow the [Task development instructions](https://docs.spring.io/spring-cloud-task/docs/2.3.0/reference/#getting-started-developing-first-task) and then:
* Set the parent POM version of Boot to 2.7.16 or latest
```xml
org.springframework.boot
spring-boot-starter-parent
2.7.16
```
* Make sure that `spring-cloud-task-dependencies` version `2.4.6` or newer are imported:
```xml
org.springframework.cloud
spring-cloud-task-dependencies
2.4.6
pom
import
```
* Enable Spring Batch and Spring Cloud Task
```xml
org.springframework.cloud
spring-cloud-starter-task
org.springframework.boot
spring-boot-starter-batch
```
* Add dependencies to configure the jdbc dependencies for the task repository:
```xml
org.mariadb.jdbc
mariadb-java-client
runtime
```
* Add dependencies to configure Micrometer integration:
To enable Prometheus metrics collection add:
```xml
io.micrometer
micrometer-registry-prometheus
io.micrometer.prometheus
prometheus-rsocket-spring
1.5.2
```
* Configure the Application metadata generation
```xml
org.springframework.boot
spring-boot-configuration-processor
true
```
```xml
org.springframework.cloud
spring-cloud-dataflow-apps-metadata-plugin
1.0.7
true
io.spring.task.taskdemometrics.TaskDemoMetricsProperties
aggregate-metadata
compile
aggregate-metadata
org.codehaus.mojo
properties-maven-plugin
1.0.0
process-classes
read-project-properties
${project.build.outputDirectory}/META-INF/spring-configuration-metadata-encoded.properties
io.fabric8
docker-maven-plugin
0.33.0
springcloudtask/${project.artifactId}
latest
${project.version}
springcloud/baseimage:1.0.0
/tmp
${org.springframework.cloud.dataflow.spring.configuration.metadata.json}
java
-jar
/maven/task-demo-metrics-prometheus.jar
assembly.xml
```
## Build
Run
```
./mvnw clean install
```
Will produce `task-demo-metrics-prometheus-2.0.0-SNAPSHOT.jar` task application under the `target` folder.
## Spring Cloud Data FLow server
Follow the [Task Monitoring](https://dataflow.spring.io/docs/feature-guides/batch/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
```