Commit 8b632ac0 by Huan Wang Committed by GitHub

Prometheus: Do not show rate hint when increase function is applied (#21955)

parent 89d1ab37
......@@ -75,6 +75,19 @@ describe('getQueryHints()', () => {
expect(hints).toEqual(null);
});
it('returns no rate hint for a counter metric that already has an increase', () => {
const series = [
{
datapoints: [
[23, 1000],
[24, 1001],
],
},
];
const hints = getQueryHints('increase(metric_total[1m])', series);
expect(hints).toEqual(null);
});
it('returns a rate hint w/o action for a complex counter metric', () => {
const series = [
{
......
......@@ -28,7 +28,7 @@ export function getQueryHints(query: string, series?: any[], datasource?: Promet
}
// Check for need of rate()
if (query.indexOf('rate(') === -1) {
if (query.indexOf('rate(') === -1 && query.indexOf('increase(') === -1) {
// Use metric metadata for exact types
const nameMatch = query.match(/\b(\w+_(total|sum|count))\b/);
let counterNameMetric = nameMatch ? nameMatch[1] : '';
......
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