X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_mon%2Fserver%2Fservice.py;h=d1b408b478df404cd70458f17ca94e76a4f62657;hb=0ccdba94d5ca1de0ff26c6aaf5a16aacc3c2fd0d;hp=298043e0b59057abffe1c043a62a925e64bd3240;hpb=8e4179facf22c8096992f0a83caeec9f2f4996c7;p=osm%2FMON.git diff --git a/osm_mon/server/service.py b/osm_mon/server/service.py index 298043e..d1b408b 100755 --- a/osm_mon/server/service.py +++ b/osm_mon/server/service.py @@ -41,11 +41,12 @@ class ServerService: severity: str, statistic: str, metric_name: str, + action: str, tags: dict, ) -> Alarm: log.debug("create_alarm") alarm = Alarm( - name, severity, threshold, operation, statistic, metric_name, tags + name, severity, threshold, operation, statistic, metric_name, action, tags ) self.common_db.create_alarm(alarm) log.info("Alarm %s created", alarm.name) @@ -55,3 +56,23 @@ class ServerService: log.debug("delete_alarm") self.common_db.delete_alarm(alarm_uuid) log.info("Alarm %s is deleted", alarm_uuid) + + def populate_prometheus(self): + # This method can be executed infinite number of times + # without side-effects. + log.info("Setting up MON Exporter in prometheus") + result = self.common_db.common_db.set_one( + "prometheus_jobs", {"job_name": "mon_exporter"}, { + "job_name": "mon_exporter", + "static_configs": [ + { + "targets": [ + "mon:8000" + ] + } + ] + }, + fail_on_empty=False, + upsert=True + ) + log.info("Prometheus Jobs added > {}".format(result))