mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
More timestamp handling fixes/improvements
Signed-off-by: Julius Volz <julius.volz@gmail.com>
This commit is contained in:
parent
3c44f43815
commit
b40a029599
|
@ -1,6 +1,7 @@
|
||||||
import { Card, Group, Stack, Table, Text } from "@mantine/core";
|
import { Card, Group, Stack, Table, Text } from "@mantine/core";
|
||||||
import { useSuspenseAPIQuery } from "../api/api";
|
import { useSuspenseAPIQuery } from "../api/api";
|
||||||
import { IconRun, IconWall } from "@tabler/icons-react";
|
import { IconRun, IconWall } from "@tabler/icons-react";
|
||||||
|
import { formatTimestamp } from "../lib/formatTime";
|
||||||
|
|
||||||
const statusConfig: Record<
|
const statusConfig: Record<
|
||||||
string,
|
string,
|
||||||
|
@ -11,7 +12,7 @@ const statusConfig: Record<
|
||||||
> = {
|
> = {
|
||||||
startTime: {
|
startTime: {
|
||||||
title: "Start time",
|
title: "Start time",
|
||||||
formatValue: (v: string) => new Date(v).toUTCString(),
|
formatValue: (v: string) => formatTimestamp(new Date(v).valueOf() / 1000),
|
||||||
},
|
},
|
||||||
CWD: { title: "Working directory" },
|
CWD: { title: "Working directory" },
|
||||||
reloadConfigSuccess: {
|
reloadConfigSuccess: {
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
import { Stack, Card, Group, Table, Text } from "@mantine/core";
|
import { Stack, Card, Group, Table, Text } from "@mantine/core";
|
||||||
import { useSuspenseAPIQuery } from "../api/api";
|
import { useSuspenseAPIQuery } from "../api/api";
|
||||||
import { TSDBMap } from "../api/responseTypes/tsdbStatus";
|
import { TSDBMap } from "../api/responseTypes/tsdbStatus";
|
||||||
|
import { useAppSelector } from "../state/hooks";
|
||||||
|
import { formatTimestamp } from "../lib/formatTime";
|
||||||
|
|
||||||
export default function TSDBStatusPage() {
|
export default function TSDBStatusPage() {
|
||||||
const {
|
const {
|
||||||
|
@ -15,23 +17,27 @@ export default function TSDBStatusPage() {
|
||||||
},
|
},
|
||||||
} = useSuspenseAPIQuery<TSDBMap>({ path: `/status/tsdb` });
|
} = useSuspenseAPIQuery<TSDBMap>({ path: `/status/tsdb` });
|
||||||
|
|
||||||
|
const useLocalTime = useAppSelector((state) => state.settings.useLocalTime);
|
||||||
|
|
||||||
const unixToTime = (unix: number): string => {
|
const unixToTime = (unix: number): string => {
|
||||||
try {
|
const formatted = formatTimestamp(unix, useLocalTime);
|
||||||
return `${new Date(unix).toISOString()} (${unix})`;
|
if (formatted === "Invalid Date") {
|
||||||
} catch {
|
|
||||||
if (numSeries === 0) {
|
if (numSeries === 0) {
|
||||||
return "No datapoints yet";
|
return "No datapoints yet";
|
||||||
}
|
}
|
||||||
return `Error parsing time (${unix})`;
|
return `Error parsing time (${unix})`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return formatted;
|
||||||
};
|
};
|
||||||
|
|
||||||
const { chunkCount, numSeries, numLabelPairs, minTime, maxTime } = headStats;
|
const { chunkCount, numSeries, numLabelPairs, minTime, maxTime } = headStats;
|
||||||
const stats = [
|
const stats = [
|
||||||
{ name: "Number of Series", value: numSeries },
|
{ name: "Number of Series", value: numSeries },
|
||||||
{ name: "Number of Chunks", value: chunkCount },
|
{ name: "Number of Chunks", value: chunkCount },
|
||||||
{ name: "Number of Label Pairs", value: numLabelPairs },
|
{ name: "Number of Label Pairs", value: numLabelPairs },
|
||||||
{ name: "Current Min Time", value: `${unixToTime(minTime)}` },
|
{ name: "Current Min Time", value: `${unixToTime(minTime / 1000)}` },
|
||||||
{ name: "Current Max Time", value: `${unixToTime(maxTime)}` },
|
{ name: "Current Max Time", value: `${unixToTime(maxTime / 1000)}` },
|
||||||
];
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
Loading…
Reference in a new issue