Commit Graph

68 Commits

Author SHA1 Message Date
Martin Chacon Piza fa2454a3c9 Fix Grafana URL in email notification
- Remove prefix 'dim_' from dimensions in Drilldown Dashboard
- Same was done for Monasca-UI [1]

[1] https://review.opendev.org/c/openstack/monasca-ui/+/782599

Change-Id: I69e3e7db54b995e45810532a1dd940ac8b68921f
2021-06-18 11:06:08 +02:00
wangzihao 3b91b33784 Remove six
Remove all six usage.

Change-Id: Ib2f0f6cf3b7f5d9ec20440fb81b09c1c083c67b0
Story: 2008305
Task: 41295
2020-11-20 09:35:23 +00:00
Hervé Beraud 7faa2184cd Use unittest.mock instead of mock
The mock third party library was needed for mock support in py2
runtimes. Since we now only support py36 and later, we can use the
standard lib unittest.mock module instead.

Change-Id: Ib7c9cca06dcfe14440ab9711cc0b76a5b4fe4e1c
2020-06-09 01:25:09 +02:00
Doug Szumski 0b5b77c974 Remove deprecated YAML config
This was marked for removal after the Pike release.

Updating Docker file is leftover and will done in a separate change.

Story: 2003180
Task: 23326
Change-Id: I583eab7b3ea2efd5d9bcd3ef433e68b49684e343
2020-04-23 18:53:27 +02:00
Sean McGinnis db7377f476 Use unittest.mock instead of third party mock
Now that we no longer support py27, we can use the standard library
unittest.mock module instead of the third party mock lib.

Change-Id: I380f25044c8f7b496d485aabf09215468f955818
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
2020-04-23 10:29:22 +00:00
Witek Bedyk db01fe425b Migrate from ujson to simplejson
Additionally, temporarily set build-monasca-docker-image as non-voting
due to problems with buggy confluent-kafka 1.4.0 release, which prevents
building the Docker image.

Change-Id: I561ea633a09eb3d7468d2d55aa46d6fb3b2380ff
Story: 2007549
Task: 39390
2020-04-18 10:42:39 +02:00
Doug Szumski efc6e28edc Fix periodic notifications for webhooks
- Removes the hard-coded magic number of 60 seconds allowing users to
  choose the period that they require.
- Standardise on strings for DictOpt dict keys. When loaded from a config
  file, the DictOpt keys are parsed as strings, which was conflicting with
  the default integer dict keys. This caused the periodic engine to silently
  fail to load when configured via a config file.
- Remove unused variable

Story: 2006783
Task: 37313
Change-Id: Ibd61c45fc1ade37022150d34a5b00c56fdf69814
2019-12-11 11:13:17 +00:00
Zuul d91ceee414 Merge "Use Confluent Kafka client" 2019-09-26 09:51:33 +00:00
Witek Bedyk d47bbae4e8 Use Confluent Kafka client
The change introduces the possibility to run the persister with the new
confluent-kafka client. It has to be enabled in the configuration file.

Story: 2003705
Task: 35858

Depends-On: https://review.opendev.org/675297
Change-Id: I8d9e173e9a252712fb285c0676c26334e1f677a7
2019-09-19 15:09:23 +02:00
Doug Szumski 39a906b8fb Templates for Slack notifications
This change adds an optional, user configurable template which
may be used to format the text contained in Slack notifications.

Story: 2001308
Task: 5859
Change-Id: Id936c3dc8b4f3e2430de20c8b69d0e703b1cf9ef
2019-05-02 09:49:42 +01:00
Zuul 7d43228214 Merge "Update hacking version to latest" 2019-02-11 13:20:31 +00:00
melissaml 226a070b4a Update hacking version to latest
Story: 2004930
Task: 29317

Change-Id: I8d7ad198599943fc23a8a55d25eab672c096725d
2019-02-08 15:49:23 +01:00
Joe Keen 1d680f1739 Make default notifiers pluggable
Erasing distinction between plugins that are an inherent part of the
notification engine and plugins that can be specified via the config file.
Fixing broken tests.

