mirror of
https://github.com/alerta/alerta-contrib.git
synced 2025-03-16 05:23:28 +00:00
Update normalise plugin and add README
This commit is contained in:
parent
025c59e092
commit
0fd64a18c5
2 changed files with 70 additions and 0 deletions
plugins/normalise
63
plugins/normalise/README.md
Normal file
63
plugins/normalise/README.md
Normal file
|
@ -0,0 +1,63 @@
|
|||
Normalise Plugin (Example)
|
||||
==========================
|
||||
|
||||
This is an example plugin that demonstrates how plugins can be used
|
||||
to "normalise" alerts from different monitoring sources to ensure
|
||||
they conform to a standard before being saved to the database.
|
||||
|
||||
Normalise actions:
|
||||
|
||||
* two alert attributes are checked for values and if no value is set they are assigned default values.
|
||||
* alert text is modified to prepend the severity level in capitals.
|
||||
|
||||
This repo should be forked or copied and the python plugin modified to suit
|
||||
the specific Alerta environment.
|
||||
|
||||
For help, join [](https://gitter.im/alerta/chat)
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
Clone the GitHub repo and run:
|
||||
|
||||
$ python setup.py install
|
||||
|
||||
Or, to install remotely from GitHub run:
|
||||
|
||||
$ pip install git+https://github.com/alerta/alerta-contrib.git#subdirectory=plugins/normalise
|
||||
|
||||
Note: If Alerta is installed in a python virtual environment then plugins
|
||||
need to be installed into the same environment for Alerta to dynamically
|
||||
discover them.
|
||||
|
||||
Configuration
|
||||
-------------
|
||||
|
||||
Add `normalise` to the list of enabled `PLUGINS` in `alertad.conf` server
|
||||
configuration file and set plugin-specific variables either in the
|
||||
server configuration file or as environment variables.
|
||||
|
||||
**Example**
|
||||
|
||||
```python
|
||||
PLUGINS = ['reject','normalise']
|
||||
```
|
||||
|
||||
Troubleshooting
|
||||
---------------
|
||||
|
||||
Restart Alerta API and confirm that the plugin has been loaded and enabled.
|
||||
|
||||
Set `DEBUG=True` in the `alertad.conf` configuration file and look for log
|
||||
entries similar to below:
|
||||
|
||||
|
||||
References
|
||||
----------
|
||||
|
||||
* Normalize Monitoring Traps: https://docops.ca.com/ca-service-operations-insight/3-2/en/administrating/event-management/event-management-example-scenarios/event-management-example-5-normalize-monitoring-traps
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
Copyright (c) 2016 Nick Satterly. Available under the MIT License.
|
|
@ -11,8 +11,15 @@ class NormaliseAlert(PluginBase):
|
|||
|
||||
LOG.info("Normalising alert...")
|
||||
|
||||
# prepend severity to alert text
|
||||
alert.text = '%s: %s' % (alert.severity.upper(), alert.text)
|
||||
|
||||
# supply different default values if missing
|
||||
if not alert.group or alert.group == 'Misc':
|
||||
alert.group = 'Unknown'
|
||||
if not alert.value or alert.value == 'n/a':
|
||||
alert.value = '--'
|
||||
|
||||
return alert
|
||||
|
||||
def post_receive(self, alert):
|
||||
|
|
Loading…
Reference in a new issue