Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultOpts = Opts{ReplaceExistingLabel: true}
Functions ¶
This section is empty.
Types ¶
type Opts ¶
type Opts struct {
ReplaceExistingLabel bool
}
Opts contains optional configurations for the QueryRestrictor
type QueryRestrictor ¶
type QueryRestrictor struct { Opts // contains filtered or unexported fields }
QueryRestrictor provides functionality to add restrictor labels to a Prometheus query
func NewQueryRestrictor ¶
func NewQueryRestrictor(opts Opts) *QueryRestrictor
NewQueryRestrictor returns a new QueryRestrictor to be built upon
func (*QueryRestrictor) AddMatcher ¶
func (q *QueryRestrictor) AddMatcher(key string, values ...string) *QueryRestrictor
AddMatcher takes a key and an arbitrary number of values. If only one value is provided, an Equal matcher will be added to the restrictor. Otherwise a Regex matcher with an OR of the values will be added. e.g. {label=~"value1|value2"} If values is empty the label will be matched to the empty string e.g. {label=""} effectively, this matches which do not contain this label
func (*QueryRestrictor) Matchers ¶
func (q *QueryRestrictor) Matchers() []labels.Matcher
Matchers returns the list of label matchers for the restrictor
func (*QueryRestrictor) RestrictQuery ¶
func (q *QueryRestrictor) RestrictQuery(query string) (string, error)
RestrictQuery appends a label selector to each metric in a given query so that only metrics with those labels are returned from the query.