Skip to content

Track snapshot stats as metrics #130301

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

nicktindall
Copy link
Contributor

@nicktindall nicktindall commented Jun 30, 2025

Adds additional snapshot metrics and publishes them via APM

Still a WIP, need to add some tests, need to add new metrics to node stats

@elasticsearchmachine elasticsearchmachine added the serverless-linked Added by automation, don't add manually label Jun 30, 2025
@nicktindall nicktindall added >non-issue :Distributed Coordination/Snapshot/Restore Anything directly related to the `_snapshot/*` APIs labels Jun 30, 2025
@@ -152,6 +156,7 @@ public RepositoriesService(
threadPool.relativeTimeInMillisSupplier()
);
this.preRestoreChecks = preRestoreChecks;
this.snapshotMetrics = new SnapshotMetrics(meterRegistry, this::getSnapshotsInProgress);
Copy link
Contributor Author

@nicktindall nicktindall Jun 30, 2025

Choose a reason for hiding this comment

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

We only create SnapshotMetrics here so we can provide it with the supplier for the "snapshots in progress" gauge. This means we need to pass it to the Repository.Factory#create call rather than the RepositoryPlugin#getRepositories.

ActionListener.running(
() -> blobStoreSnapshotMetrics.shardSnapshotCompleted(threadPool.absoluteTimeInMillis() - startTimeInMillis)
)
);
Copy link
Contributor Author

@nicktindall nicktindall Jun 30, 2025

Choose a reason for hiding this comment

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

We track start and finish shard here, which means we don't include the time in the queue, we could move this to include time in the queue as well?

I think we'd want this time to reflect the amount of time shards are unable to be moved, I will dig in to see whether queued time or snapshotting time is a better reflection of that?

snapshotMetrics.snapshotsShardsCompletedCounter().increment();
if (durationInMillis > 0) {
snapshotMetrics.snapshotShardsDurationHistogram().record(durationInMillis / 1_000f);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

totalTime will be zero in some failure cases I think

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Distributed Coordination/Snapshot/Restore Anything directly related to the `_snapshot/*` APIs >non-issue serverless-linked Added by automation, don't add manually v9.2.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants