Repository navigation
Service: Prometheus metrics at GET /metrics, gated by MONITORING_TOKEN - #43
Merged
Merged
Conversation
…mily With marine coverage live, 7% of events were rejected by the 900 a minute per-station limit, which was sized for aircraft receivers. Marine stations now get 6000 a minute. The AIS range limit goes from 70 to 100 km (120 km with the existing 20% margin). Health now reports rate-limited events by transport and out-of-range positions by radio family, split into within twice the limit and beyond it, so the remaining limits can be judged from production numbers. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PS44Q7WRmAzMJLhi44dzdo
A busy receiver is legitimate, so coverage should not drop its events. Replaces the higher marine limit from the previous commit. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PS44Q7WRmAzMJLhi44dzdo
Per-station message counts were summed from the H3 cells. A cell's count is the total of every station that reported into it, so each station sharing a cell was credited with all of them, and messages without a position were not counted. Read the counts from the per-station sliding windows instead, which record every accepted event once. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PS44Q7WRmAzMJLhi44dzdo
Stations listed in AREA_FEED_STATIONS (default NCT, the Norwegian coastal administration's national AIS feed) relay a whole area, not one antenna. Their positions are kept at any distance and give the station no range or direction of its own, the same way satellite relays are handled. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PS44Q7WRmAzMJLhi44dzdo
Mirrors the /api/v1/health counters with prom-client (prefix coverage_), read at scrape time so the two cannot disagree. The port is public, so the route needs MONITORING_TOKEN as a bearer token or X-Monitoring-Token, compared in constant time, and answers 401 when the variable is unset. Adds accepted events by radio family, last-success timestamps for the station sync and snapshot save, and the build commit in the image. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PS44Q71yEaiXrKpFsgUpg1
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 35 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Deploying airframes-coverage with
|
| Latest commit: |
b8e8930
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://699e52ce.airframes-coverage.pages.dev |
| Branch Preview URL: | https://feature-prometheus-metrics.airframes-coverage.pages.dev |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Requested by Kevin · project thread
Summary
Adds a Prometheus scrape endpoint to the coverage service, as part of the monitoring work (Prometheus and Grafana live in
airframesio/stack).This branch is built on top of #42 because #42 changes the health counters this mirrors. Until #42 merges, the diff here includes its four commits. The change that belongs to this PR is the last commit.
What it does
GET /metricsat the root of port 3002, Prometheus text format, usingprom-client.metrics-token.guard.ts: the token comes inAuthorization: Bearer <token>orX-Monitoring-Token, is compared in constant time, and the route answers 401 whenMONITORING_TOKENis not set. The public API routes are unchanged./api/v1/healthalready reports, so the two cannot disagree and the ingest path does no extra work beyond one new counter.Metrics
coverage_build_info{version,commit}commitcomes from a newGIT_SHAbuild arg set by the Docker Push jobcoverage_nats_connected,coverage_nats_messages_received_total,coverage_nats_messages_parsed_total,coverage_nats_parse_errors_total,coverage_nats_raw_positions_found_totalcoverage_events_processed_total{source}sourceis the radio family:acars,vdl,hfdl,satcom,ais,unknown. New counter in the store, also shown on health asprocessedBySourcecoverage_events_rejected_total{reason}coverage_events_with_position_total,coverage_events_without_position_totalcoverage_positions_discarded_total{reason}coverage_positions_out_of_range_total{source,band}bandisnearorfar, from #42'soutOfRangecoverage_stations_tracked,coverage_active_cells{resolution},coverage_cells_in_memorycoverage_marine_events_total{outcome},coverage_marine_pending,coverage_marine_tracked_voyagespaired,from_last_position,without_position,unknown_stationcoverage_station_sync_last_success_timestamp_secondscoverage_snapshot_last_success_timestamp_seconds,coverage_snapshot_duration_secondsprocess_resident_memory_bytes,process_cpu_seconds_total,process_start_time_seconds,nodejs_eventloop_lag_seconds, ...No station ids, idents or other unbounded labels.
Testing
npm run typecheck,npm run buildandnpm testpass (48 tests, 9 new intest/metrics.test.ts: fails closed without the variable, rejects a missing or wrong token, accepts both header forms, values match/api/v1/health, no double counting across scrapes).GIT_SHAarg (no Docker in the sandbox; CI's Docker Build job covers it).To deploy
Set
MONITORING_TOKENon the coverage stack in Dockhand (the same value Prometheus sends). Until it is set the route answers 401 and nothing else changes.Generated by Claude Code