mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
* rework the target page Signed-off-by: Augustin Husson <husson.augustin@gmail.com> * put back the URL of the endpoint Signed-off-by: Augustin Husson <husson.augustin@gmail.com> * replace old code by the new one and change function style Signed-off-by: Augustin Husson <husson.augustin@gmail.com> * align filter and search bar on the same row Signed-off-by: Augustin Husson <husson.augustin@gmail.com> * remove unnecessary return Signed-off-by: Augustin Husson <husson.augustin@gmail.com> * upgrade kvsearch to v0.3.0 Signed-off-by: Augustin Husson <husson.augustin@gmail.com> * fix unit test Signed-off-by: Augustin Husson <husson.augustin@gmail.com> * add missing style on column Signed-off-by: Augustin Husson <husson.augustin@gmail.com> * add placeholder and autofocus Signed-off-by: Augustin Husson <husson.augustin@gmail.com> * put back the previous table design Signed-off-by: Augustin Husson <husson.augustin@gmail.com> * fix issue relative to the position of the tooltip Signed-off-by: Augustin Husson <husson.augustin@gmail.com> * fix health filter Signed-off-by: Augustin Husson <husson.augustin@gmail.com> * fix test on label tooltip Signed-off-by: Augustin Husson <husson.augustin@gmail.com> * simplify filter condition Signed-off-by: Augustin Husson <husson.augustin@gmail.com>
57 lines
1.2 KiB
TypeScript
57 lines
1.2 KiB
TypeScript
export interface Labels {
|
|
[key: string]: string;
|
|
}
|
|
|
|
export type Target = {
|
|
discoveredLabels: Labels;
|
|
labels: Labels;
|
|
scrapePool: string;
|
|
scrapeUrl: string;
|
|
globalUrl: string;
|
|
lastError: string;
|
|
lastScrape: string;
|
|
lastScrapeDuration: number;
|
|
health: string;
|
|
scrapeInterval: string;
|
|
scrapeTimeout: string;
|
|
};
|
|
|
|
export interface DroppedTarget {
|
|
discoveredLabels: Labels;
|
|
}
|
|
|
|
export interface ScrapePool {
|
|
upCount: number;
|
|
targets: Target[];
|
|
}
|
|
|
|
export interface ScrapePools {
|
|
[scrapePool: string]: ScrapePool;
|
|
}
|
|
|
|
export const groupTargets = (targets: Target[]): ScrapePools =>
|
|
targets.reduce((pools: ScrapePools, target: Target) => {
|
|
const { health, scrapePool } = target;
|
|
const up = health.toLowerCase() === 'up' ? 1 : 0;
|
|
if (!pools[scrapePool]) {
|
|
pools[scrapePool] = {
|
|
upCount: 0,
|
|
targets: [],
|
|
};
|
|
}
|
|
pools[scrapePool].targets.push(target);
|
|
pools[scrapePool].upCount += up;
|
|
return pools;
|
|
}, {});
|
|
|
|
export const getColor = (health: string): string => {
|
|
switch (health.toLowerCase()) {
|
|
case 'up':
|
|
return 'success';
|
|
case 'down':
|
|
return 'danger';
|
|
default:
|
|
return 'warning';
|
|
}
|
|
};
|