fix(prometheus): use time independent API to list metrics and labels names

Using the "/api/v1/query" endpoint to extract information about metrics
and labels are limited to the metrics available at the time parameter
(that is set to current time), this can lead to labels not showing
because they have no value in the current time even when the dashboard
is displaying historic data.

On the other hand "/api/v1/series" returns results including every
metric and label known to Prometheus, independent of time and value.
This commit is contained in:
Arthur D'Andréa Alemar
2015-10-23 16:08:22 -02:00
parent bad8ab232d
commit 0a6a3f9ab7
2 changed files with 13 additions and 25 deletions

View File

@@ -59,19 +59,16 @@ describe('PrometheusDatasource', function() {
ctx.$rootScope.$apply();
expect(results.length).to.be(3);
});
it('label_values(metric, resource) should generate count metric query', function() {
it('label_values(metric, resource) should generate series query', function() {
response = {
status: "success",
data: {
resultType: "vector",
result: [
{metric: {resource: "value1"}, value: []},
{metric: {resource: "value2"}, value: []},
{metric: {resource: "value3"}, value: []}
]
}
data: [
{__name__: "metric", resource: "value1"},
{__name__: "metric", resource: "value2"},
{__name__: "metric", resource: "value3"}
]
};
ctx.$httpBackend.expect('GET', /proxied\/api\/v1\/query\?query=count\(metric\)%20by%20\(resource\)&time=.*/).respond(response);
ctx.$httpBackend.expect('GET', 'proxied/api/v1/series?match[]=metric').respond(response);
ctx.ds.metricFindQuery('label_values(metric, resource)').then(function(data) { results = data; });
ctx.$httpBackend.flush();
ctx.$rootScope.$apply();
@@ -90,4 +87,3 @@ describe('PrometheusDatasource', function() {
});
});
});