Skip to content

[Server] Add health and metrics endpoints (/livez, /readyz, /metrics) - #1906

Merged
yili-db merged 44 commits into
unitycatalog:mainfrom
shba24:uc-observability
Oct 5, 2026
Merged

yili-db merged 44 commits into
unitycatalog:mainfrom
shba24:uc-observability

Conversation

@shba24

@shba24 shba24 commented Sep 18, 2026 •

Copy link
Copy Markdown
Collaborator

PR Checklist

Description of changes

Adds opt-in production observability endpoints to the Unity Catalog server:

Endpoint Purpose
GET /livez Liveness while the server is running; returns 200 OK with {"healthy":true}
GET /readyz Database-backed readiness; returns 200 OK with {"healthy":true} when ready, or 503 Service Unavailable with {"healthy":false}
GET /metrics Prometheus metrics:
JVM: jvm_memory_used_bytes, jvm_gc_*, jvm_threads_*
CPU: process_cpu_usage, system_cpu_usage
Armeria: 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.0
Persisted table-securable creates: uc_securable_table_creations_total

Start the server with --obs-port <port> to enable observability. The flag requires an explicit
port between 1 and 65535; omitting it keeps observability disabled. There is no separate
enable 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:

  • client/Vert.x: N
  • internal Armeria API: N + 1
  • observability: the explicit --obs-port value, when supplied

Startup 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 Armeria 1.41.1, with
armeria-prometheus1 for the modern Prometheus registry.

Within the http_server_* family, only http_server_requests_total is exposed, tagged by
hostname_pattern, service, method, and http_status, without result. method is the annotated Java handler name (for example, createCatalog), not the HTTP verb; unmatched routes use the HTTP verb. HTTP latency, size, timeout, and
in-flight metrics are not exposed. JVM, CPU, Armeria-internal, and UC metrics remain enabled.

uc_securable_table_creations_total increments after the database transaction commits. It
covers creates through UC, Delta, and Iceberg REST, including views and metric views, because
those securables share the persisted table-create path. The counter uses creations rather
than created to avoid Prometheus's reserved created suffix.

Configuration:

  • --obs-port <port> — enables observability on an explicit port; omitted means disabled
  • server.readiness.probe-interval — background readiness-check interval (default PT5S)
  • server.readiness.db-timeout — Connection.isValid timeout (default PT2S)

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.

  • Latest HTTP-metric validation: 25 focused tests passed across the server, catalog access-control, authentication, permissions, and observability integration test classes. Assertions cover successful responses, conversion failures, authentication and authorization rejections (including expired tokens and response-time denials), server errors, unmatched routes, and exclusion of observability probes and scrapes. The new assertions were also checked against deliberately injected counting faults; those temporary production changes were removed.
  • A full root build/sbt test run is in progress; this update does not claim a full-suite pass. CI for the updated commit is pending.

Closes #1905.

shba24 and others added 10 commits September 18, 2026 20:42
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"))

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

came with existing formatting tool from other PRs.

@yili-db

yili-db commented Sep 25, 2026

Copy link
Copy Markdown
Collaborator

Can we serve /livez, /readyz, and /metrics on a dedicated observability port in this PR, rather than on the main API listener?

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.

@shba24
shba24 force-pushed the uc-observability branch 2 times, most recently from 65cf3d6 to 25ed517 Compare September 26, 2026 03:35
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]>

@timothyw553 timothyw553 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

two comments.

Comment thread docs/server/observability.md Resolved
Comment thread build.sbt Resolved
Comment thread build.sbt Resolved
shba24 added 2 commits October 1, 2026 19:40
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]>
Comment thread build.sbt Resolved
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]>

@timothyw553 timothyw553 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

one more small nit. very close!

shba24 added 2 commits October 3, 2026 00:03
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]>
@yili-db
yili-db merged commit d8823fc into unitycatalog:main Oct 5, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Observability endpoints for the UC server: /livez, /readyz, /metrics

3 participants