diff --git a/src/query/graphite/storage/converter.go b/src/query/graphite/storage/converter.go index 45e91ec04b..df560ee47c 100644 --- a/src/query/graphite/storage/converter.go +++ b/src/query/graphite/storage/converter.go @@ -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), diff --git a/src/query/graphite/storage/converter_test.go b/src/query/graphite/storage/converter_test.go index 80955134b6..88460d5fde 100644 --- a/src/query/graphite/storage/converter_test.go +++ b/src/query/graphite/storage/converter_test.go @@ -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)