How to use the prom2teams.app.sender.AlarmSender function in prom2teams

To help you get started, weā€™ve selected a few prom2teams examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github idealista / prom2teams / tests / test_json_fields.py View on Github external
def test_compose_all(self):
        with open(self.TEST_CONFIG_FILES_PATH + 'all_ok.json') as json_data:
            with open(self.TEST_CONFIG_FILES_PATH + 'teams_alarm_all_ok.json') as expected_data:
                json_received = json.load(json_data)
                json_expected = json.load(expected_data)

                alerts = MessageSchema().load(json_received)
                rendered_data = AlarmSender()._create_alarms(alerts)[0]
                json_rendered = json.loads(rendered_data)

                self.assertDictEqual(json_rendered, json_expected)
github idealista / prom2teams / tests / test_json_fields.py View on Github external
def test_with_extra_labels(self):
        excluded_labels = ('pod_name', )
        with open(self.TEST_CONFIG_FILES_PATH + 'all_ok_extra_labels.json') as json_data:
            with open(self.TEST_CONFIG_FILES_PATH + 'teams_alarm_all_ok_extra_labels.json') as expected_data:
                json_received = json.load(json_data)
                json_expected = json.load(expected_data)

                alerts = MessageSchema(exclude_fields=excluded_labels).load(json_received)
                rendered_data = AlarmSender()._create_alarms(alerts)[0]
                json_rendered = json.loads(rendered_data)

                self.assertDictEqual(json_rendered, json_expected)
github idealista / prom2teams / tests / test_json_fields.py View on Github external
def test_with_extra_annotations(self):
        excluded_annotations = ('message', )
        with open(self.TEST_CONFIG_FILES_PATH + 'all_ok_extra_annotations.json') as json_data:
            with open(self.TEST_CONFIG_FILES_PATH + 'teams_alarm_all_ok_extra_annotations.json') as expected_data:
               json_received = json.load(json_data)
               json_expected = json.load(expected_data)

               alerts = MessageSchema(exclude_annotations=excluded_annotations).load(json_received)
               rendered_data = AlarmSender()._create_alarms(alerts)[0]
               json_rendered = json.loads(rendered_data)

               self.assertDictEqual(json_rendered, json_expected)
github idealista / prom2teams / tests / test_json_fields.py View on Github external
def test_with_common_items(self):
        self.maxDiff = None
        with open(self.TEST_CONFIG_FILES_PATH + 'with_common_items.json') as json_data:
            with open(self.TEST_CONFIG_FILES_PATH + 'teams_alarm_with_common_items.json') as expected_data:
                json_received = json.load(json_data)
                json_expected = json.load(expected_data)

                alerts = MessageSchema().load(json_received)
                rendered_data = AlarmSender()._create_alarms(alerts)[0]
                json_rendered = json.loads(rendered_data)

                self.assertEqual(json_rendered.keys(), json_expected.keys())
github idealista / prom2teams / tests / test_json_fields.py View on Github external
def test_grouping_multiple_alerts(self):
        with open(self.TEST_CONFIG_FILES_PATH + 'all_ok_multiple.json') as json_data:
            with open(self.TEST_CONFIG_FILES_PATH + 'teams_alarm_all_ok_multiple.json') as expected_data:
                json_received = json.load(json_data)
                json_expected = json.load(expected_data)

                alerts = MessageSchema().load(json_received)
                rendered_data = AlarmSender(group_alerts_by='name')._create_alarms(alerts)[0].replace("\n\n\n", " ")
                json_rendered = json.loads(rendered_data)

                self.assertDictEqual(json_rendered, json_expected)
github idealista / prom2teams / prom2teams / app / versions / v1 / namespace.py View on Github external
def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.schema = MessageSchema()
        if 'TEMPLATE_PATH' in app.config:
            self.sender = AlarmSender(app.config['TEMPLATE_PATH'])
        else:
            self.sender = AlarmSender()
github idealista / prom2teams / prom2teams / app / versions / v2 / namespace.py View on Github external
def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.schema = MessageSchema(exclude_fields=app.config['LABELS_EXCLUDED'], exclude_annotations=app.config['ANNOTATIONS_EXCLUDED'], unknown=EXCLUDE)
        if app.config['TEMPLATE_PATH']:
            self.sender = AlarmSender(app.config['TEMPLATE_PATH'], app.config['GROUP_ALERTS_BY'])
        else:
            self.sender = AlarmSender(group_alerts_by=app.config['GROUP_ALERTS_BY'])
github idealista / prom2teams / prom2teams / app / versions / v2 / namespace.py View on Github external
def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.schema = MessageSchema(exclude_fields=app.config['LABELS_EXCLUDED'], exclude_annotations=app.config['ANNOTATIONS_EXCLUDED'], unknown=EXCLUDE)
        if app.config['TEMPLATE_PATH']:
            self.sender = AlarmSender(app.config['TEMPLATE_PATH'], app.config['GROUP_ALERTS_BY'])
        else:
            self.sender = AlarmSender(group_alerts_by=app.config['GROUP_ALERTS_BY'])