Cleaning up.

* Wiped out a ton of warnings about comments.
* Created consts for `MetricType` values.
* `externalInfoMap` can now track multiple series with the same name/namespace and different labels.
* `namespace` parameter of external metrics queries is now respected (albeit very rudimentarily)
* Metric converter values for external metrics are now converted the same way as for custom metrics (probably still some opportunity for consolidation).
* Lots of TODOs actually done.
* Deleted a lot of commented out code.
This commit is contained in:
Tony Compton 2018-07-20 15:35:24 -04:00
parent 9641e70005
commit a94494337e
18 changed files with 155 additions and 188 deletions

View file

@ -17,6 +17,9 @@ import (
pmodel "github.com/prometheus/common/model"
)
//ResourceConverter is a type for extracting associated Kubernetes GroupResource objects from
//Prometheus series and generating appropriate labels to target specific Kubernetes GroupResource
//objects.
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).
@ -34,6 +37,7 @@ type resourceConverter struct {
labelTemplate *template.Template
}
//NewResourceConverter creates a ResourceConverter that will use the provided parameters to map data between Prometheus and Kubernetes.
func NewResourceConverter(resourceTemplate string, overrides map[string]config.GroupResource, mapper apimeta.RESTMapper) (ResourceConverter, error) {
converter := &resourceConverter{
labelToResource: make(map[pmodel.LabelName]schema.GroupResource),