Skip to content

Conversation

sujalshah-bit
Copy link
Contributor

@sujalshah-bit sujalshah-bit commented Jun 5, 2025

This cover the first part of creating endpoint which list out blocks detail.

Response

{
  "status": "success",
  "data": {
    "blocks": [
      {
        "ulid": "01JXAHF3P6PBEZR3VNQXJ5ZKK9",
        "minTime": 1749142291684,
        "maxTime": 1749146400000,
        "stats": {
          "numSamples": 8678,
          "numSeries": 644,
          "numChunks": 644
        },
        "compaction": {
          "level": 1,
          "sources": [
            "01JXAHF3P6PBEZR3VNQXJ5ZKK9"
          ]
        },
        "version": 1
      }
    ]
  }
}

Fixes #16647.

@sujalshah-bit sujalshah-bit force-pushed the block_endpoint branch 2 times, most recently from 031fe16 to 785cb5f Compare June 9, 2025 17:52
@sujalshah-bit sujalshah-bit changed the title WIP fixes #16647. api: Create /status/tsdb/blocks endpoint. Jun 9, 2025
@sujalshah-bit sujalshah-bit marked this pull request as ready for review June 9, 2025 17:53
@sujalshah-bit
Copy link
Contributor Author

I wanted to write unit test case for serveTSDBBlock function but I don't know how to replicate api.dbDir in test env ?

@sujalshah-bit
Copy link
Contributor Author

@SuperQ can you give it a review?

@sujalshah-bit
Copy link
Contributor Author

I don't know too much about the current TSDB code though, does that make sense?

I also never worked in this field But I tried, it worked. Based on your feedback, I refactored the serveTSDBBlocks API endpoint to avoid manually reading block metadata from disk (ReadMetaFile) and instead rely on the TSDB instance to return already-loaded block metadata safely.

@juliusv can you give it review :)

Copy link
Member

@juliusv juliusv left a comment

Choose a reason for hiding this comment

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

Thanks! While I'm not a TSDB expert, the TSDB-related changes looks pretty simple and good to me, so I think I would feel comfortable merging them unless @codesome or @jesusvazquez have any objections in the next days.

Other than that, just a few comments.

Also, could you please add documentation for the new endpoint at:

https://github.com/prometheus/prometheus/blob/main/docs/querying/api.md

(...which is the source for https://prometheus.io/docs/prometheus/latest/querying/api/#http-api)

Copy link
Member

@codesome codesome left a comment

Choose a reason for hiding this comment

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

LGTM on the TSDB changes with a small suggestion

@sujalshah-bit sujalshah-bit force-pushed the block_endpoint branch 3 times, most recently from 282360f to 995e352 Compare July 3, 2025 17:12
this endpoint serves blocks data to the client.

Signed-off-by: sujal shah <sujalshah28092004@gmail.com>
@sujalshah-bit
Copy link
Contributor Author

@juliusv made the relevant doc change and posted a question above in a thread.

I am not able to access docs at http://localhost:9090/docs/prometheus/latest/querying/api/
Are the docs not built locally?

@sujalshah-bit sujalshah-bit requested a review from juliusv July 7, 2025 17:31
@sujalshah-bit
Copy link
Contributor Author

@juliusv, gentle reminder for this PR. Is this ready to merge?

Copy link
Member

@juliusv juliusv left a comment

Choose a reason for hiding this comment

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

Thanks! Merging :)

@juliusv juliusv merged commit 2e709c6 into prometheus:main Jul 31, 2025
27 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.

API: Add blocks endpoint
3 participants