Skip to content

cluster_link: export Schema Registry sync totals as prometheus metrics#31067

Open
nguyen-andrew wants to merge 3 commits into
redpanda-data:devfrom
nguyen-andrew:sl-sr-prometheus
Open

cluster_link: export Schema Registry sync totals as prometheus metrics#31067
nguyen-andrew wants to merge 3 commits into
redpanda-data:devfrom
nguyen-andrew:sl-sr-prometheus

Conversation

@nguyen-andrew

Copy link
Copy Markdown
Member

Expose the totals_since_task_start counters of Schema Registry
shadowing as shadow_link_schema_registry_* counters on both the
internal and public prometheus endpoints, labelled by
shadow_link_name, with unit and ducktape coverage.

Fixes https://redpandadata.atlassian.net/browse/CORE-16607

Backports Required

  • none - not a bug fix
  • none - this is a backport
  • none - issue does not exist in previous branches
  • none - papercut/not impactful enough to backport
  • v26.1.x
  • v25.3.x
  • v25.2.x

Release Notes

Features

  • Schema Registry shadowing now exports its sync totals as
    shadow_link_schema_registry_* counters on the internal and public
    metrics endpoints, labelled by shadow_link_name.

}

const auto sl_name = link_probe::shadow_link_name(link_name);
const auto& totals = status.totals_since_task_start;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think resolving the reference to totals_since_task_start this early might already be or could become problematic when mirroring_task::_status.totals_since_task_start is assigned a fresh value, which is currently done in mirroring_task::reset_sync_state().

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good point, forgot about that

