Repository navigation
[Server] Add health and metrics endpoints (/livez, /readyz, /metrics) - #1906
Conversation
Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Spec §8/PR2 required that after a table is created via the API, the uc_tables_created counter must appear on the live /metrics scrape. TableServiceMetricTest already verified the counter increment at unit level (SimpleMeterRegistry), and MetricsEndpointTest only asserted jvm_memory_used_bytes; nothing tied a real table create to the live Prometheus output. Add MetricsDomainCounterTest that: - Extends BaseTableCRUDTestEnv (server started, catalog+schema wired in @beforeeach, no extra setup needed). - Creates an external table via the SDK (SdkTableOperations, same as SdkTableCRUDTest). - Issues a raw GET /metrics (same java.net.http pattern as MetricsEndpointTest) and asserts the response body contains uc_tables_created. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Strengthen MetricsDomainCounterTest to verify the uc_tables_created_total metric value actually increases after a table is created, not just that the counter line is present in the metrics scrape. This prevents the test from passing if the increment path regresses (counter would stay at 0.0). Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Add docs/server/observability.md covering the three unauthenticated observability endpoints served on the UC server port: /livez (liveness, no DB touch), /readyz (readiness, cached background DB check, fails closed, drains on shutdown), and /metrics (Prometheus text exposition). Includes metric families, a Prometheus scrape config example, and a Kubernetes probe snippet. Wire the new page into the Server nav block in mkdocs.yml. Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
| .isFalse(); | ||
| assertThat( | ||
| UCTableProperties.shouldPersistProperty("spark.sql.sources.schema.part.0")) | ||
| assertThat(UCTableProperties.shouldPersistProperty("spark.sql.sources.schema.part.0")) |
There was a problem hiding this comment.
came with existing formatting tool from other PRs.
|
Can we serve These 3 are unauthenticated internal endpoints and are supposed to be accessed only internally. If they exposed on the same port they can be accidentally leaked outside, especially when the new release is upgraded on existing deployments where there was no such consideration when initially deployed and their API proxy config hasn't blocked these endpoints. Instead when they are hosted on a separate dedicated port number, it won't be accidentally leaked. This will be some extra work on the Armeria server builder etc as it has to open up a separate port number listener etc. |
65cf3d6 to
25ed517
Compare
Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Co-authored-by: Isaac <[email protected]> Signed-off-by: Shubham Bansal <[email protected]>
Disable the observability listener by default, add explicit CLI port configuration and collision validation, and keep domain metrics safe when observability is disabled. Signed-off-by: Shubham Bansal <[email protected]>
Signed-off-by: Shubham Bansal <[email protected]>
Signed-off-by: Shubham Bansal <[email protected]>
Signed-off-by: Shubham Bansal <[email protected]>
Signed-off-by: Shubham Bansal <[email protected]>
Signed-off-by: Shubham Bansal <[email protected]>
Use the observability port flag as the sole opt-in signal and require a valid explicit port. Remove the enable property and automatic port selection, update documentation and existing tests, and address metric registration and build review feedback. Signed-off-by: Shubham Bansal <[email protected]>
Signed-off-by: Shubham Bansal <[email protected]>
Match Armeria with Micrometer 1.17.0 and use its modern Prometheus integration. Expose only the HTTP request counter without the result tag while preserving other metric families. Rename the persisted table counter to avoid the reserved created suffix. Signed-off-by: Shubham Bansal <[email protected]>
Signed-off-by: Shubham Bansal <[email protected]>
timothyw553
left a comment
There was a problem hiding this comment.
one more small nit. very close!
Register HTTP metrics outside the security decorators so authentication and authorization failures are recorded. Assert exact Prometheus series for successful requests, rejected bodies, access denials, server errors, and unmatched routes, and document the emitted labels and examples. Signed-off-by: Shubham Bansal <[email protected]>
Assert expired-token rejection counts, response-time authorization failure counts without a success series or leaked data, and unchanged API counters across observability probes and scrapes. Reuse existing test classes and fixtures. Signed-off-by: Shubham Bansal <[email protected]>
PR Checklist
docsis updatedDescription of changes
Adds opt-in production observability endpoints to the Unity Catalog server:
GET /livez200 OKwith{"healthy":true}GET /readyz200 OKwith{"healthy":true}when ready, or503 Service Unavailablewith{"healthy":false}GET /metricsJVM:
jvm_memory_used_bytes,jvm_gc_*,jvm_threads_*CPU:
process_cpu_usage,system_cpu_usageArmeria:
armeria_server_*,armeria_executor_*HTTP request counts, for example:
http_server_requests_total{hostname_pattern="*:8081",http_status="200",method="createCatalog",service="io.unitycatalog.server.service.CatalogService"} 1.0Persisted table-securable creates:
uc_securable_table_creations_totalStart the server with
--obs-port <port>to enable observability. The flag requires an explicitport between
1and65535; omitting it keeps observability disabled. There is no separateenable property, default observability port, or automatic port selection.
All three endpoints are unauthenticated and served on a dedicated observability port on the
same Armeria server as the API. The API and observability surfaces use port-based virtual hosts,
so cross-surface requests return
404. The API port remains loopback-only behind Vert.x,while the observability port binds all interfaces for kubelet and Prometheus access;
deployments should restrict that port with network policy.
The CLI port layout is:
NN + 1--obs-portvalue, when suppliedStartup fails if the observability port is invalid, conflicts with either API port, or any
required port cannot be bound. It does not search for a fallback port.
Readiness performs one synchronous database check before serving, then refreshes a cached
result on a background schedule. Requests never perform JDBC work. The checker fails closed
and catches probe failures so one failed scheduled execution cannot freeze readiness in a
stale healthy state. This PR does not configure production graceful draining or add a process
shutdown hook.
Uses Micrometer
1.17.0, matching the published dependencies of Armeria1.41.1, witharmeria-prometheus1for the modern Prometheus registry.Within the
http_server_*family, onlyhttp_server_requests_totalis exposed, tagged byhostname_pattern,service,method, andhttp_status, withoutresult.methodis the annotated Java handler name (for example,createCatalog), not the HTTP verb; unmatched routes use the HTTP verb. HTTP latency, size, timeout, andin-flight metrics are not exposed. JVM, CPU, Armeria-internal, and UC metrics remain enabled.
uc_securable_table_creations_totalincrements after the database transaction commits. Itcovers creates through UC, Delta, and Iceberg REST, including views and metric views, because
those securables share the persisted table-create path. The counter uses
creationsratherthan
createdto avoid Prometheus's reservedcreatedsuffix.Configuration:
--obs-port <port>— enables observability on an explicit port; omitted means disabledserver.readiness.probe-interval— background readiness-check interval (defaultPT5S)server.readiness.db-timeout—Connection.isValidtimeout (defaultPT2S)Validation covers required CLI values, disabled-by-default startup, port bounds and collisions,
two-port/vhost isolation, readiness, metrics exposition, and successful and failed UC, Delta,
Iceberg, view, and metric-view creates.
build/sbt testrun is in progress; this update does not claim a full-suite pass. CI for the updated commit is pending.Closes #1905.