Skip to content

Commit

Permalink
Merge pull request #253 from idealista/develop
Browse files Browse the repository at this point in the history
PR previous to release 3.2.1
  • Loading branch information
jperera authored Feb 18, 2021
2 parents 05922a7 + bf929f1 commit 2971010
Show file tree
Hide file tree
Showing 8 changed files with 75 additions and 4 deletions.
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

0 comments on commit 2971010

Please sign in to comment.