Prometheus: Add metadata to metrics in Metrics browser (#34708)

* Prometheus: Add metadata to metrics in Metrics browser

- use the available metadata to enhance the tooltip on metric items in the metrics browser
- added meta info for histogram metrics (was missing before)
- also added one for ALERTS

* fix test
This commit is contained in:
David
2021-05-28 14:51:06 +02:00
committed by GitHub
parent 886f6fc55b
commit 2205464a8d
4 changed files with 79 additions and 8 deletions

View File

@@ -176,6 +176,26 @@ export function fixSummariesMetadata(metadata: PromMetricsMetadata): PromMetrics
const summaryMetadata: PromMetricsMetadata = {};
for (const metric in metadata) {
const item = metadata[metric][0];
if (item.type === 'histogram') {
summaryMetadata[`${metric}_bucket`] = [
{
type: 'counter',
help: `Cumulative counters for the observation buckets (${item.help})`,
},
];
summaryMetadata[`${metric}_count`] = [
{
type: 'counter',
help: `Count of events that have been observed for the histogram metric (${item.help})`,
},
];
summaryMetadata[`${metric}_sum`] = [
{
type: 'counter',
help: `Total sum of all observed values for the histogram metric (${item.help})`,
},
];
}
if (item.type === 'summary') {
summaryMetadata[`${metric}_count`] = [
{
@@ -191,7 +211,17 @@ export function fixSummariesMetadata(metadata: PromMetricsMetadata): PromMetrics
];
}
}
return { ...metadata, ...summaryMetadata };
// Synthetic series
const syntheticMetadata: PromMetricsMetadata = {};
syntheticMetadata['ALERTS'] = [
{
type: 'counter',
help:
'Time series showing pending and firing alerts. The sample value is set to 1 as long as the alert is in the indicated active (pending or firing) state.',
},
];
return { ...metadata, ...summaryMetadata, ...syntheticMetadata };
}
export function roundMsToMin(milliseconds: number): number {