Issue
I have many spring batch applications which are simple job or deamons that run as a fat jar in linux via shell scripts, one of the challenges we face is performance monitoring of the application metrics such as processing speed ,identify bottleneck ,time taken by rest api calls,DB query latency . Currently we have some AOP annotations that give us some metrics in a log file . But I was wondering are there any standard tools /APM for it. Options explored so far :
- Spring Data Admin : it is now a retired project and seems like cannot be used
- Spring actuator and HAL browser: It needs a web server but my applications are batch
- APM like glow root /prometheus : but I cannot find some documentation / ref guide on how to implement with spring batch properly.
I want to know what is the standard way of monitoring spring batch application this in spring batch , if possible one that gives DB query metrics (like high query timing) out of the box with simple change , a pointer to the documentation of ref guide for same would be nice
Solution
- Use Spring Cloud DataFlow instead
- Spring Boot actuator does not provide Batch specific metrics, but it is definitely useful for JVM metrics that you might want to monitor for your batch apps as well (memory usage, GC activity, etc)
- Spring Batch provides out-of-the box integration with Micrometer since v4.2. This gives you the choice between metrics backends (prometheus, influxdb, etc).
what is the standard way of monitoring spring batch application
The standard way is through Micrometer, as mentioned previously. There is also tracing support coming in v5.
a pointer to the documentation of ref guide for same would be nice
- The reference documentation: https://docs.spring.io/spring-batch/docs/current/reference/html/monitoring-and-metrics.html#monitoring-and-metrics
- Sample of Batch metrics with Prometheus/Grafana: https://github.com/spring-projects/spring-batch/tree/main/spring-batch-samples#batch-metrics-with-micrometer
Answered By - Mahmoud Ben Hassine
Answer Checked By - Dawn Plyler (JavaFixing Volunteer)