Story: 2003801
Task: 26532
Change-Id: I360cc2ad0782f209606706bf1869570fdae2260d
2019-01-17 11:58:45 +01:00
Jui Chandwaskar d396753a83 Update pep8 checks
* Set max line length to 100
* Clean up code for pep8 checks

Change-Id: Ie00dc204f522fb2112f02f4151ec8a15d5523459
Signed-off-by: Jui Chandwaskar <jchandwaskar@op5.com>
2018-04-11 14:16:27 +02:00
Vu Cong Tuan 8b6260e10f Use assertRegex instead of assertRegexpMatches
In Python3, assertRegexpMatches & assertNotRegexpMatches
are deprecated in favor of assertRegex and assertNotRegex

Change-Id: I52b84fd49bed43902f0a57983710c0fb08649b12
2017-11-07 14:52:35 +07:00
Tomasz Trębski e1a9b9a96a Integrate with oslo.conf and oslo.log
Change upgrades the monasca-notification to leverage
the capabilities of both oslo.log and oslo.conf:

- configuration of logging separated from application settings
- ability to enforce data types for application settings
- ability to use oslo.config-generator capabilities
- automatic configuration parsing done by oslo.cfg

That change will bring it closer to the rest of monasca
components where such transition has happened already.
However, in the rest of monasca, oslo.cfg was partially
or fully implemented whereas monasca-notification has
been relying on YAML based configuration file.

Therefore backward compatybility for such format will
be kept for now.

Story: 2000959
Task: 4093
Task: 4092

Change-Id: Ia75c3b60d0fada854178f21ca5ccb9e6a880f37f
2017-10-20 09:32:11 +02:00
Jenkins fb535756d7 Merge "Added a field 'Grafana Url' in the email" 2017-09-01 09:19:03 +00:00
Georgia-Anna Farmaki 347606ac54 Added a field 'Grafana Url' in the email
Retrieve the grafana_url field from notification.yaml
and append the query for metric info and timestamp.

Unit tests for method get_link_url,
adjust existing unit tests, python3 tests.

Change-Id: Ie0e98f3df48eb68caad232e5b9293222d7c946c8
Story: 2001052
Task: 4652
2017-08-28 11:32:14 +02:00
Jenkins 20479d1c1d Merge "Fix slack notification" 2017-08-08 03:55:57 +00:00
Haruki Yamanashi 68a6a8319b Send notification to Jira in custom description
This change makes possible to send notification to Jira
in custom description (e.g. AlarmID)

Change-Id: Ib7f9a438a27f29b17967c31922391d76f8f0092f
2017-07-26 14:24:21 +09:00
Haruki Yamanashi 0b82639af0 Fix typo and add configuration example for Jira
Change-Id: Ic304bfff6258126a439dee58b722c773bcfa8c57
2017-07-26 09:23:58 +09:00
Koji Nakazono 4cfcf0803f Fix slack notification
This patch fixes 2 issues in slack notification.
First, incoming webhook supports the JSON request, however Slack
API to post a message to chat doesn't support JSON request.
Change to use "data" for posting a message to chat.
Second, incoming webhook returns the response as text.
Change to check the content type of response before parsing it.

Change-Id: Ic81cc1d99496774a16f91569022d5e4fe0aff795
Story: 2001041
Task: 4597
2017-07-25 15:17:19 +09:00
Haruki Yamanashi 46a36adde0 Add unit test for Jira
Add unit test for Jira notifier which achieves 100% coverage.

Change-Id: Iae22a35a5bec5f173c3fae60df393d55b805e0fb
2017-07-19 16:58:24 +09:00
Tomasz Trębski fe78b6d698 Make monasca-notification Py35 compatible
Adjust the monasca-notification to run
under Python3.5

Story: 2000975
Task: 4130

Change-Id: I3bf2725fb2904374d7bae51ebf061a47dcbef0c0
2017-07-18 13:31:41 +02:00
Koji Nakazono 46b9afd03c Fix insert notification type of ORM
This patch fixes insert_notification_method_types of ORM.

Change-Id: I944f7cea583dd56cd1c777b1633498dde2abd31b
Story: 2001069
Task: 4685
2017-06-22 09:04:09 +09:00
Tomasz Trębski c9f0a8e63c Enable Py35 tests to run
Python3.5 tests were not running because Python3 has not
Queue module (instead have queue module). Commit
does not fix failing tests but gives an insight in what
exactly is failing and allows to fix them in future.

