Development

Python SDK

Alerta is developed in Python so the Python SDK is a core component of the monitoring system.

Installation

Install using pip:

$ pip install alerta

Install master branch directly from GitHub:

$ pip install git+https://github.com/alerta/python-alerta-client.git@master

Examples

Initialise the alerta API client:

>>> from alertaclient.api import Client
>>> client = Client(endpoint='https://api.alerta.dev/', key='demo-key')

Send an alert:

>>> client.send_alert(resource='foo', event='bar')
...
alertaclient.exceptions.UnknownError: [POLICY] Alert environment does not match one of Production, Development

Send an alert again, this time including the required environment and service:

>>> client.send_alert(resource='foo', event='bar', environment='Development', service=['Web'])
('fd3ecad4-6558-4ec7-96cc-aff6cdf1fabc', Alert(id='fd3ecad4-6558-4ec7-96cc-aff6cdf1fabc', environment='Development', resource='foo', event='bar', severity='normal', status='closed', customer=None), None)

Query for the alert just sent, by alert ID:

>>> client.get_alert('fd3ecad4-6558-4ec7-96cc-aff6cdf1fabc')
Alert(id='fd3ecad4-6558-4ec7-96cc-aff6cdf1fabc', environment='Development', resource='foo', event='bar', severity='normal', status='closed', customer=None)

Search for alerts by attributes:

>>> client.get_alerts([('resource','foo'),('environment','Development')])
[Alert(id='fd3ecad4-6558-4ec7-96cc-aff6cdf1fabc', environment='Development', resource='foo', event='bar', severity='normal', status='closed', customer=None)]

Send a heartbeat:

>>> client.heartbeat(origin='baz')
Heartbeat(id='98c220e6-5148-4b19-8ae8-e1c078b7d68c', origin='baz', create_time=datetime.datetime(2018, 9, 6, 8, 48, 48, 817000), timeout=86400, customer=None)

For more details, visit the Alerta Python SDK page.

Ruby SDK

The Ruby SDK is a work-in-progress. For more details, visit the Alerta Ruby SDK page.

Haskell SDK

This SDK supplies bindings to the Alerta REST API so that it can be used from Haskell.

For more details, visit the Haskell Package page.

Gource Visualization

View the development of Alerta over the years as an animated tree Gource visualization.