mirror of
https://github.com/grafana/grafana.git
synced 2025-02-16 18:34:52 -06:00
Prometheus: Do not show rate hint when increase function is applied (#21955)
This commit is contained in:
parent
89d1ab37de
commit
8b632ac029
@ -75,6 +75,19 @@ describe('getQueryHints()', () => {
|
|||||||
expect(hints).toEqual(null);
|
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', () => {
|
it('returns a rate hint w/o action for a complex counter metric', () => {
|
||||||
const series = [
|
const series = [
|
||||||
{
|
{
|
||||||
|
@ -28,7 +28,7 @@ export function getQueryHints(query: string, series?: any[], datasource?: Promet
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check for need of rate()
|
// 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
|
// Use metric metadata for exact types
|
||||||
const nameMatch = query.match(/\b(\w+_(total|sum|count))\b/);
|
const nameMatch = query.match(/\b(\w+_(total|sum|count))\b/);
|
||||||
let counterNameMetric = nameMatch ? nameMatch[1] : '';
|
let counterNameMetric = nameMatch ? nameMatch[1] : '';
|
||||||
|
Loading…
Reference in New Issue
Block a user