feat(server): persist server self-metrics into ClickHouse

Snapshot the full Micrometer registry (cameleer business metrics, alerting
metrics, and Spring Boot Actuator defaults) every 60s into a new
server_metrics table so server health survives restarts without an external
Prometheus. Includes a dashboard-builder reference for the SaaS team.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
hsiegeln
2026-04-23 23:20:45 +02:00
parent 0bbe5d6623
commit 48ce75bf38
14 changed files with 913 additions and 1 deletions

View File

@@ -0,0 +1,16 @@
package com.cameleer.server.core.storage;
import com.cameleer.server.core.storage.model.ServerMetricSample;
import java.util.List;
/**
* Sink for periodic snapshots of the server's own Micrometer meter registry.
* Implementations persist the samples (e.g. to ClickHouse) so server
* self-metrics survive restarts and can be queried historically without an
* external Prometheus.
*/
public interface ServerMetricsStore {
void insertBatch(List<ServerMetricSample> samples);
}

View File

@@ -0,0 +1,23 @@
package com.cameleer.server.core.storage.model;
import java.time.Instant;
import java.util.Map;
/**
* A single sample of the server's own Micrometer registry, captured by a
* scheduled snapshot and destined for the ClickHouse {@code server_metrics}
* table. One {@code ServerMetricSample} per Micrometer {@code Measurement},
* so Timers and DistributionSummaries produce multiple samples per tick
* (distinguished by {@link #statistic()}).
*/
public record ServerMetricSample(
String tenantId,
Instant collectedAt,
String serverInstanceId,
String metricName,
String metricType,
String statistic,
double value,
Map<String, String> tags
) {
}