-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Do not parse string of empty matchers #5980
Conversation
This fixes a bug in the index gateway when querying values for a label. Since the gRPC handler for LabelValuesForMetricName in the index gateway allows empty matchers in the LabelValuesForMetricNameRequest, we need to check if the matchers string is an empty matcher (`{}`) before we parse the string. This bug was introduced with the index gateway api refactoring in #5892 Fixes: #5965 Signed-off-by: Christian Haudum <christian.haudum@gmail.com>
matchers, err = syntax.ParseMatchers(req.Matchers) | ||
if err != nil { | ||
return nil, err | ||
} | ||
} | ||
names, err := g.indexQuerier.LabelValuesForMetricName(ctx, instanceID, req.From, req.Through, req.MetricName, req.LabelName, matchers...) |
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.
Hope it's ok to pass empty []*labels.Matcher
to g.indexQuerier.LabelValuesForMetricName
when req.Matchers == syntax.EmptyMatchers
Also can you add a test?
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.
The index store checks for len(matchers)
:
loki/pkg/storage/stores/series/series_index_store.go
Lines 239 to 241 in ea59e4b
if len(matchers) != 0 { | |
return c.labelValuesForMetricNameWithMatchers(ctx, userID, from, through, metricName, labelName, matchers...) | |
} |
This fixes a bug in the index gateway when querying values for a label. Since the gRPC handler for LabelValuesForMetricName in the index gateway allows empty matchers in the LabelValuesForMetricNameRequest, we need to check if the matchers string is an empty matcher (`{}`) before we parse the string. This bug was introduced with the index gateway api refactoring in #5892 Fixes: #5965 Signed-off-by: Christian Haudum <christian.haudum@gmail.com>
This fixes a bug in the index gateway when querying values for a label. Since the gRPC handler for LabelValuesForMetricName in the index gateway allows empty matchers in the LabelValuesForMetricNameRequest, we need to check if the matchers string is an empty matcher (`{}`) before we parse the string. This bug was introduced with the index gateway api refactoring in #5892 Fixes: #5965 Signed-off-by: Christian Haudum <christian.haudum@gmail.com>
What this PR does / why we need it:
This fixes a bug in the index gateway when querying values for a label.
Since the gRPC handler for LabelValuesForMetricName in the index gateway
allows empty matchers in the LabelValuesForMetricNameRequest, we need to
check if the matchers string is an empty matcher (
{}
) before we parsethe string.
This bug was introduced with the index gateway api refactoring in #5892
Signed-off-by: Christian Haudum christian.haudum@gmail.com
Which issue(s) this PR fixes:
Fixes: #5965
Special notes for your reviewer:
Checklist
CHANGELOG.md
.docs/sources/upgrading/_index.md