Build a job analytics dashboard for Firebird in Spring Boot. Visualize job history, failures, and duration trends to improve reliability and detect recurring issuesOnce auto-retry and alerts are working, the next logical step is
visual analytics.
In this stage, we’ll create a dashboard to visualize job history, success rate, and failure trends — helping you detect recurring issues and improve stability.
1. Why Build a Job Analytics Dashboard
A simple log table shows what happened, but an analytics dashboard
shows patterns.
You can answer key questions such as:
- Which jobs fail most often?
- What times see the most failures?
- How long do successful jobs take on average?
These insights help optimize scheduling and identify weak points in your Firebird maintenance routines.
2. Extend the Log Table
Add extra columns to record job duration and retry attempts.
ALTER TABLE MAINTENANCE_LOG ADD COLUMN DURATION_MS BIGINT;
ALTER TABLE MAINTENANCE_LOG ADD COLUMN RETRY_COUNT INT;
Then, update your scheduler to calculate and save these values.
long start = System.currentTimeMillis();
try {
auditRepo.archiveOldLogs();
auditRepo.deleteOldLogs();
long duration = System.currentTimeMillis() - start;
logRepo.save(new MaintenanceLog("Cleanup Job", "SUCCESS",
LocalDateTime.now(), "Completed successfully.", duration, 0));
} catch (Exception e) {
logRepo.save(new MaintenanceLog("Cleanup Job", "FAILED",
LocalDateTime.now(), e.getMessage(), 0L, 1));
}
Now your data includes performance and reliability metrics for each run.
3. Create Repository Queries for Analytics
Define custom queries in your repository to get aggregated statistics.
@Query("SELECT m.jobName, COUNT(m), SUM(CASE WHEN m.status = 'FAILED' THEN 1 ELSE 0 END) " +
"FROM MaintenanceLog m GROUP BY m.jobName")
List<Object[]> countJobFailures();
@Query("SELECT AVG(m.durationMs) FROM MaintenanceLog m WHERE m.status = 'SUCCESS'")
Long averageJobDuration();
These queries help you summarize job health directly from Firebird.
4. Build REST Endpoints for Dashboard Data
Expose the analytics data through simple JSON APIs.
@RestController
@RequestMapping("/api/analytics")
public class AnalyticsController {
@Autowired
private MaintenanceLogRepository logRepo;
@GetMapping("/failures")
public List<Object[]> getFailureStats() {
return logRepo.countJobFailures();
}
@GetMapping("/avg-duration")
public Long getAverageDuration() {
return logRepo.averageJobDuration();
}
}
This will serve the backend data for visualization tools or custom UI components.
5. Create the Dashboard UI
You can display charts using
Chart.js or
Google Charts in a simple HTML/Thymeleaf template.
<canvas id="jobStats" width="400" height="200"></canvas>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script>
fetch('/api/analytics/failures')
.then(res => res.json())
.then(data => {
const labels = data.map(d => d[0]);
const failures = data.map(d => d[2]);
new Chart(document.getElementById('jobStats'), {
type: 'bar',
data: {
labels: labels,
datasets: [{ label: 'Job Failures', data: failures, backgroundColor: 'rgba(255,99,132,0.5)' }]
}
});
});
</script>
This chart gives an at-a-glance view of which jobs fail most often.
6. Add Trend Visualization
To monitor trends, you can group logs by date:
SELECT CAST(EXECUTED_AT AS DATE) AS run_date,
COUNT(*) AS total_jobs,
SUM(CASE WHEN STATUS = 'FAILED' THEN 1 ELSE 0 END) AS failed_jobs
FROM MAINTENANCE_LOG
GROUP BY CAST(EXECUTED_AT AS DATE)
ORDER BY run_date;
Plotting this over time reveals patterns — for example, increasing failures after a specific update.
image quote pre code