From eb07672618920bcb12befd795a13ed41a231ef86 Mon Sep 17 00:00:00 2001 From: aguilard Date: Wed, 31 May 2023 09:45:00 +0000 Subject: [PATCH] Update mongo alarm structure for VDU alarms Change-Id: Ia661c23c902372357aa1efc511060e706065be61 Signed-off-by: aguilard --- osm_lcm/ns.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/osm_lcm/ns.py b/osm_lcm/ns.py index 6ec52c8..999aee6 100644 --- a/osm_lcm/ns.py +++ b/osm_lcm/ns.py @@ -2597,13 +2597,12 @@ class NsLcm(LcmBase): operation = alarm_descriptor["operation"] rel_operator = self.rel_operation_types.get(operation, "<=") metric_selector = f'{metric_name}{{ns_id="{nsr_id}", vnf_member_index="{vnf_member_index}", vdu_id="{vdu_id}"}}' - expression = ( - f"avg({metric_selector}) {rel_operator} {metric_threshold}" - ) + expression = f"{metric_selector} {rel_operator} {metric_threshold}" labels = { "ns_id": nsr_id, "vnf_member_index": vnf_member_index, "vdu_id": vdu_id, + "vdu_name": "{{ $labels.vdu_name }}", } prom_cfg = { "alert": alert_name, @@ -2617,12 +2616,9 @@ class NsLcm(LcmBase): "actions" in alarm_descriptor and action_type in alarm_descriptor["actions"] ): - for url in alarm_descriptor["actions"][action_type]: - if "webhook" in alarm_action: - alarm_action["webhook"].append(url["url"]) - else: - alarm_action["webhook"] = [url["url"]] - + alarm_action[action_type] = alarm_descriptor["actions"][ + action_type + ] alert = { "uuid": uuid, "name": alert_name, -- 2.25.1