Skip to content

Commit

Permalink
Merge pull request #101 from idealista/develop
Browse files Browse the repository at this point in the history
v2.2.3 to master
  • Loading branch information
José Noguera authored Oct 24, 2018
2 parents d0b3973 + 78c7466 commit a35273c
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 20 deletions.
9 changes: 7 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@ This project adheres to [Semantic Versioning](http://semver.org/) and [Keep a ch

## [Unreleased](https://github.com/idealista/prom2teams/tree/develop)

## [2.2.3](https://github.com/idealista/prom2teams/tree/2.2.3)
[Full Changelog](https://github.com/idealista/prom2teams/compare/2.2.2...2.2.3)
## Changed
- *[#99](https://github.com/idealista/prom2teams/pull/99) Marshmallow update* @manuhortet

## [2.2.2](https://github.com/idealista/prom2teams/tree/2.2.2)
[Full Changelog](https://github.com/idealista/prom2teams/compare/2.2.1...2.2.2)
## Added
- *[#94](https://github.com/idealista/prom2teams/pull/94) Always group by status @manuhortet*
- *[#94](https://github.com/idealista/prom2teams/pull/94) Always group by status* @manuhortet

## [2.2.1](https://github.com/idealista/prom2teams/tree/2.2.1)
[Full Changelog](https://github.com/idealista/prom2teams/compare/2.1.2...2.2.1)
Expand All @@ -22,7 +27,7 @@ This project adheres to [Semantic Versioning](http://semver.org/) and [Keep a ch
## [2.1.2](https://github.com/idealista/prom2teams/tree/2.1.2)
[Full Changelog](https://github.com/idealista/prom2teams/compare/2.1.1...2.1.2)
### Fixed
- *[#70](https://github.com/idealista/prom2teams/pull/70) Fix condition in teams_client.py * @Gkrlo
- *[#70](https://github.com/idealista/prom2teams/pull/70) Fix condition in teams_client.py* @Gkrlo

## [2.1.1](https://github.com/idealista/prom2teams/tree/2.1.1)
[Full Changelog](https://github.com/idealista/prom2teams/compare/2.0.4...2.1.1)
Expand Down
2 changes: 1 addition & 1 deletion prom2teams/app/versions/v1/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
'device': fields.String(default='rootfs'),
'instance': fields.String(default='cs30.evilcorp'),
'job': fields.String(default='fsociety'),
'mounterpoint': fields.String(default='/'),
'mountpoint': fields.String(default='/'),
'severity': fields.String(default='severe')
})

Expand Down
2 changes: 1 addition & 1 deletion prom2teams/app/versions/v1/namespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def __init__(self, *args, **kwargs):
def post(self):
_show_deprecated_warning("Call to deprecated function. It will be removed in future versions. "
"Please view the README file.")
alerts = self.schema.load(request.get_json()).data
alerts = self.schema.load(request.get_json())
self.sender.send_alarms(alerts, app.config['MICROSOFT_TEAMS']['Connector'])
return 'OK', 201

Expand Down
2 changes: 1 addition & 1 deletion prom2teams/app/versions/v2/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
'device': fields.String(default='rootfs'),
'instance': fields.String(default='cs30.evilcorp'),
'job': fields.String(default='fsociety'),
'mounterpoint': fields.String(default='/'),
'mountpoint': fields.String(default='/'),
'severity': fields.String(default='severe')
})

Expand Down
2 changes: 1 addition & 1 deletion prom2teams/app/versions/v2/namespace.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ def __init__(self, *args, **kwargs):

@api_v2.expect(message)
def post(self, connector):
alerts = self.schema.load(request.get_json()).data
alerts = self.schema.load(request.get_json())
self.sender.send_alarms(alerts, app.config['MICROSOFT_TEAMS'][connector])
return 'OK', 201
6 changes: 3 additions & 3 deletions prom2teams/teams/alarm_mapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
def map_alarm_to_json(alarm):
schema = TeamsAlarmSchema()
result = schema.dump(alarm)
return result.data
return result


def map_prom_alerts_to_teams_alarms(alerts):
Expand All @@ -16,7 +16,7 @@ def map_prom_alerts_to_teams_alarms(alerts):
for alert in alerts[same_status_alerts]:
alarm = TeamsAlarm(alert.name, alert.status.lower(), alert.severity,
alert.summary, alert.instance, alert.description)
json_alarm = schema.dump(alarm).data
json_alarm = schema.dump(alarm)
teams_alarms.append(json_alarm)
return teams_alarms

Expand All @@ -36,7 +36,7 @@ def map_and_group(alerts, group_alerts_by):
teams_visualization(features["status"]),
teams_visualization(features["summary"]))
alarm = TeamsAlarm(name, status.lower(), severity, summary, instance, description)
json_alarm = schema.dump(alarm).data
json_alarm = schema.dump(alarm)
teams_alarms.append(json_alarm)
return teams_alarms

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ requests==2.9.1
Jinja2==2.10
Flask==1.0.2
flask-restplus==0.10.1
marshmallow==2.15.0
marshmallow==3.0.0b16
pyyaml==3.12
uwsgi==2.0.16
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@


setup(name='prom2teams',
version='2.2.2',
version='2.2.3',
description='Project that redirects Prometheus Alert Manager '
'notifications to Microsoft Teams',
long_description=readme,
Expand Down
6 changes: 3 additions & 3 deletions tests/data/jsons/without_mandatory_field.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
"device": "rootfs",
"fstype": "rootfs",
"job": "fsociety",
"mountpoint": "/"
"mountpoint": "/",
"severity": "severe"
},
"annotations": {
"description": "disk usage 73% on rootfs device",
"severity": "severe"
"description": "disk usage 73% on rootfs device"
},
"startsAt": "2017-05-09T07:01:37.803Z",
"endsAt": "2017-05-09T07:08:37.818278068Z",
Expand Down
12 changes: 6 additions & 6 deletions tests/test_json_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,28 +13,28 @@ class TestJSONFields(unittest.TestCase):
def test_json_with_all_fields(self):
with open(self.TEST_CONFIG_FILES_PATH + 'all_ok.json') as json_data:
json_received = json.load(json_data)
alerts = MessageSchema().load(json_received).data
alerts = MessageSchema().load(json_received)
alarm = map_prom_alerts_to_teams_alarms(alerts)[0]
self.assertNotIn('unknown', str(alarm))

def test_json_without_mandatory_field(self):
with open(self.TEST_CONFIG_FILES_PATH + 'without_mandatory_field.json') as json_data:
json_received = json.load(json_data)
alerts = MessageSchema().load(json_received).data
alerts = MessageSchema().load(json_received)
alarm = map_prom_alerts_to_teams_alarms(alerts)[0]
self.assertIn('unknown', str(alarm))

def test_json_without_optional_field(self):
with open(self.TEST_CONFIG_FILES_PATH + 'without_optional_field.json') as json_data:
json_received = json.load(json_data)
alerts = MessageSchema().load(json_received).data
alerts = MessageSchema().load(json_received)
alarm = map_prom_alerts_to_teams_alarms(alerts)[0]
self.assertIn("'description': 'unknown'", str(alarm))

def test_json_without_instance_field(self):
with open(self.TEST_CONFIG_FILES_PATH + 'without_instance_field.json') as json_data:
json_received = json.load(json_data)
alerts = MessageSchema().load(json_received).data
alerts = MessageSchema().load(json_received)
alarm = map_prom_alerts_to_teams_alarms(alerts)[0]
self.assertEqual('unknown', str(alarm['instance']))

Expand All @@ -44,7 +44,7 @@ def test_compose_all(self):
json_received = json.load(json_data)
json_expected = json.load(expected_data)

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

Expand All @@ -56,7 +56,7 @@ def test_grouping_multiple_alerts(self):
json_received = json.load(json_data)
json_expected = json.load(expected_data)

alerts = MessageSchema().load(json_received).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)

Expand Down

0 comments on commit a35273c

Please sign in to comment.