diff --git a/hbd/server/templates/alerts.html b/hbd/server/templates/alerts.html index 8b0da0c..bde9af7 100644 --- a/hbd/server/templates/alerts.html +++ b/hbd/server/templates/alerts.html @@ -438,7 +438,7 @@
${alert.level} ${alert.hostname} - ${alert.metric_path.includes('.') ? alert.metric_path.slice(alert.metric_path.indexOf('.') + 1) : alert.metric_path} + ${(alert.metric_path.includes('.') ? alert.metric_path.slice(alert.metric_path.indexOf('.') + 1) : alert.metric_path).replace(/_status_code$/, '')}
${valueText} diff --git a/hbd/server/threshold.py b/hbd/server/threshold.py index 2be4588..11d79a3 100644 --- a/hbd/server/threshold.py +++ b/hbd/server/threshold.py @@ -1044,8 +1044,8 @@ class ThresholdChecker: # Format operator symbol op_symbol = threshold.operator.value - # Short metric label: strip the plugin-name prefix for readability - short_path = metric_path.partition(".")[2] or metric_path + # Short metric label: strip the plugin-name prefix and _status_code suffix + short_path = (metric_path.partition(".")[2] or metric_path).removesuffix("_status_code") # Use a display-friendly value (inf is the sentinel for "overdue") import math @@ -1109,7 +1109,7 @@ class ThresholdChecker: if host is not None and not host.watched: eventlog(host_name, lvl, message, service="threshold") return - short_path = metric_path.partition(".")[2] or metric_path + short_path = (metric_path.partition(".")[2] or metric_path).removesuffix("_status_code") title = f"[{lvl}] {host_name} {short_path}" # Strip the "metric = " prefix from message so body is just the value/detail prefix = short_path + " = " @@ -1349,7 +1349,7 @@ class ThresholdChecker: # Format operator symbol op_symbol = threshold.operator.value - short_path = metric_path.partition(".")[2] or metric_path + short_path = (metric_path.partition(".")[2] or metric_path).removesuffix("_status_code") # Time to re-notify if threshold_value is not None: