Skip to content

Added 'limit' query parameter support to /api/v1/status/tsdb endpoint#12336

Merged
juliusv merged 6 commits intoprometheus:mainfrom
codebasky:topN-tsdb-status-11945
May 22, 2023
Merged

Added 'limit' query parameter support to /api/v1/status/tsdb endpoint#12336
juliusv merged 6 commits intoprometheus:mainfrom
codebasky:topN-tsdb-status-11945

Conversation

@codebasky
Copy link
Contributor

@codebasky codebasky commented May 5, 2023

This change adds the ability to limit the number of items returned for each TSDB stat by adding a new limit query parameter to the /api/v1/status/tsdb endpoint. By default, 10 items are returned.

The implementation uses a max-heap to keep track of the top N values for each stat (existing logic).
This feature was implemented as part of addressing issue #11945.

Testing:

  1. Added UT
  2. Verified the functionality locally using 'curl http://localhost:9090/api/v1/status/tsdb?limit=2'
  3. Verified tsdb-status in prometheus dashboard

Signed-off-by: Baskar Shanmugam <baskar.shanmugam.career@gmail.com>
@codebasky codebasky requested a review from codesome as a code owner May 5, 2023 19:06
@codebasky
Copy link
Contributor Author

@bboreham @roidelapluie

@codebasky
Copy link
Contributor Author

@juliusv Please take a look at web package changes.

@DanielCastronovo
Copy link

Happy to see this PR :)

@juliusv
Copy link
Member

juliusv commented May 17, 2023

CC @codesome for the TSDB changes, since the original TSDB stats features were introduced by him.

@codebasky
Copy link
Contributor Author

cc @jesusvazquez

@codebasky codebasky requested a review from jesusvazquez as a code owner May 19, 2023 00:53
Signed-off-by: Baskar Shanmugam <baskar.shanmugam.career@gmail.com>
Copy link
Member

@jesusvazquez jesusvazquez left a comment

Choose a reason for hiding this comment

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

Seems almost ready. Left a minor change and also if you could please update PR description and title replacing topN with limit.

Then I think we're good to go 👍

Signed-off-by: Baskar Shanmugam <baskar.shanmugam.career@gmail.com>
@codebasky codebasky changed the title Added 'topN' query parameter support to /api/v1/status/tsdb endpoint Added 'limit' query parameter support to /api/v1/status/tsdb endpoint May 22, 2023
Copy link
Member

@jesusvazquez jesusvazquez left a comment

Choose a reason for hiding this comment

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

LGTM, will wait for CI and then merge

Thank you!

codebasky added 2 commits May 22, 2023 16:49
Signed-off-by: Baskar Shanmugam <baskar.shanmugam.career@gmail.com>
@juliusv
Copy link
Member

juliusv commented May 22, 2023

👍 CI passing :)

@@ -978,7 +978,7 @@ func (h *Head) DisableNativeHistograms() {
}

// PostingsCardinalityStats returns top 10 highest cardinality stats By label and value names.
Copy link
Member

Choose a reason for hiding this comment

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

The comment needed an update here :)

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.

6 participants