Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR previous to release 3.2.1 #253

Merged
merged 9 commits into from
Feb 18, 2021
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/) and [Keep a changelog](https://github.com/olivierlacan/keep-a-changelog).

## [Unreleased](https://github.com/idealista/prom2teams/tree/develop)
## [3.2.1](https://github.com/idealista/prom2teams/tree/3.2.1)
[Full Changelog](https://github.com/idealista/prom2teams/compare/3.2.0...3.2.1)
### Fixed
- *[#225](https://github.com/idealista/prom2teams/issues/250) Fix error when fingerprint is missing @jperera
### Changed
- *[#244](https://github.com/idealista/prom2teams/issues/244) Change travis-ci.org by travis-ci.com in README @Crozzers
## [3.2.0](https://github.com/idealista/prom2teams/tree/3.2.0)
[Full Changelog](https://github.com/idealista/prom2teams/compare/3.1.0...3.2.0)
### Added
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div align="center">
<img alt="logo" src="https://raw.githubusercontent.com/idealista/prom2teams/master/logo.gif">

[![Build Status](https://travis-ci.org/idealista/prom2teams.svg?branch=master)](https://travis-ci.org/idealista/prom2teams)
[![Build Status](https://travis-ci.com/idealista/prom2teams.svg?branch=master)](https://travis-ci.com/idealista/prom2teams)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=idealista_prom2teams&metric=alert_status)](https://sonarcloud.io/dashboard?id=idealista_prom2teams)
[![Docker Build Status](https://img.shields.io/docker/build/idealista/prom2teams.svg)](https://hub.docker.com/r/idealista/prom2teams/)
[![Docker Hub Pulls](https://img.shields.io/docker/pulls/idealista/prom2teams.svg)](https://hub.docker.com/r/idealista/prom2teams/)
Expand Down
2 changes: 1 addition & 1 deletion helm/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: v1
appVersion: "3.2.0"
appVersion: "3.2.1"
description: A Helm chart for Prom2Teams
name: prom2teams
version: 0.2.0
2 changes: 1 addition & 1 deletion prom2teams/prometheus/message_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def get_alerts(self, message):
description = alert['annotations']['description']
severity = alert['labels']['severity']
runbook_url = alert['annotations'].get('runbook_url', '')
fingerprint = alert.get('fingerprint', None)
fingerprint = alert.get('fingerprint', '')
extra_labels = dict()
extra_annotations = dict()

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@


setup(name='prom2teams',
version='3.2.0',
version='3.2.1',
description='Project that redirects Prometheus Alert Manager '
'notifications to Microsoft Teams',
long_description=readme,
Expand Down
27 changes: 27 additions & 0 deletions tests/data/json_files/teams_without_fingerprint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"@type": "MessageCard",
"@context": "http://schema.org/extensions",
"themeColor": " 2DC72D ",
"summary": "(Resolved) Disk usage alert on CS30.evilcorp",
"title": "Prometheus alert (Resolved) ",
"sections": [{
"activityTitle": "Disk usage alert on CS30.evilcorp",
"facts": [{
"name": "Alert",
"value": "DiskSpace"
},{
"name": "In host",
"value": "cs30.evilcorp"
},{
"name": "Severity",
"value": "severe"
},{
"name": "Description",
"value": "disk usage 93% on rootfs device"
},{
"name": "Status",
"value": "resolved"
}],
"markdown": true
}]
}
26 changes: 26 additions & 0 deletions tests/data/json_files/without_fingerprint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"receiver": "test_webhook",
"status": "resolved",
"alerts": [
{
"status": "resolved",
"labels": {
"alertname": "DiskSpace",
"device": "rootfs",
"fstype": "rootfs",
"instance": "cs30.evilcorp",
"mountpoint": "/",
"severity": "severe"
},
"annotations": {
"description": "disk usage 93% on rootfs device",
"summary": "Disk usage alert on CS30.evilcorp"
},
"startsAt": "2017-05-09T07:01:37.803000Z",
"endsAt": "2017-05-09T07:08:37.818278Z",
"generatorURL": "my.prometheusserver.url"
}
],
"externalURL": "my.prometheusalertmanager.url",
"version": "4"
}
12 changes: 12 additions & 0 deletions tests/test_json_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,18 @@ def test_fingerprint(self):
alert = map_prom_alerts_to_teams_alerts(alerts)[0]
self.assertEqual('dd19ae3d4e06ac55', str(alert['fingerprint']))

def test_without_fingerprint(self):
with open(os.path.join(self.TEST_CONFIG_FILES_PATH, 'without_fingerprint.json')) as json_data:
with open(os.path.join(self.TEST_CONFIG_FILES_PATH, 'teams_without_fingerprint.json')) as expected_data:
json_received = json.load(json_data)
json_expected = json.load(expected_data)

alerts = MessageSchema().load(json_received)
rendered_data = AlertSender()._create_alerts(alerts)[0]
json_rendered = json.loads(rendered_data)

self.assertEqual(json_rendered.keys(), json_expected.keys())

def test_compose_all(self):
with open(os.path.join(self.TEST_CONFIG_FILES_PATH, 'all_ok.json')) as json_data:
with open(os.path.join(self.TEST_CONFIG_FILES_PATH, 'teams_alert_all_ok.json')) as expected_data:
Expand Down