Commit 377bc440 by David Kaltschmidt

Explore: dont rate-hint on rate queries

parent 4a8d80a9
...@@ -46,7 +46,7 @@ export function determineQueryHints(series: any[], datasource?: any): any[] { ...@@ -46,7 +46,7 @@ export function determineQueryHints(series: any[], datasource?: any): any[] {
// Check for monotony // Check for monotony
const datapoints: number[][] = s.datapoints; const datapoints: number[][] = s.datapoints;
if (datapoints.length > 1) { if (query.indexOf('rate(') === -1 && datapoints.length > 1) {
let increasing = false; let increasing = false;
const monotonic = datapoints.filter(dp => dp[0] !== null).every((dp, index) => { const monotonic = datapoints.filter(dp => dp[0] !== null).every((dp, index) => {
if (index === 0) { if (index === 0) {
......
...@@ -247,6 +247,12 @@ describe('PrometheusDatasource', () => { ...@@ -247,6 +247,12 @@ describe('PrometheusDatasource', () => {
}); });
}); });
it('returns no rate hint for a monotonously increasing series that already has a rate', () => {
const series = [{ datapoints: [[23, 1000], [24, 1001]], query: 'rate(metric[1m])', responseIndex: 0 }];
const hints = determineQueryHints(series);
expect(hints).toEqual([null]);
});
it('returns a rate hint w/o action for a complex monotonously increasing series', () => { it('returns a rate hint w/o action for a complex monotonously increasing series', () => {
const series = [{ datapoints: [[23, 1000], [24, 1001]], query: 'sum(metric)', responseIndex: 0 }]; const series = [{ datapoints: [[23, 1000], [24, 1001]], query: 'sum(metric)', responseIndex: 0 }];
const hints = determineQueryHints(series); const hints = determineQueryHints(series);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment