From 664b39157381239c7c5e568ca9dcebc8732beae4 Mon Sep 17 00:00:00 2001 From: Julius Volz Date: Mon, 28 Jun 2021 16:14:48 +0200 Subject: [PATCH] Speed up alerts page by not rendering collapsed details (#9005) All this is doing is wrapping the inner alert details display with a conditional `{open && ...}`. This already improves https://github.com/prometheus/prometheus/issues/8548 a lot for cases where there are many individual firing/pending alert elements under each alerting rule. E.g. for a list of 200 rules with ~100 alert elements each, this changed the page render time from 30 seconds to 1s. Signed-off-by: Julius Volz --- .../pages/alerts/CollapsibleAlertPanel.tsx | 148 +++++++++--------- 1 file changed, 76 insertions(+), 72 deletions(-) diff --git a/web/ui/react-app/src/pages/alerts/CollapsibleAlertPanel.tsx b/web/ui/react-app/src/pages/alerts/CollapsibleAlertPanel.tsx index 72edfbab7b..8a5197aa71 100644 --- a/web/ui/react-app/src/pages/alerts/CollapsibleAlertPanel.tsx +++ b/web/ui/react-app/src/pages/alerts/CollapsibleAlertPanel.tsx @@ -28,81 +28,85 @@ const CollapsibleAlertPanel: FC = ({ rule, showAnnot {rule.name} ({`${rule.alerts.length} active`}) -
-          
-            
- name: {rule.name} -
-
- expr: {rule.query} -
- {rule.duration > 0 && ( -
-
for: {formatDuration(rule.duration * 1000)}
-
- )} - {rule.labels && Object.keys(rule.labels).length > 0 && ( -
-
labels:
- {Object.entries(rule.labels).map(([key, value]) => ( -
- {key}: {value} + {open && ( + <> +
+              
+                
+ name: {rule.name} +
+
+ expr: {rule.query} +
+ {rule.duration > 0 && ( +
+
for: {formatDuration(rule.duration * 1000)}
- ))} -
- )} - {rule.annotations && Object.keys(rule.annotations).length > 0 && ( -
-
annotations:
- {Object.entries(rule.annotations).map(([key, value]) => ( -
- {key}: {value} + )} + {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 && ( + + + + + + + + + + + {rule.alerts.map((alert, i) => { + return ( + + + + + + + + {showAnnotations && } + + ); + })} + +
LabelsStateActive SinceValue
+ {Object.entries(alert.labels).map(([k, v], j) => { + return ( + + {k}={v} + + ); + })} + +
+ + {alert.state} + +
+
{alert.activeAt}{parsePrometheusFloat(alert.value)}
)} -
- - {rule.alerts.length > 0 && ( - - - - - - - - - - - {rule.alerts.map((alert, i) => { - return ( - - - - - - - - {showAnnotations && } - - ); - })} - -
LabelsStateActive SinceValue
- {Object.entries(alert.labels).map(([k, v], j) => { - return ( - - {k}={v} - - ); - })} - -
- - {alert.state} - -
-
{alert.activeAt}{parsePrometheusFloat(alert.value)}
+ )}