From fe8d412ce9b7313ea5c31686d25a648aba11fc21 Mon Sep 17 00:00:00 2001 From: Julien Pivotto Date: Tue, 21 Jul 2020 10:49:33 +0200 Subject: [PATCH] React UI: Add duration, labels, annotations to alerts page (#7605) * React UI: Add duration, labels, annotation to alerts page Signed-off-by: Julien Pivotto * lint Signed-off-by: Julien Pivotto * make expression shorter Signed-off-by: Julien Pivotto * Check for null Signed-off-by: Julien Pivotto * Use object.keys Signed-off-by: Julien Pivotto --- .../pages/alerts/CollapsibleAlertPanel.tsx | 35 ++++++++++++++----- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/web/ui/react-app/src/pages/alerts/CollapsibleAlertPanel.tsx b/web/ui/react-app/src/pages/alerts/CollapsibleAlertPanel.tsx index ee1f507f9..1208d5088 100644 --- a/web/ui/react-app/src/pages/alerts/CollapsibleAlertPanel.tsx +++ b/web/ui/react-app/src/pages/alerts/CollapsibleAlertPanel.tsx @@ -5,7 +5,7 @@ import { RuleStatus } from './AlertContents'; import { Rule } from '../../types/types'; import { faChevronDown, faChevronRight } from '@fortawesome/free-solid-svg-icons'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; -import { createExpressionLink, parsePrometheusFloat } from '../../utils/index'; +import { createExpressionLink, parsePrometheusFloat, formatRange } from '../../utils/index'; interface CollapsibleAlertPanelProps { rule: Rule; @@ -36,14 +36,31 @@ const CollapsibleAlertPanel: FC = ({ rule, showAnnot
expr: {rule.query}
-
-
labels:
-
severity: {rule.labels.severity}
-
-
-
annotations:
-
summary: {rule.annotations.summary}
-
+ {rule.duration > 0 && ( +
+
for: {formatRange(rule.duration)}
+
+ )} + {rule.labels && Object.keys(rule.labels).length > 0 && ( +
+
labels:
+ {Object.entries(rule.labels).map(([key, value]) => ( +
+ {key}: {value} +
+ ))} +
+ )} + {rule.annotations && Object.keys(rule.annotations).length > 0 && ( +
+
annotations:
+ {Object.entries(rule.annotations).map(([key, value]) => ( +
+ {key}: {value} +
+ ))} +
+ )} {rule.alerts.length > 0 && (