1
0
mirror of https://blitiri.com.ar/repos/chasquid synced 2025-12-17 14:37:02 +00:00

monitoring: Add OpenMetrics exporter

This patch makes chasquid's monitoring server expose an OpenMetrics
metrics endpoint.

It adds a new package "expvarom" which implements an HTTP handler that
exports expvar variables in the OpenMetrics text format.

Then, the handler is registered by the monitoring server at /metrics
(where most things expect it to be).

The existing exported variables are also extended with descriptions,
which is optional, but improves the readability of the metrics.
This commit is contained in:
Alberto Bertogli
2020-08-19 20:42:28 +01:00
parent 7e412db19b
commit 7fe42a368a
12 changed files with 447 additions and 154 deletions

View File

@@ -55,6 +55,13 @@ fetch http://localhost:1099/debug/config .data-A/dbg-config \
|| fail "failed to fetch /debug/config"
fetch http://localhost:1099/404 .data-A/dbg-404 \
&& fail "fetch /404 worked, should have failed"
fetch http://localhost:1099/metrics .data-A/metrics \
&& linesgt10 .data-A/metrics \
|| fail "failed to fetch /metrics"
# Quick sanity-check of the /metrics page, just in case.
grep -q '^chasquid_queue_itemsWritten [0-9]\+$' .data-A/metrics \
|| fail "A /metrics is missing the chasquid_queue_itemsWritten counter"
# Wait until one of them has noticed and stopped the loop.
while sleep 0.1; do