{
sm::make_counter(
"schema_registry_subject_versions_changed",
[&totals] { return totals.subject_versions_changed; },

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The mirroring_task has a reconcile stats field that is added onto the status counters on status reporting call. It might be simplest to either reuse mirroring_task::get_status_report() here too.

@nguyen-andrew

Copy link
Copy Markdown
Member Author

Force push to address PR comments and add more tests.

@nguyen-andrew nguyen-andrew marked this pull request as ready for review July 11, 2026 04:12
Copilot AI review requested due to automatic review settings July 11, 2026 04:12

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR exposes Schema Registry shadow-linking totals_since_task_start counters as Prometheus counters (shadow_link_schema_registry_*) on both internal (/metrics) and public (/public_metrics) endpoints, labelled by shadow_link_name, and adds unit + ducktape coverage to validate behavior across leadership changes and task lifecycle.

Changes:

  • Add a Schema Registry sync probe that registers shadow_link_schema_registry_* counters on both metrics endpoints.
  • Extend Schema Registry shadow-linking tests (C++ and ducktape) to validate counter presence/values, pause/stop behavior, and leadership-tenure resets.
  • Update build targets to include the new probe and metric-test utilities.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/rptest/tests/cluster_linking_schema_registry_sync_test.py Adds ducktape assertions for the new Prometheus counters on both endpoints and leadership-movement behavior.
src/v/cluster_link/schema_registry_sync/tests/mirroring_task_test.cc Adds unit tests validating metric export, pause/stop series lifetime, leadership tenure resets, and scrape-time behavior.
src/v/cluster_link/schema_registry_sync/tests/BUILD Adds deps needed for new metric tests (metrics + test_utils metrics).
src/v/cluster_link/schema_registry_sync/probe.h New probe interface for exporting Schema Registry sync totals as metrics.
src/v/cluster_link/schema_registry_sync/probe.cc New probe implementation registering shadow_link_schema_registry_* counters.
src/v/cluster_link/schema_registry_sync/mirroring_task.h Integrates the probe and adds helper for live status assembly.
src/v/cluster_link/schema_registry_sync/mirroring_task.cc Registers/clears the probe on start/stop and reuses live-status helper in status reporting.
src/v/cluster_link/schema_registry_sync/BUILD Adds probe sources/headers and metrics dependency to the library build.

Comment on lines +147 to +149
_probe.setup(get_link()->get_config()->name, [this] {
return get_live_sync_status().totals_since_task_start;
});
#include "test_utils/metrics.h"
#include "test_utils/test.h"

#include <seastar/core/coroutine.hh>
Comment on lines +26 to +30
/// The owning task keeps the series registered while it is not stopped,
/// i.e. on the shard leading `_schemas/0`, including while paused (the
/// totals survive a pause). Stopping resets the totals, so a stale series
/// cannot linger after leadership moves away; a transfer may briefly
/// export the series on zero or two nodes.
@nguyen-andrew

Copy link
Copy Markdown
Member Author

Force push to rebase on latest dev.

@vbotbuildovich

vbotbuildovich commented Jul 11, 2026

Copy link
Copy Markdown
Collaborator

CI test results

test results on build#86990
test_status test_class test_method test_arguments test_kind job_url passed reason test_history
FLAKY(PASS) ShadowLinkingRandomOpsTest test_node_operations {"failures": false, "workload_set": "cloud_combos"} integration https://buildkite.com/redpanda/redpanda/builds/86990#019f4f7b-2f97-47a3-b43a-8aaef36ff570 10/11 Test PASSES after retries.No significant increase in flaky rate(baseline=0.0129, p0=1.0000, reject_threshold=0.0100. adj_baseline=0.1000, p1=0.3487, trust_threshold=0.5000) https://redpanda.metabaseapp.com/dashboard/87-tests?tab=142-dt-individual-test-history&test_class=ShadowLinkingRandomOpsTest&test_method=test_node_operations
test results on build#87093
test_status test_class test_method test_arguments test_kind job_url passed reason test_history
FLAKY(PASS) ShadowLinkRoleSyncScaleTest test_role_sync_at_scale {"members_per_role": 1, "num_roles": 5000} integration https://buildkite.com/redpanda/redpanda/builds/87093#019f62c5-3660-4a69-9c85-9c8f84f5c74c 10/11 Test PASSES after retries.No significant increase in flaky rate(baseline=0.0127, p0=1.0000, reject_threshold=0.0100. adj_baseline=0.1000, p1=0.3487, trust_threshold=0.5000) https://redpanda.metabaseapp.com/dashboard/87-tests?tab=142-dt-individual-test-history&test_class=ShadowLinkRoleSyncScaleTest&test_method=test_role_sync_at_scale

@pgellert pgellert added this to the v26.2.1-RC3 milestone Jul 13, 2026
@nguyen-andrew nguyen-andrew force-pushed the sl-sr-prometheus branch 2 times, most recently from fe63a2f to 6dd29c5 Compare July 14, 2026 22:10
Expose the totals_since_task_start counters of the Schema Registry
shadowing task as counters on both the internal and public metrics
endpoints, labelled by shadow_link_name.

The task drives the series off its state machine: they exist exactly
while it surfaces Schema Registry status (any state but stopped), so a
demoted leader stops exporting rather than double-counting into the
aggregated sum (a transfer may briefly export on zero or two nodes),
while pause/resume keeps the series continuous. stop() already resets
the totals, so a fresh leader re-exports from zero.
Assert the probe's counters mirror totals_since_task_start on both the
internal and public registries, labelled with the link name, and pin
the series lifecycle: registered while active, kept (with values)
across pause/resume, removed on stop so a non-leader cannot export
misleading reset zeros.
Scrape the shadow_link_schema_registry_* counters in the existing SR
sync tests: the e2e counter check now asserts both metrics endpoints
agree with the admin API totals, the out-of-scope-reference test covers
a nonzero errors counter, and the leadership-change test verifies the
series follows _schemas/0 leadership (the old leader drops its series
rather than exporting stale values).

Disable the leader balancer for the suite: totals_since_task_start
resets when _schemas/0 leadership moves, so a balancer-initiated move
would strand the exact-value counter assertions. The leadership-change
test moves leadership explicitly.
@nguyen-andrew

Copy link
Copy Markdown
Member Author

Force push to address copilot comments.

Force push to reword commit.

Force push to rebase on latest dev and fix merge conflict in cluster_linking_schema_registry_sync_test.py

@nguyen-andrew nguyen-andrew requested a review from pgellert July 14, 2026 22:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants