Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type MetricsQuery ¶
type MetricsQuery interface { // Build constructs Prometheus expressions to represent this query // over the given group-resource. If namespace is empty, the resource // is considered to be root-scoped. extraGroupBy may be used for cases // where we need to scope down more specifically than just the group-resource // (e.g. container metrics). Build(series string, groupRes schema.GroupResource, namespace string, extraGroupBy []string, resourceNames ...string) (prom.Selector, error) }
MetricsQuery represents a compiled metrics query for some set of series that can be converted into an series of Prometheus expressions to be passed to a client.
func NewMetricsQuery ¶
func NewMetricsQuery(queryTemplate string, resourceConverter ResourceConverter) (MetricsQuery, error)
NewMetricsQuery constructs a new MetricsQuery by compiling the given Go template. The delimiters on the template are `<<` and `>>`, and it may use the following fields: - Series: the series in question - LabelMatchers: a pre-stringified form of the label matchers for the resources in the query - LabelMatchersByName: the raw map-form of the above matchers - GroupBy: the group-by clause to use for the resources in the query (stringified) - GroupBySlice: the raw slice form of the above group-by clause
type ResourceConverter ¶
type ResourceConverter interface { // ResourcesForSeries returns the group-resources associated with the given series, // as well as whether or not the given series has the "namespace" resource). ResourcesForSeries(series prom.Series) (res []schema.GroupResource, namespaced bool) // LabelForResource returns the appropriate label for the given resource. LabelForResource(resource schema.GroupResource) (pmodel.LabelName, error) }
ResourceConverter knows the relationship between Kubernetes group-resources and Prometheus labels, and can convert between the two for any given label or series.
func NewResourceConverter ¶
func NewResourceConverter(resourceTemplate string, overrides map[string]config.GroupResource, mapper apimeta.RESTMapper) (ResourceConverter, error)
NewResourceConverter creates a ResourceConverter based on a generic template plus any overrides. Either overrides or the template may be empty, but not both.