alerta / alerta-contrib

Contributed integrations, plugins and custom webhooks
http://alerta.io
MIT License
119 stars 170 forks source link

Filtering in forward plugin #392

Closed micwiel closed 1 year ago

micwiel commented 1 year ago

Is your feature request related to a problem? Please describe. My company is using few notification tools depending on team and use case. Configuring the same rules is impossible for different alerta plugins for example slack configuration is completely different than pagerduty one etc.

Describe the solution you'd like I would like to have 2 alerta components, let's name them alerta-ui and alerta-notify. First one is the main alerta, with dashboard for users, blackouts management, the place where all alerts coming in etc. The second one is alerta responsible for sending notifications to external integrations. I would like to forward some subset of alerts based on some criteria like environment, severity etc respecting blackouts from first alerta to second one (and third and fourth... depending on the needs). It will move filtering logic out of plugins configuration and will introduce high flexibility regarding using different notification channels for different purposes.

Describe alternatives you've considered Tried to configure all plugins separately but failed. Don't see how to achieve the flexibility using current version of alerta.

satterly commented 1 year ago

Please take a look at this tutorial on plugin "routing" and let me know if that helps. Thanks.

https://docs.alerta.io/gettingstarted/tutorial-3-plugins.html#step-3-route-alerts-to-plugins

micwiel commented 1 year ago

Hi @satterly thanks for your reply. Looks like your solution will fit. However I tried implement it and it doesn't work as expected. Finally I even used your example plugin and still no success. My Dockerfile

FROM alerta/alerta-web:8.7.0

RUN /venv/bin/pip install git+https://github.com/alerta/alerta.git#subdirectory=contrib/routing/

Using this alert https://docs.alerta.io/api/reference.html#example-request Sending with severity changed to debug - OK Sending with malformed environment and original severity - expect to reject but unfortunately it is accepted

Error in logs

2023-03-24 08:19:37,717 DEBG 'uwsgi' stdout output:
2023-03-24 08:19:37,717 alerta.plugins[49]: [WARNING] Plugin routing rules failed: 'reject' request_id=7333dd78-31ad-460f-82d6-5e46b55d7907 ip=<redacted>

Nothing else related despite I have

        - name: DEBUG
          value: True

Similar problem I have when use 9.0.0 version of alerta base image.

micwiel commented 1 year ago

Ok, looks like some strange edge-case in my configuration. Problem with routing plugin resolved.

Good job @satterly, your approach meets expectations. Nevertheless whole solution is not intuitive for less experienced alerta users, even though everything is documented I was using wrong keywords during searching alerta documentation and didn't find it without your help. Moreover it requires rebuilding alerta, it is not out-of-the-box solution with just playing with the configuration. Since you have prepared and documented this solution I guess it is quite common use-case for alerta users. I'm closing this ticket as the initial problem is resolved but maybe it is worth considering to either add more examples to the documentation what use-cases could be addressed by it or even create possibility to achieve the same effect just by changing some of the configuration settings, without necessity to rebuild anything or creating custom images. Cheers!