Skip to content

feat: Add endpoint returning tenant configured limits #17101

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

salvacorts
Copy link
Contributor

@salvacorts salvacorts commented Apr 10, 2025

What this PR does / why we need it:

This PR adds a new API endpoint GET /config/tenant/{tenant}/limits that returns the configured limits (merged with the defaults) of a tenant.

Note, this may be useful to implement the tenants limits page in the new operator UI

{
path: "/tenants/limits",
breadcrumb: "Limits",
element: <ComingSoon />,
},

@salvacorts salvacorts marked this pull request as ready for review April 10, 2025 10:52
@salvacorts salvacorts requested a review from a team as a code owner April 10, 2025 10:52
pkg/loki/loki.go Outdated
@@ -505,6 +503,7 @@ func (t *Loki) bindConfigEndpoint(opts RunOpts) {
configEndpointHandlerFn = opts.CustomConfigEndpointHandlerFn
}
t.Server.HTTP.Path("/config").Methods("GET").HandlerFunc(configEndpointHandlerFn)
t.Server.HTTP.Path("/config/tenant/{tenant}/limits").Methods("GET").HandlerFunc(t.tenantLimitsHandler())
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure if we have a root prefix for paths like this? given that this is now going to be something relied upon by other services I think the path should have a version in it, if that's not already provided by an additional prefix somewhere else

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We don't add any prefix to that route. My concern with adding it under /loki/api/v1 is that I think we risk to somehow accidentally exposte the endpoint and make it public. I see this more like an operator endpoint similar to the /config or /ring ones.

I agree adding versioning here makes sense, what about /config/tenant/v1/{tenant}/limits?

pkg/loki/loki.go Outdated
@@ -505,6 +503,7 @@ func (t *Loki) bindConfigEndpoint(opts RunOpts) {
configEndpointHandlerFn = opts.CustomConfigEndpointHandlerFn
}
t.Server.HTTP.Path("/config").Methods("GET").HandlerFunc(configEndpointHandlerFn)
t.Server.HTTP.Path("/config/tenant/{tenant}/limits").Methods("GET").HandlerFunc(t.tenantLimitsHandler())
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm also wary about how this changes our multi-tenant paradigm, might it be better to not have a tenant path param and instead use headers the way we do multi-tenant in the rest of our API's?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, good idea 👍 I will get the tenant from the header

Copy link
Collaborator

@slim-bean slim-bean left a comment

Choose a reason for hiding this comment

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

I have a few questions with this approach, I think we should have a discussion before merging this

@salvacorts
Copy link
Contributor Author

Pushed your suggestions Ed, this is how the endpoint looks like now

$ http 127.0.0.1:3100/config/tenant/v1/limits X-Scope-OrgID:12345
HTTP/1.1 200 OK
Content-Type: text/plain; charset=utf-8
Date: Thu, 10 Apr 2025 12:55:44 GMT
Transfer-Encoding: chunked

ingestion_rate_strategy: global
ingestion_rate_mb: 8
ingestion_burst_size_mb: 9

@salvacorts salvacorts requested a review from slim-bean April 10, 2025 14:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants