Chore: Don't show hint for recorded queries (#78422)
Don't show hint on recorded queries
This commit is contained in:
@@ -171,4 +171,22 @@ describe('getQueryHints()', () => {
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it('should not return rate hint for a recorded query', () => {
|
||||
const seriesCount = SUM_HINT_THRESHOLD_COUNT;
|
||||
const series = Array.from({ length: seriesCount }, (_) => ({
|
||||
datapoints: [
|
||||
[0, 0],
|
||||
[0, 0],
|
||||
],
|
||||
}));
|
||||
let hints = getQueryHints('node_namespace_pod_container:container_cpu_usage_seconds_total:sum_irate', series);
|
||||
expect(hints!.length).toBe(0);
|
||||
|
||||
hints = getQueryHints('node_namespace_pod_container:container_cpu_usage_seconds_total', series);
|
||||
expect(hints!.length).toBe(0);
|
||||
|
||||
hints = getQueryHints('container_cpu_usage_seconds_total:irate_total', series);
|
||||
expect(hints!.length).toBe(0);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -32,7 +32,7 @@ export function getQueryHints(query: string, series?: any[], datasource?: Promet
|
||||
// Check for need of rate()
|
||||
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/);
|
||||
const nameMatch = query.match(/\b((?<!:)\w+_(total|sum|count)(?!:))\b/);
|
||||
let counterNameMetric = nameMatch ? nameMatch[1] : '';
|
||||
const metricsMetadata = datasource?.languageProvider?.metricsMetadata;
|
||||
let certain = false;
|
||||
|
||||
Reference in New Issue
Block a user