0
0
mirror of https://github.com/alerta/alerta.git synced 2024-12-04 12:57:32 +00:00
alerta_alerta/examples/backends/custom
Víctor M. García Muñoz c794a04f00
Support custom backends defined as entry point (#1826)
* Support custom backends defined as entry point

A custom backend may be needed to support a different database or
to extend or modify current backends functionality.
With this modification, a custom backend can be defined using an
entry point to provide its module location.

* Change entry point name for custom backends and include an example
2023-03-09 18:27:53 +01:00
..
package Support custom backends defined as entry point (#1826) 2023-03-09 18:27:53 +01:00
README.md Support custom backends defined as entry point (#1826) 2023-03-09 18:27:53 +01:00
setup.py Support custom backends defined as entry point (#1826) 2023-03-09 18:27:53 +01:00

Custom backends example

Provided example consists of a database backend based on standard PostgreSQL backend.

It has a very basic functionality, adding an attribute to the alert before storing it in the database. This functionality can be achieved using plugins, it is just an example.

Custom backends must provide a class named 'Backend' that implements alerta.database.base.Backend.

The module providing that class must be referenced as an 'alerta.database.backends' entry-point in python package setup.

   ...
    entry_points={
        'alerta.database.backends': [
            'custom = package'
        ]
    }
    ...

To use the custom database backend, the name used for the entry-point has to be used as schema in DATABASE_URL configuration setting:

DATABASE_URL = "custom://user@db_server/monitoring?connect_timeout=10&application_name=alerta"