import React, { FC } from 'react'; import { RouteComponentProps } from '@reach/router'; import { Table } from 'reactstrap'; import { useFetch } from '../../hooks/useFetch'; import { withStatusIndicator } from '../../components/withStatusIndicator'; import { usePathPrefix } from '../../contexts/PathPrefixContext'; import { API_PATH } from '../../constants/constants'; interface Stats { name: string; value: number; } interface HeadStats { numSeries: number; numLabelPairs: number; chunkCount: number; minTime: number; maxTime: number; } export interface TSDBMap { headStats: HeadStats; seriesCountByMetricName: Stats[]; labelValueCountByLabelName: Stats[]; memoryInBytesByLabelName: Stats[]; seriesCountByLabelValuePair: Stats[]; } export const TSDBStatusContent: FC = ({ headStats, labelValueCountByLabelName, seriesCountByMetricName, memoryInBytesByLabelName, seriesCountByLabelValuePair, }) => { const unixToTime = (unix: number): string => new Date(unix).toISOString(); const { chunkCount, numSeries, numLabelPairs, minTime, maxTime } = headStats; const stats = [ { header: 'Number of Series', value: numSeries }, { header: 'Number of Chunks', value: chunkCount }, { header: 'Number of Label Pairs', value: numLabelPairs }, { header: 'Current Min Time', value: `${unixToTime(minTime)} (${minTime})` }, { header: 'Current Max Time', value: `${unixToTime(maxTime)} (${maxTime})` }, ]; return (

TSDB Status

Head Stats

{stats.map(({ header }) => { return ; })} {stats.map(({ header, value }) => { return ; })}
{header}
{value}

Head Cardinality Stats

{[ { title: 'Top 10 label names with value count', stats: labelValueCountByLabelName }, { title: 'Top 10 series count by metric names', stats: seriesCountByMetricName }, { title: 'Top 10 label names with high memory usage', unit: 'Bytes', stats: memoryInBytesByLabelName }, { title: 'Top 10 series count by label value pairs', stats: seriesCountByLabelValuePair }, ].map(({ title, unit = 'Count', stats }) => { return (

{title}

{stats.map(({ name, value }) => { return ( ); })}
Name {unit}
{name} {value}
); })}
); }; TSDBStatusContent.displayName = 'TSDBStatusContent'; const TSDBStatusContentWithStatusIndicator = withStatusIndicator(TSDBStatusContent); const TSDBStatus: FC = () => { const pathPrefix = usePathPrefix(); const { response, error, isLoading } = useFetch(`${pathPrefix}/${API_PATH}/status/tsdb`); return ( ); }; export default TSDBStatus;