Hierarchical monitoring in Spring Batch means measuring the job, each step, each chunk and each item as separate levels, so a slowdown or failure can be traced from the whole job down to the exact stage. In Spring Batch 5 on Spring Boot 3 you get most of this from built-in Micrometer metrics and Actuator, then add listeners for the levels and business counters you need.
For low-latency datasets the main rule is to keep monitoring cheap: record timers and counters, avoid per-item logging or database writes, and alert on rates and percentiles instead of single events.
Spring Batch already models work as a hierarchy, and each level answers a different question.
| Level | Spring Batch concept | Question it answers | Typical signal |
|---|---|---|---|
| Job | Job / JobExecution | Did the run finish, and how long did it take? | duration, status, active jobs |
| Step | Step / StepExecution | Which stage is slow or failing? | step duration, read/write/skip counts |
| Chunk | one read-process-write transaction | Is commit time growing? | chunk write time, rollback count |
| Item | ItemReader, ItemProcessor | Are individual records slow or bad? | read/process time, skips, filters |
Start with job and step metrics in production. Turn on chunk and item level detail only where you need it, because these levels run most often.
Spring Batch 5 publishes Micrometer metrics automatically when a MeterRegistry is present. Add Actuator and a registry such as Prometheus:
The framework records meters whose names start with spring.batch, including job and step timers (spring.batch.job, spring.batch.step), item read and process timers, chunk write timers and a gauge of active jobs. Check /actuator/metrics on your version for the exact list, since meter names are tagged with the job and step names and have changed between releases. Tags such as name and status let you aggregate upward (all steps of a job) or drill down (one step).
For custom signals, register listeners on the step. StepExecution already holds read, write, skip and commit counts, so a listener only needs to publish them.
Publishing at afterStep costs one update per step. If you need near-real-time progress for long steps, use a ChunkListener and publish once per chunk rather than per item:
The Spring Batch 5 builders take the JobRepository and a transaction manager explicitly. @EnableBatchProcessing is not needed on Spring Boot 3.
Chunk size is the main latency lever: small chunks commit often and give fine-grained feedback, large chunks raise throughput but delay both commits and visible progress.
JobExplorer queries stay fast.Build alerts from the hierarchy so each one points to a level:
importJob within its expected window, or duration above the 95th percentile of the last week.FAILED status.For ad hoc inspection, JobExplorer returns executions and their step executions, and a JobExecutionListener can send a notification when a job ends with a failed status.
Yes. Since Spring Batch 5 it records Micrometer metrics for jobs, steps, item reads and processing, and chunk writes whenever a MeterRegistry bean exists, which Spring Boot Actuator provides.
No. Per-item logging adds I/O to the hot path. Count and time items with Micrometer and log only failures and skips.
In the Spring Batch metadata tables (BATCH_JOB_EXECUTION, BATCH_STEP_EXECUTION and related) of the configured DataSource. They are also the source for restarts.
Publish a gauge or counter from a ChunkListener and graph it, or poll StepExecution read and write counts through JobExplorer.
Monitor Spring Batch at four levels: job, step, chunk and item. Use the built-in Micrometer metrics with Actuator as the base, add StepExecutionListener and ChunkListener counters for business signals, keep tags low in cardinality, and alert at the level where the symptom appears. Tune chunk size and avoid per-item work to keep the overhead low on latency-sensitive datasets.