prometheus/web/ui/mantine-ui/src/pages/TSDBStatusPage.tsx
Julius Volz 0180cf31aa
Some checks failed
CI / Go tests (push) Has been cancelled
CI / More Go tests (push) Has been cancelled
CI / Go tests with previous Go version (push) Has been cancelled
CI / UI tests (push) Has been cancelled
CI / Go tests on Windows (push) Has been cancelled
CI / Mixins tests (push) Has been cancelled
CI / Build Prometheus for common architectures (0) (push) Has been cancelled
CI / Build Prometheus for common architectures (1) (push) Has been cancelled
CI / Build Prometheus for common architectures (2) (push) Has been cancelled
CI / Build Prometheus for all architectures (0) (push) Has been cancelled
CI / Build Prometheus for all architectures (1) (push) Has been cancelled
CI / Build Prometheus for all architectures (10) (push) Has been cancelled
CI / Build Prometheus for all architectures (11) (push) Has been cancelled
CI / Build Prometheus for all architectures (2) (push) Has been cancelled
CI / Build Prometheus for all architectures (3) (push) Has been cancelled
CI / Build Prometheus for all architectures (4) (push) Has been cancelled
CI / Build Prometheus for all architectures (5) (push) Has been cancelled
CI / Build Prometheus for all architectures (6) (push) Has been cancelled
CI / Build Prometheus for all architectures (7) (push) Has been cancelled
CI / Build Prometheus for all architectures (8) (push) Has been cancelled
CI / Build Prometheus for all architectures (9) (push) Has been cancelled
CI / Check generated parser (push) Has been cancelled
CI / golangci-lint (push) Has been cancelled
CI / fuzzing (push) Has been cancelled
CI / codeql (push) Has been cancelled
CI / Report status of build Prometheus for all architectures (push) Has been cancelled
CI / Publish main branch artifacts (push) Has been cancelled
CI / Publish release artefacts (push) Has been cancelled
CI / Publish UI on npm Registry (push) Has been cancelled
Factor out common icon and card styles
Signed-off-by: Julius Volz <julius.volz@gmail.com>
2024-09-13 14:44:04 +02:00

103 lines
3.1 KiB
TypeScript

import { Table } from "@mantine/core";
import { useSuspenseAPIQuery } from "../api/api";
import { TSDBStatusResult } from "../api/responseTypes/tsdbStatus";
import { formatTimestamp } from "../lib/formatTime";
import { useSettings } from "../state/settingsSlice";
import InfoPageStack from "../components/InfoPageStack";
import InfoPageCard from "../components/InfoPageCard";
export default function TSDBStatusPage() {
const {
data: {
data: {
headStats,
labelValueCountByLabelName,
seriesCountByMetricName,
memoryInBytesByLabelName,
seriesCountByLabelValuePair,
},
},
} = useSuspenseAPIQuery<TSDBStatusResult>({ path: `/status/tsdb` });
const { useLocalTime } = useSettings();
const unixToTime = (unix: number): string => {
const formatted = formatTimestamp(unix, useLocalTime);
if (formatted === "Invalid Date") {
if (numSeries === 0) {
return "No datapoints yet";
}
return `Error parsing time (${unix})`;
}
return formatted;
};
const { chunkCount, numSeries, numLabelPairs, minTime, maxTime } = headStats;
const stats = [
{ name: "Number of Series", value: numSeries },
{ name: "Number of Chunks", value: chunkCount },
{ name: "Number of Label Pairs", value: numLabelPairs },
{ name: "Current Min Time", value: `${unixToTime(minTime / 1000)}` },
{ name: "Current Max Time", value: `${unixToTime(maxTime / 1000)}` },
];
return (
<InfoPageStack>
{[
{
title: "TSDB Head Status",
stats,
formatAsCode: false,
},
{
title: "Top 10 label names with value count",
stats: labelValueCountByLabelName,
formatAsCode: true,
},
{
title: "Top 10 series count by metric names",
stats: seriesCountByMetricName,
formatAsCode: true,
},
{
title: "Top 10 label names with high memory usage",
unit: "Bytes",
stats: memoryInBytesByLabelName,
formatAsCode: true,
},
{
title: "Top 10 series count by label value pairs",
stats: seriesCountByLabelValuePair,
formatAsCode: true,
},
].map(({ title, unit = "Count", stats, formatAsCode }) => (
<InfoPageCard title={title}>
<Table layout="fixed">
<Table.Thead>
<Table.Tr>
<Table.Th>Name</Table.Th>
<Table.Th>{unit}</Table.Th>
</Table.Tr>
</Table.Thead>
<Table.Tbody>
{stats.map(({ name, value }) => (
<Table.Tr key={name}>
<Table.Td
style={{
wordBreak: "break-all",
}}
>
{formatAsCode ? <code>{name}</code> : name}
</Table.Td>
<Table.Td>{value}</Table.Td>
</Table.Tr>
))}
</Table.Tbody>
</Table>
</InfoPageCard>
))}
</InfoPageStack>
);
}