diff --git a/web/ui/mantine-ui/src/RuleDefinition.tsx b/web/ui/mantine-ui/src/RuleDefinition.tsx
index d8546b395..c157a2ca6 100644
--- a/web/ui/mantine-ui/src/RuleDefinition.tsx
+++ b/web/ui/mantine-ui/src/RuleDefinition.tsx
@@ -1,7 +1,7 @@
-import { Badge, Card, Group, useComputedColorScheme } from "@mantine/core";
+import { Badge, Box, Card, Group, useComputedColorScheme } from "@mantine/core";
import { IconClockPause, IconClockPlay } from "@tabler/icons-react";
import { FC } from "react";
-import { formatDuration } from "./lib/formatTime";
+import { formatPrometheusDuration } from "./lib/formatTime";
import codeboxClasses from "./codebox.module.css";
import badgeClasses from "./Badge.module.css";
import { Rule } from "./api/responseTypes/rules";
@@ -14,6 +14,7 @@ import {
promqlHighlighter,
} from "./codemirror/theme";
import { PromQLExtension } from "@prometheus-io/codemirror-promql";
+import { LabelBadges } from "./LabelBadges";
const promqlExtension = new PromQLExtension();
@@ -46,7 +47,7 @@ const RuleDefinition: FC<{ rule: Rule }> = ({ rule }) => {
styles={{ label: { textTransform: "none" } }}
leftSection={}
>
- for: {formatDuration(rule.duration * 1000)}
+ for: {formatPrometheusDuration(rule.duration * 1000)}
)}
{rule.keepFiringFor && (
@@ -55,24 +56,15 @@ const RuleDefinition: FC<{ rule: Rule }> = ({ rule }) => {
styles={{ label: { textTransform: "none" } }}
leftSection={}
>
- keep_firing_for: {formatDuration(rule.duration * 1000)}
+ keep_firing_for: {formatPrometheusDuration(rule.duration * 1000)}
)}
)}
{rule.labels && Object.keys(rule.labels).length > 0 && (
-
- {Object.entries(rule.labels).map(([k, v]) => (
-
- {k}: {v}
-
- ))}
-
+
+
+
)}
{/* {Object.keys(r.annotations).length > 0 && (
diff --git a/web/ui/mantine-ui/src/api/responseTypes/rules.ts b/web/ui/mantine-ui/src/api/responseTypes/rules.ts
index 63d63d3d4..5866000af 100644
--- a/web/ui/mantine-ui/src/api/responseTypes/rules.ts
+++ b/web/ui/mantine-ui/src/api/responseTypes/rules.ts
@@ -13,7 +13,7 @@ type CommonRuleFields = {
name: string;
query: string;
evaluationTime: string;
- health: string;
+ health: "ok" | "unknown" | "err";
lastError?: string;
lastEvaluation: string;
};
diff --git a/web/ui/mantine-ui/src/pages/RulesPage.tsx b/web/ui/mantine-ui/src/pages/RulesPage.tsx
index c3d1db152..408bb5db4 100644
--- a/web/ui/mantine-ui/src/pages/RulesPage.tsx
+++ b/web/ui/mantine-ui/src/pages/RulesPage.tsx
@@ -1,4 +1,5 @@
import {
+ Accordion,
Alert,
Badge,
Card,
@@ -9,12 +10,17 @@ import {
Tooltip,
} from "@mantine/core";
// import { useQuery } from "react-query";
-import { formatRelative, humanizeDuration, now } from "../lib/formatTime";
+import {
+ humanizeDurationRelative,
+ humanizeDuration,
+ now,
+} from "../lib/formatTime";
import {
IconAlertTriangle,
IconBell,
IconDatabaseImport,
IconHourglass,
+ IconInfoCircle,
IconRefresh,
IconRepeat,
} from "@tabler/icons-react";
@@ -32,7 +38,7 @@ const healthBadgeClass = (state: string) => {
case "unknown":
return badgeClasses.healthUnknown;
default:
- return "orange";
+ throw new Error("Unknown rule health state");
}
};
@@ -41,6 +47,11 @@ export default function RulesPage() {
return (
+ {data.data.groups.length === 0 && (
+ }>
+ No rule groups configured.
+
+ )}
{data.data.groups.map((g, i) => (
}
>
- last run {formatRelative(g.lastEvaluation, now())}
+ last run {humanizeDurationRelative(g.lastEvaluation, now())}
@@ -91,21 +102,34 @@ export default function RulesPage() {
-
-
- {g.rules.map((r) => (
- // TODO: Find a stable and definitely unique key.
-
-
+ {g.rules.length === 0 && (
+ }>
+ No rules in rule group.
+
+ )}
+
+ {g.rules.map((r, j) => (
+
+
+
{r.type === "alerting" ? (
-
+
) : (
-
+
)}
-
- {r.name}
-
+ {r.name}
@@ -120,7 +144,7 @@ export default function RulesPage() {
styles={{ label: { textTransform: "none" } }}
leftSection={}
>
- {formatRelative(r.lastEvaluation, now())}
+ {humanizeDurationRelative(r.lastEvaluation, now())}
@@ -141,24 +165,24 @@ export default function RulesPage() {
-
-
-
- {r.lastError && (
- }
- >
- Error: {r.lastError}
-
- )}
-
-
- ))}
-
-
+
+
+
+
+ {r.lastError && (
+ }
+ >
+ Error: {r.lastError}
+
+ )}
+
+
+ ))}
+
))}