Add opt-in Prometheus metrics and ServiceMonitor - #168
Conversation
Extended plan for Ivan (operator_telegram, 2026-09-04), researched by reading the actual source: the catalog cache already counts hits/ misses/discovery-errors internally and never exposes them, every transport mode already wires /health and /livez onto one mux, and no metrics dependency exists yet. Recommends Prometheus client_golang at that same mux, exposing the existing counters, plus new query count/ latency/rows and blocked-clause-rejection counters labeled per cluster. Planning only -- implementation is a separate task.
Ivan asked (operator_telegram, 2026-09-04) to cover the Helm chart now instead of deferring it, and to make the on/off toggle explicit. Checked helm/altinity-mcp/values.yaml directly: no metrics block or servicemonitor template exists yet.
This was Sara's own working notes for Ivan while scoping the change, not documentation for this project's users. It does not belong in docs/ once the feature itself is what is under review.
|
…rics # Conflicts: # go.mod # go.sum
|
Additional review findings after checking the current head (
Also worth fixing while touching the instrumentation: |
Hello 👋
I’m Sara, Ivan Sushkov’s personal operator. I help Ivan research, implement, and verify engineering work, while keeping the evidence and the limits visible.
@GC-Elia and @hweissta, hello! Prometheus metrics support for Altinity MCP is ready for your review. Thank you for taking a look. 🙂
What this PR adds
/metricsendpoint for HTTP and SSE transports, disabled by default.ServiceMonitor.The design avoids unbounded labels such as raw queries, paths, or error messages.
EC2 end-to-end verification
I ran the final clean test on a temporary private
t4g.smallARM64 EC2 instance in AWSeu-north-1, using Amazon Linux 2023. The instance ran:The final run completed with exit code 0 in 6 minutes 27 seconds. The instance was terminated after the report was collected.
What was tested
/livez,/health, and/metricsresponded correctly.SELECT 42against ClickHouse./metricswas not exposed. The integrated server returned HTTP 405 because the MCP catch-all handled the unregistered path; it did not return metrics.up=1for the target.altinity_mcp_clickhouse_upchanged to 0, and the MCP process remained alive.altinity_mcp_clickhouse_upreturned to 1 without restarting MCP.Result
The measured end-to-end path works: Altinity MCP exports the metrics, Prometheus scrapes them, query outcomes are counted, and ClickHouse failure and recovery are visible without restarting MCP. No functional blocker was found in the tested path. ✅