Also applied sixer utility to fix common Py2-Py3 compatybility
issues.

Additionally:
* removed unconstrained mysql and psycopg drivers from tox.ini.
  Instead added them to test-requirements to be picked up
  by requirements bot. That also allowed to remove 3 tox
  environments.
* added removing .testrepository/times.dbm (may cause py3 environment
  to fail if present)

Change-Id: I9bcc33dad80fdfbf60d95c4bb0ce7f79f642a414
2017-04-07 19:15:10 +00:00
Brad Klein 833aad71e8 Enhance hipchat plugin to color-code messages by alarm severity
Change-Id: Ic63d130c8545144be17f4be2faecf5c3b63375be
2017-01-25 10:08:55 -07:00
Artur Basiak eb6a5a487b Remove plugins from possible notifiers
Remove plugins keyword from possible notifiers. Monasca notification
was throwing a warning: "No notifiers found for plugins" if
plugins section was defined in notification_types.

Change-Id: I7ccacba0624322bf912bbb088ed7c993ed32db02
2017-01-24 06:46:12 +01:00
Artur Basiak 722ecaa7a5 Add config option for statsd
Add new section to config file with configuration for statsd
host and port. Add modification in notification engines.
According to the monasca-agent change:
https://review.openstack.org/#/c/381417

Change-Id: I6e99bae5e50f3670ae8b4a0c7ac5af3c747bcd68
2016-12-02 07:10:52 +01:00
Cao Xuan Hoang 69f4c2b8e3 Clean imports in code
This patch set modifies lines which are importing objects
instead of modules. As per openstack import guide lines, user should
import modules in a file not objects.

http://docs.openstack.org/developer/hacking/#imports

Change-Id: I3c5c7368fb006f3691d07cef9557c20a42cc5b76
2016-10-06 15:27:06 +07:00
Michael James Hoppal 063c4f1d1d Query database to see if the periodic notificiation changes
Also added notification id to notification object we construct in the
alarm processor

Change-Id: I6ccfffc9102bec8f670df13268e244cb0c998950
2016-08-29 15:11:20 -06:00
haali1 be6fb21e19 Add HipChat and Slack Notification types
This patch
   1. Supports for loading new notification types as plugins.
   2) Adds new plugins for HipChat and Slack
   3) Insert Notification types during startup

Partially-implements: blueprint notification-engine-plugin
Change-Id: I246ced3fe22a9797a3c8384f7bda166797cfac3a
2016-07-29 07:59:32 -07:00
Michael James Hoppal 79189ca811 Adding support for periodic notifications
New periodic notification engine that will take a notification send it, and then
place it back onto the periodic notification topic. Once the alarm associated
with the notification has transitioned to a state that is different from the
original state the notification is removed from the queue.

Change-Id: Ie3103a0ec30abcd8dfc53869b1c3135953aabf3a
2016-05-09 08:18:11 -06:00
bklei f333f92709 Support dynamic mysql port via config file
This is necessary in some installations to specify a non-default
mysql port (something other than 3306).  All of the other monasca
packages allow overriding this in the config file, this change
brings monasca-notification inline with the others.

Change-Id: Ibe6ffca9e5adb13e44594531358e2a8e5da46b9d
2016-03-02 09:06:24 -07:00
Ryan Brandt c050ce0843 Remove limit on dimension sets in email
Change-Id: Ifbc77fb06bb76e717d5f5593120829e0ebd413f6
2016-02-09 08:43:37 -07:00
Ryan Brandt 97a401027a Change email notification format
Add severity to the subject line
Add up to 10 unique dimension sets in body
Add link and lifecycle state to email body

