Alerting ensures you know when ClickHouse performance drops or errors occur. Using Spring Boot monitoring and external tools, you can set alerts easily.
1. Expose Metrics with Actuator
Enable Actuator in
application.properties:
management.endpoints.web.exposure.include=health,metrics
management.endpoint.health.show-details=always
This gives you endpoints for health and metrics.
2. Add Key Metrics
Monitor critical areas:
- Connection pool usage (
hikaricp.connections.active)
- Query execution time
- Error counts
- Disk or memory usage (via system metrics)
3. Integrate with Prometheus
Prometheus can scrape Actuator metrics. Add Prometheus registry:
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
</dependency>
Configure Prometheus to scrape
/actuator/prometheus.
4. Create Alert Rules
In Prometheus, define rules:
- alert: HighQueryLatency
expr: clickhouse_query_time_ms > 500
for: 1m
labels:
severity: warning
annotations:
description: "Queries taking longer than 500ms"
5. Send Alerts
Connect Prometheus to
Alertmanager, then forward alerts via:
6. Automate Health Checks
Spring Boot health indicators can trigger alerts if ClickHouse is unreachable:
GET /actuator/health
If status is
DOWN, Alertmanager sends notification.
image quote pre code