import React, { FC } from 'react'; import { ScrapePool, getColor } from './target'; import { Collapse, Table, Badge } from 'reactstrap'; import styles from './ScrapePoolPanel.module.css'; import { Target } from './target'; import EndpointLink from './EndpointLink'; import TargetLabels from './TargetLabels'; import TargetScrapeDuration from './TargetScrapeDuration'; import { now } from 'moment'; import { ToggleMoreLess } from '../../components/ToggleMoreLess'; import { formatRelative } from '../../utils'; interface PanelProps { scrapePool: string; targetGroup: ScrapePool; expanded: boolean; toggleExpanded: () => void; } export const columns = ['Endpoint', 'State', 'Labels', 'Last Scrape', 'Scrape Duration', 'Error']; const ScrapePoolPanel: FC = ({ scrapePool, targetGroup, expanded, toggleExpanded }) => { const modifier = targetGroup.upCount < targetGroup.targets.length ? 'danger' : 'normal'; const id = `pool-${scrapePool}`; const anchorProps = { href: `#${id}`, id, }; return (
{`${scrapePool} (${targetGroup.upCount}/${targetGroup.targets.length} up)`} {columns.map((column) => ( ))} {targetGroup.targets.map((target: Target, idx: number) => { const { discoveredLabels, labels, scrapePool, scrapeUrl, globalUrl, lastError, lastScrape, lastScrapeDuration, health, scrapeInterval, scrapeTimeout, } = target; const color = getColor(health); return ( ); })}
{column}
{health.toUpperCase()} {formatRelative(lastScrape, now())} {lastError ? {lastError} : null}
); }; export default ScrapePoolPanel;