Skip to content

Commit

Permalink
Support matchers that are only the added promxy labels
Browse files Browse the repository at this point in the history
Promxy supports adding labels and filtering by them, if a query included
only matchers on these added labels the matchers would end up being
empty -- but downstream prometheus doesn't support empty matchers. This
simply replaces empty matchers with `{__name__=".+"}` (which effectively
matches all).

Fixes #251
  • Loading branch information
jacksontj committed Dec 2, 2019
1 parent 3d035a8 commit caf5456
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pkg/promclient/labelfilter.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,17 @@ func FilterMatchers(ls model.LabelSet, matchers []*labels.Matcher) ([]*labels.Ma
filteredMatchers = append(filteredMatchers, matcher)
}
}

// Prometheus doesn't support empty matchers (https://github.com/prometheus/prometheus/issues/2162)
// so if we filter out all matchers we want to replace the empty matcher
// with a matcher that does the same
if len(filteredMatchers) == 0 {
filteredMatchers = append(filteredMatchers, &labels.Matcher{
Type: labels.MatchRegexp,
Name: labels.MetricName,
Value: ".+",
})
}

return filteredMatchers, true
}

0 comments on commit caf5456

Please sign in to comment.