More implementation work in conversion.

Notable next steps include:
* Intelligently select the aggregation method (rate/avg_over_time/etc).
* Intelligenty select the aggregation window.
* Figure out how to handle "namespace", if at all.
* Fix the crazy type conversion in `sample_converter.go`.
This commit is contained in:
Tony Compton 2018-06-29 11:45:37 -04:00
parent d90012439c
commit fe0859aa5c
6 changed files with 99 additions and 30 deletions

View file

@ -66,7 +66,14 @@ func NewExternalPrometheusProvider(mapper apimeta.RESTMapper, kubeClient dynamic
}
func (p *externalPrometheusProvider) GetExternalMetric(namespace string, metricName string, metricSelector labels.Selector) (*external_metrics.ExternalMetricValueList, error) {
query := p.queryBuilder.BuildPrometheusQuery(namespace, metricName, metricSelector)
//TODO: Get the appropriate time window and aggregation type from somewhere
//based on the metric being selected. Does SeriesRegistry have the metric type cached?
queryMetadata := conv.QueryMetadata{
MetricName: metricName,
WindowInSeconds: 120,
Aggregation: "rate",
}
query := p.queryBuilder.BuildPrometheusQuery(namespace, metricName, metricSelector, queryMetadata)
selector := prom.Selector(query)
//TODO: I don't yet know what a context is, but apparently I should use a real one.
@ -78,10 +85,6 @@ func (p *externalPrometheusProvider) GetExternalMetric(namespace string, metricN
return nil, err
}
queryMetadata := conv.QueryMetadata{
MetricName: metricName,
WindowInSeconds: 0,
}
return p.metricConverter.Convert(queryMetadata, queryResults)
}