0
0
Fork 0
mirror of https://github.com/alerta/alerta.git synced 2025-01-24 17:29:39 +00:00
alerta_alerta/examples/backends/custom/package/base.py
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

12 lines
419 B
Python

from alerta.database.backends.postgres import Backend as PGBackend
class Backend(PGBackend):
def create_engine(self, app, uri, dbname=None, raise_on_error=True):
uri = f"postgresql://{uri.split('://')[1]}"
super().create_engine(app, uri, dbname, raise_on_error)
def create_alert(self, alert):
alert.attributes['custom_attribute'] = 'value'
return super().create_alert(alert)