Skip to content
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

[query] Graphite match regexp all values for __g0__ tag matcher instead of match field #3021

Merged
merged 4 commits into from
Dec 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/query/graphite/storage/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,19 @@ func convertMetricPartToMatcher(
) (models.Matcher, error) {
var matchType models.MatchType
if metric == wildcard {
if count == 0 {
// Match field does not actually match all values
// for the first metric selector in practice.
// Need to special case this and just use a regexp match all
// on this first value.
// This is ok since there usually a very small amount of distinct
// values in the first dot separator.
return models.Matcher{
Type: models.MatchRegexp,
Name: graphite.TagName(count),
Value: []byte(".*"),
}, nil
}
return models.Matcher{
Type: models.MatchField,
Name: graphite.TagName(count),
Expand Down
7 changes: 7 additions & 0 deletions src/query/graphite/storage/converter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ func TestConvertWildcardToMatcher(t *testing.T) {
Type: models.MatchField,
Name: graphite.TagName(i),
}
if i == 0 {
expected = models.Matcher{
Type: models.MatchRegexp,
Name: graphite.TagName(0),
Value: []byte(".*"),
}
}

actual, err := convertMetricPartToMatcher(i, metric)
require.NoError(t, err)
Expand Down