-
Notifications
You must be signed in to change notification settings - Fork 3.9k
feat: drilldown config endpoint #19028
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
Conversation
|
Claude finished @trevorwhitney's task —— View job PR Review Complete ✅I've completed a comprehensive review of PR #19028: feat: drilldown config endpoint 📋 Review SummaryThis PR successfully adds a new ✅ Positive AspectsCode Quality & Architecture
Security & Authorization
Test Coverage
🔍 Detailed Technical AnalysisImplementation Qualitypkg/loki/drilldown_config.go:9 - Simple, focused struct with clear field mappings type DrilldownConfigResponse struct {
Limits map[string]any `json:"limits"`
PatternIngesterEnabled bool `json:"pattern_ingester_enabled"`
Version string `json:"version"`
}pkg/loki/config_handler.go:193-243 - Handler follows Loki conventions:
Limit Resolution LogicThe fallback chain is implemented correctly:
This matches the expected behavior described in the tests and follows Loki's multi-tenancy patterns. Performance Considerations
Pattern Integration
🚦 Minor ObservationsVersion Handling (pkg/loki/config_handler.go:226-229)version := build.GetVersion().Version
if version == "" {
version = "unknown"
}Good defensive programming - handles edge cases where version might be empty. Error MessagesAll error messages are clear and actionable:
🎯 Security Assessment✅ No Security Concerns Identified
📊 Test Coverage AnalysisThe test suite is exemplary with:
🎯 Recommendation✅ APPROVED - This PR is well-implemented and ready for merge. Why This PR Succeeds:
No changes required - this implementation demonstrates good software engineering practices and is ready for production deployment. |
|
@claude are you there? this is a test |
|
Claude finished @trevorwhitney's task —— View job Todo List
Test confirmed - Claude Code is operational and ready to help with your Loki development tasks! |
|
@trevorwhitney I'm not seeing |
|
A few more questions I asked in Slack that might be nice to have greater visibility on: All of the limits we’re returning (i.e.
{
"otlp_config": {
"LogAttributes": null,
"ResourceAttributes": {
"AttributesConfig": [
{
"Action": "index_label",
"Attributes": [
"service.name",
"service.namespace",
"service.instance.id",
"deployment.environment",
"deployment.environment.name",
"cloud.region",
"cloud.availability_zone",
"k8s.cluster.name",
"k8s.namespace.name",
"k8s.pod.name",
"k8s.container.name",
"container.name",
"k8s.replicaset.name",
"k8s.deployment.name",
"k8s.statefulset.name",
"k8s.daemonset.name",
"k8s.cronjob.name",
"k8s.job.name"
],
"Regex": ""
},
{
"Action": "index_label",
"Attributes": [
"service.name",
"service.namespace",
"service.instance.id",
"deployment.environment",
"deployment.environment.name",
"cloud.region",
"cloud.availability_zone",
"k8s.cluster.name",
"k8s.namespace.name",
"k8s.pod.name",
"k8s.container.name",
"container.name",
"k8s.replicaset.name",
"k8s.deployment.name",
"k8s.statefulset.name",
"k8s.daemonset.name",
"k8s.cronjob.name",
"k8s.job.name"
],
"Regex": ""
}
],
"IgnoreDefaults": false
},
"ScopeAttributes": null,
"SeverityTextAsLabel": false
}
} |
A: there are, but you'd need to make a case for them, because the argument to not expose them is that an operator may not want a user to discover certain limits on their queries, as they may request the operator to bump them
A: no, we can never assume anything about a customer's labeling strategy. discover log level was implemented to give us a consistent place we could assume level will be (detected_level).
A: yes, the latter is a Loki config, and the whole reason we needed an endpoint beyond the tenant limits endpoint
A: that's a good question, I'm not sure, I'd have to poke around a bit to see if this happens everywhere or is an artifact of your config. |
|
@trevorwhitney can we add |
|
And |
|
@gtk-grafana I added the extra properties to the default allow list. I also confirmed the duplicate otlp config you noticed. It looks like we're registering the defaults twice, here and here. I'm investigating why. |
23ee772 to
c0d7feb
Compare
|
💻 Deploy preview deleted. |
|
chatted with @salvacorts about this one today. we're going to move the endpoint to something more drilldown specific to make it more clear what it's for (ie |
| if t.TenantLimits == nil { | ||
| http.Error(w, "Tenant configs not enabled", http.StatusNotFound) | ||
| return | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this logic was moved, because previously defaults weren't working unless there was a runtime config file configured.
| return | ||
| } | ||
| } else { | ||
| writeYAMLResponse(w, filteredLimits) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
super nit so feel free to disregard: it would be more idomatic to return early and avoid this if-else
if !forDrilldown {
writeYAMLResponse(w, filteredLimits)
return
}
// Hereafter, we know the response should be for drilldown so we build the custom response
version := build.GetVersion().Version
if version == "" {
version = "unknown"
}
...There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, I agree, I'll make that change!
What this PR does / why we need it:
This PR adds a new endpoint at
/loki/api/v1/configthat exposes a mix of tenant limits and config that is useful to Drilldown to make decisions to improve the user experience.This extends the work done in #18521, which was originally done for this purpose (of supporting Drilldown), but in practice has two major drawbacks.
First, the tenant limits endpoint is at
/config/tenant/v1/limitswhich is a path outside of what the current Loki datasource can access, so in order for Drilldown to use there needs to be changes to core Grafana.Second, that endpoint only returns limits, and there is also some config Drilldown needs to know about (such as if the pattern ingesters are enabled). It could be possible to move this to a per-tenant config, but this PR is a bit more future proof in case there are configs added in the future that are relevant to Drilldown.
Special notes for your reviewer:
Checklist
CONTRIBUTING.mdguide (required)featPRs are unlikely to be accepted unless a case can be made for the feature actually being a bug fix to existing behavior.docs/sources/setup/upgrade/_index.mddeprecated-config.yamlanddeleted-config.yamlfiles respectively in thetools/deprecated-config-checkerdirectory. Example PR