diff --git a/web/ui/mantine-ui/src/components/RuleDefinition.module.css b/web/ui/mantine-ui/src/components/RuleDefinition.module.css index d54a7d1b4f..15a8d4a420 100644 --- a/web/ui/mantine-ui/src/components/RuleDefinition.module.css +++ b/web/ui/mantine-ui/src/components/RuleDefinition.module.css @@ -4,3 +4,12 @@ var(--mantine-color-gray-9) ); } + +.queryButton { + opacity: 0; + transition: opacity 0.1s ease-in-out; +} + +.codebox:hover .queryButton { + opacity: 1; +} diff --git a/web/ui/mantine-ui/src/components/RuleDefinition.tsx b/web/ui/mantine-ui/src/components/RuleDefinition.tsx index dfc5c5d33f..0865f58ad9 100644 --- a/web/ui/mantine-ui/src/components/RuleDefinition.tsx +++ b/web/ui/mantine-ui/src/components/RuleDefinition.tsx @@ -1,5 +1,14 @@ -import { Badge, Box, Card, Group, useComputedColorScheme } from "@mantine/core"; -import { IconClockPause, IconClockPlay } from "@tabler/icons-react"; +import { + ActionIcon, + Badge, + Box, + Card, + Group, + rem, + Tooltip, + useComputedColorScheme, +} from "@mantine/core"; +import { IconClockPause, IconClockPlay, IconSearch } from "@tabler/icons-react"; import { FC } from "react"; import { formatPrometheusDuration } from "../lib/formatTime"; import codeboxClasses from "./RuleDefinition.module.css"; @@ -14,15 +23,17 @@ import { } from "../codemirror/theme"; import { PromQLExtension } from "@prometheus-io/codemirror-promql"; import { LabelBadges } from "./LabelBadges"; +import { useSettings } from "../state/settingsSlice"; const promqlExtension = new PromQLExtension(); const RuleDefinition: FC<{ rule: Rule }> = ({ rule }) => { const theme = useComputedColorScheme(); + const { pathPrefix } = useSettings(); return ( <> - + = ({ rule }) => { EditorView.lineWrapping, ]} /> + + + { + window.open( + `${pathPrefix}/query?g0.expr=${encodeURIComponent(rule.query)}&g0.tab=1`, + "_blank" + ); + }} + className={codeboxClasses.queryButton} + > + + + {rule.type === "alerting" && ( - + {rule.duration && ( = ({ rule }) => { )} {rule.labels && Object.keys(rule.labels).length > 0 && ( - + )} diff --git a/web/ui/mantine-ui/src/pages/AlertsPage.tsx b/web/ui/mantine-ui/src/pages/AlertsPage.tsx index 84f7ff1156..78e12a57d1 100644 --- a/web/ui/mantine-ui/src/pages/AlertsPage.tsx +++ b/web/ui/mantine-ui/src/pages/AlertsPage.tsx @@ -11,6 +11,7 @@ import { Alert, TextInput, Anchor, + Divider, } from "@mantine/core"; import { useSuspenseAPIQuery } from "../api/api"; import { AlertingRule, AlertingRulesResult } from "../api/responseTypes/rules"; @@ -352,7 +353,9 @@ export default function AlertsPage() { {a.state} - + {humanizeDurationRelative( @@ -363,12 +366,24 @@ export default function AlertsPage() { - {a.value} + + {isNaN(Number(a.value)) + ? a.value + : Number(a.value)} + {showAnnotations && ( - +
{Object.entries( a.annotations