Change-Id: I85e2e9f2382c6ebadde072967e098e8109f65bfe
2016-01-29 16:42:56 -07:00
Michal Zielonka 94f5bdbd62 Migrate from MysqlDB to pymysql
Change-Id: I61b7a35badaa4a3480a1c786152b07c17a99bf80
2015-12-16 09:51:28 +01:00
Joe Keen 82ae201cc4 Fixed mysql reconnect on error
Change-Id: I4bb502b295ee9f5d748bb11eadeae7392235981c
2015-08-21 14:37:53 -06:00
Michal Zielonka a82a49a1e8 Add configurable database setting (mysql, postgres, orm)
We used sqlalchemy.core for execute query for orm.
The configuration of db is based on monasca-api.
The default mode is mysql connection so we can use old configuration.

Change-Id: Iebb4d6dfca6d43298ced407178e7f9673a83a7ca
2015-08-04 22:34:57 +02:00
Maciej Maciaszek 28a686d7eb Add fix for local time bug
The test 'test_old_timestamp' was not able to pass in different
timezones due to hardcoded expected datetime

Change `test_alarm_processor.py` permissions

`test_alarm_processor.py` had different permissions than other test
files. While `unittest` module could collect tests in this file,
nosetests could't do it. Nose can collect tests in this file after
permissions change

Change-Id: I2b5791e7b352fbb0c05bc665b4000c412b63f1ef
2015-07-01 09:15:28 +02:00
Ryan Brandt 36b37c2120 Add unicode support to email notifications
Change-Id: I82a869a57781c19a041a5ca4a71d35e83daaf18d
2015-04-30 09:34:00 -06:00
Craig Bryant c4b469c11d AlarmStateTransitionedEvent timestamp now in ms
This will ensure a unique timestamp. Influx V9 will only keep one
entry with the same timestamp

Some of the tests weren't using a numerica timestamp which caused
problems when the code tried to divide the timestamp by 1000

Change-Id: Ie0fefc61abe9a95503fa7611971a21ed2cb56224
2015-04-16 13:31:40 -06:00
Victor Ion Munteanu 930e0dab10 More information sent through webhook
Change-Id: Ic8316064c0a87c8342db3ee76a5104df394db4b5
2015-04-15 09:25:25 +02:00
Joe Keen a17ecfb603 Email notifier returns false if self._smtp == None
When an email notifier is created and the initial smtp connection fails the
self._smtp variable is left set to None.  Now we detect that and try to
reconnect.

Change-Id: Ifbc30ee5339722357d86214b4d8c84e64dd703f7
2015-02-18 17:31:29 -07:00
Joe Keen 9f0e65028f Added retry engine to notification system
Change-Id: Iea1a05c1b7336b9e3e8aeb972e0f9ba1b7f74d69
2015-02-09 11:40:02 -07:00
Joe Keen 3eb169fac3 Notification engine refactored from many processes to one
Squished the notification down to one process in preparation for making
multiple engine instances able to talk to the same topic.

Added HA capabilities to the KafkaConsumer object.

Change-Id: Id4799d690c7caf10ae7ba89c2d4e0aeb76c54375
2015-01-30 11:59:57 -07:00
Joe Keen ebc1ed72d6 Refactored notification engine types
Added more test coverage for email notifications.

Moved notification methods from notification_processor to new types directory.

types/interface.py now automatically records statsd information for configured
types.

Configuration for a type is now optional.  Uncofigured types are not able to
send notifications.  Notifications that come across for unconfigured types
generate a warning.

Email notification type now explicity exits when unable to connect to an SMTP
server.

Change-Id: I213d815965761736eb3680b5e14206ba7bef7e90
2015-01-21 10:07:00 -07:00
Joe Keen 45a2411ebb Added pagerduty support to notification_processor
Refactored the tests to make pagerduty functionality more clear

Change-Id: Ie9616d8629112fc5f1f1576951a3cbe3b99218b0
2015-01-05 17:20:55 -07:00
Joe Keen 70f24b2034 Webhook now passes alarm_id instead of alarm_name
Change-Id: I3b7606e9584066edcbeb99cb3fe0ff308114b436
2014-12-16 15:17:36 -07:00
Joe Keen f0b4f91960 Added timeout to webhook
Added a timeout keyword to requests.post that we use to send webhooks.  Updated
the tests to verify that the webhook will properly time out.

Change-Id: I27140a8c13afcd8f2e30ea1367f0bd9f4944ba36
2014-12-12 15:42:03 -07:00