New internal/metrics package (client_golang, own registry per instance) and a second listener in cmd/api: UPTIME_API_METRICS_LISTEN, default :9090, off disables it. Port 8080 does not serve /metrics.
HTTP:uptimesebi_http_requests_total{method,route,code}, ..._request_duration_seconds (long polls and agent streams are counted but not timed), ..._requests_in_flight.
Checker pipeline:
checks_dispatched_total, check_results_total{region,ok} (own for org checkers), check_results_rejected_total{reason}, check_result_delay_seconds.
checker_instances{region} and checks_overdue{region} per platform region. The latter uses the new Scheduler.Overdue.
Background jobs:job_runs_total{job,result}, job_duration_seconds, job_last_success_timestamp_seconds for reconcile, housekeeping, org_purge, region_watch, domain_watch, heartbeats and alertmanager_monitors.
Platform totals: read on scrape, cached 15 s, new queries PlatformCounts / MonitorCounts. Covers orgs, users, monitors by type, status pages, subscribers, open incidents, pending notifications and regions online.
Pools: Postgres and Redis pool stats, Go runtime, process and uptimesebi_build_info.
Helm:api.metrics.{enabled,port} adds the container and Service port. api.metrics.serviceMonitor.enabled adds a ServiceMonitor, off by default.
Docs: README and .env.example.
Also: region limit in the monitor form
The monitor form now gets the org's regions-per-monitor limit. It shows "Up to N (platform) regions per monitor (n/N)" and locks the remaining counted regions in both the list and the map once the limit is reached.
Own regions stay free unless own_regions_count is set. The server check stays as it was.
New i18n keys monitors.regions_limit and monitors.platform_regions_limit (en/de).
Tests: testdata/regionlimit.html, plus a TestLimits check that the form carries the limit and that own regions are not counted.
Test plan
internal/metrics: HTTP middleware (routes, unmatched, streams not timed), jobs, counters, handler output, pool collectors lint-clean
TestMetrics (API): results, duplicates and unknown monitors counted per region; platform totals and checker gauges present
TestOverdueCountsRunsLeftBehind
helm lint, helm template with and without metrics / ServiceMonitor
golangci-lint clean. Full test suite green; TestDispatchSpreadsRandomly is flaky in the parallel run (shared Redis DB) and passes alone.
Dev stack: curl :9090/metrics shows all families with live values; :8080/metrics returns 404
After rollout: set api.metrics.serviceMonitor.enabled: true in the Flux HelmRelease. The cluster's Prometheus selects all ServiceMonitors.
## Summary
- New `internal/metrics` package (client_golang, own registry per instance) and a second listener in `cmd/api`: `UPTIME_API_METRICS_LISTEN`, default `:9090`, `off` disables it. Port 8080 does not serve `/metrics`.
- **HTTP:** `uptimesebi_http_requests_total{method,route,code}`, `..._request_duration_seconds` (long polls and agent streams are counted but not timed), `..._requests_in_flight`.
- **Checker pipeline:**
- `checks_dispatched_total`, `check_results_total{region,ok}` (`own` for org checkers), `check_results_rejected_total{reason}`, `check_result_delay_seconds`.
- `checker_instances{region}` and `checks_overdue{region}` per platform region. The latter uses the new `Scheduler.Overdue`.
- **Notifications:** `notifications_total{channel_type,result}`, `notification_send_duration_seconds`, `subscriber_notifications_total`, `incidents_total{event}`.
- **Background jobs:** `job_runs_total{job,result}`, `job_duration_seconds`, `job_last_success_timestamp_seconds` for reconcile, housekeeping, org_purge, region_watch, domain_watch, heartbeats and alertmanager_monitors.
- **Platform totals:** read on scrape, cached 15 s, new queries `PlatformCounts` / `MonitorCounts`. Covers orgs, users, monitors by type, status pages, subscribers, open incidents, pending notifications and regions online.
- **Pools:** Postgres and Redis pool stats, Go runtime, process and `uptimesebi_build_info`.
- **Helm:** `api.metrics.{enabled,port}` adds the container and Service port. `api.metrics.serviceMonitor.enabled` adds a ServiceMonitor, off by default.
- **Docs:** README and `.env.example`.
## Also: region limit in the monitor form
- The monitor form now gets the org's regions-per-monitor limit. It shows "Up to N (platform) regions per monitor (n/N)" and locks the remaining counted regions in both the list and the map once the limit is reached.
- Own regions stay free unless `own_regions_count` is set. The server check stays as it was.
- New i18n keys `monitors.regions_limit` and `monitors.platform_regions_limit` (en/de).
- Tests: `testdata/regionlimit.html`, plus a `TestLimits` check that the form carries the limit and that own regions are not counted.
## Test plan
- [x] `internal/metrics`: HTTP middleware (routes, unmatched, streams not timed), jobs, counters, handler output, pool collectors lint-clean
- [x] `TestMetrics` (API): results, duplicates and unknown monitors counted per region; platform totals and checker gauges present
- [x] `TestOverdueCountsRunsLeftBehind`
- [x] `helm lint`, `helm template` with and without metrics / ServiceMonitor
- [x] golangci-lint clean. Full test suite green; `TestDispatchSpreadsRandomly` is flaky in the parallel run (shared Redis DB) and passes alone.
- [x] Dev stack: `curl :9090/metrics` shows all families with live values; `:8080/metrics` returns 404
After rollout: set `api.metrics.serviceMonitor.enabled: true` in the Flux HelmRelease. The cluster's Prometheus selects all ServiceMonitors.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
The API serves Prometheus metrics on a listener of its own
(UPTIME_API_METRICS_LISTEN, default :9090, "off" disables it), so the
public ingress never exposes them:
- requests by route and status, with durations except for long polls
and agent streams
- dispatched checks, stored and rejected results per region, how late
results arrive, live checkers and overdue checks per platform region
- notification and subscriber mail deliveries, incidents opened and
resolved
- runs, duration and last success of the background jobs
- platform totals (orgs, users, monitors by type, status pages,
subscribers, open incidents, pending notifications), read at most
every 15 seconds when scraped
- the Postgres and Redis connection pools, Go runtime and build info
The Helm chart exposes the port on the API service and can add a
ServiceMonitor for the Prometheus Operator.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
Sebi
changed title from feat(api): Prometheus metrics for operators to feat(api): Prometheus metrics; fix(monitors): region limit in the form2026-11-29 11:17:27 +00:00
The monitor form let users tick any number of regions and only the save
failed with the region limit. The form now knows the organization's
regions-per-monitor limit: it says how many regions a monitor may use,
counts the ticked ones, and once the limit is reached locks the other
regions that count towards it, in the list and on the map, until one is
unticked. Own regions stay free unless they count. The server still
enforces the limit.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
Sebi
merged commit 6aabf9a364 into main2026-11-29 11:21:32 +00:00
Sebi
deleted branch feat/api-metrics2026-11-29 11:21:35 +00:00
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Summary
internal/metricspackage (client_golang, own registry per instance) and a second listener incmd/api:UPTIME_API_METRICS_LISTEN, default:9090,offdisables it. Port 8080 does not serve/metrics.uptimesebi_http_requests_total{method,route,code},..._request_duration_seconds(long polls and agent streams are counted but not timed),..._requests_in_flight.checks_dispatched_total,check_results_total{region,ok}(ownfor org checkers),check_results_rejected_total{reason},check_result_delay_seconds.checker_instances{region}andchecks_overdue{region}per platform region. The latter uses the newScheduler.Overdue.notifications_total{channel_type,result},notification_send_duration_seconds,subscriber_notifications_total,incidents_total{event}.job_runs_total{job,result},job_duration_seconds,job_last_success_timestamp_secondsfor reconcile, housekeeping, org_purge, region_watch, domain_watch, heartbeats and alertmanager_monitors.PlatformCounts/MonitorCounts. Covers orgs, users, monitors by type, status pages, subscribers, open incidents, pending notifications and regions online.uptimesebi_build_info.api.metrics.{enabled,port}adds the container and Service port.api.metrics.serviceMonitor.enabledadds a ServiceMonitor, off by default..env.example.Also: region limit in the monitor form
own_regions_countis set. The server check stays as it was.monitors.regions_limitandmonitors.platform_regions_limit(en/de).testdata/regionlimit.html, plus aTestLimitscheck that the form carries the limit and that own regions are not counted.Test plan
internal/metrics: HTTP middleware (routes, unmatched, streams not timed), jobs, counters, handler output, pool collectors lint-cleanTestMetrics(API): results, duplicates and unknown monitors counted per region; platform totals and checker gauges presentTestOverdueCountsRunsLeftBehindhelm lint,helm templatewith and without metrics / ServiceMonitorTestDispatchSpreadsRandomlyis flaky in the parallel run (shared Redis DB) and passes alone.curl :9090/metricsshows all families with live values;:8080/metricsreturns 404After rollout: set
api.metrics.serviceMonitor.enabled: truein the Flux HelmRelease. The cluster's Prometheus selects all ServiceMonitors.🤖 Generated with Claude Code
https://claude.ai/code/session_017GpWAskjmYtZpuQ5JwYTX3
feat(api): Prometheus metrics for operatorsto feat(api): Prometheus metrics; fix(monitors): region limit in the form