X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=osm_policy_module%2Fcommon%2Fmon_client.py;h=e9216aabb108a3941c29b06ec1b009a3901f8a02;hb=bb6bdfab64270428f29dfa0f03d9b7c35c9faa90;hp=d5e8dfc3da089f8d1f64ef1a9a06871ef6523293;hpb=d37c54c64eec65c9a3c490a31eef3a02a76cb474;p=osm%2FPOL.git diff --git a/osm_policy_module/common/mon_client.py b/osm_policy_module/common/mon_client.py index d5e8dfc..e9216aa 100644 --- a/osm_policy_module/common/mon_client.py +++ b/osm_policy_module/common/mon_client.py @@ -50,6 +50,8 @@ class MonClient: operation: str, statistic: str = "AVERAGE", action: str = "", + vnfr: object = None, + vnfd: object = None, ): cor_id = random.randint(1, 10e7) msg = self._build_create_alarm_payload( @@ -62,6 +64,8 @@ class MonClient: statistic, operation, action, + vnfr, + vnfd, ) log.debug("Sending create_alarm_request %s", msg) producer = AIOKafkaProducer( @@ -165,7 +169,26 @@ class MonClient: statistic: str, operation: str, action: str, + vnfr=None, + vnfd=None, ): + tags = { + "ns_id": ns_id, + "vdu_name": vdu_name, + "vnf_member_index": vnf_member_index, + } + if vnfr and vnfd: + # TODO: Change for multiple DF support + df = vnfd.get("df", [{}])[0] + if "exporters-endpoints" in df: + metric_port = df["exporters-endpoints"].get("metric-port", 9100) + if metric_name.startswith("kpi_"): + metric_name = metric_name.replace("kpi_", "") + metric_name.strip() + for vdu in vnfr["vdur"]: + if vdu["name"] == vdu_name: + vdu_ip = vdu["ip-address"] + tags = {"instance": vdu_ip + ":" + str(metric_port)} alarm_create_request = { "correlation_id": cor_id, "alarm_name": "osm_alarm_{}_{}_{}_{}".format( @@ -177,11 +200,7 @@ class MonClient: "threshold_value": threshold, "statistic": statistic, "action": action, - "tags": { - "ns_id": ns_id, - "vdu_name": vdu_name, - "vnf_member_index": vnf_member_index, - }, + "tags": tags, } msg = { "alarm_create_request": alarm_create_request,