prometheus/web/ui/react-app/src/pages/targets/target.ts

57 lines
1.2 KiB
TypeScript
Raw Normal View History

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;
};
Adds support service discovery page in react ui (#6394) * active targets component completed Signed-off-by: Harkishen-Singh <harkishensingh@hotmail.com> * support for service-discovery in react ui Signed-off-by: Harkishen-Singh <harkishensingh@hotmail.com> * restored prev files Signed-off-by: Harkishen-Singh <harkishensingh@hotmail.com> * used fc Signed-off-by: Harkishen Singh <harkishensingh@hotmail.com> * removed trivial keys Signed-off-by: Harkishen Singh <harkishensingh@hotmail.com> * FC based labels Signed-off-by: Harkishen Singh <harkishensingh@hotmail.com> * implemented suggestions Signed-off-by: Harkishen Singh <harkishensingh@hotmail.com> * implemented suggestions Signed-off-by: Harkishen Singh <harkishensingh@hotmail.com> * implmented suggestions Signed-off-by: Harkishen Singh <harkishensingh@hotmail.com> * minor word change Signed-off-by: Harkishen Singh <harkishensingh@hotmail.com> * before dropped addressed Signed-off-by: Harkishen Singh <harkishensingh@hotmail.com> * implemented suggestions Signed-off-by: Harkishen Singh <harkishensingh@hotmail.com> * linted Signed-off-by: Harkishen Singh <harkishensingh@hotmail.com> * implemented suggestions Signed-off-by: Harkishen Singh <harkishensingh@hotmail.com> * implemented suggestions. removed false styles Signed-off-by: Harkishen Singh <harkishensingh@hotmail.com> * implemented suggestions. Unified buttons with targets screen. Signed-off-by: Harkishen Singh <harkishensingh@hotmail.com> * component for ToggleButton Signed-off-by: Harkishen Singh <harkishensingh@hotmail.com> * removed false Button Signed-off-by: Harkishen Singh <harkishensingh@hotmail.com> * implemented suggestions. Signed-off-by: Harkishen Singh <harkishensingh@hotmail.com> * tests for ToggleMoreLess component Signed-off-by: Harkishen Singh <harkishensingh@hotmail.com> * linted Signed-off-by: Harkishen Singh <harkishensingh@hotmail.com> * fixed nested h3. implemented suggestions Signed-off-by: Harkishen Singh <harkishensingh@hotmail.com> * linted Signed-off-by: Harkishen Singh <harkishensingh@hotmail.com>
2019-12-31 09:41:50 -08:00
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';
}
};