alerta / alerta-contrib

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

Error while running action plugin 'alerta_prometheus': name 'USE_AM_EXTERNALURL_FOR_SILENCES' is not defined (500) #379

Open richardsavage opened 2 years ago

richardsavage commented 2 years ago

Issue Summary When using the prometheus plugin, I get an error, as mentionned in the title: Error while running action plugin 'alerta_prometheus': name 'USE_AM_EXTERNALURL_FOR_SILENCES' is not defined (500)

The problem seem to be this:

the variable set is: ALERTMANAGER_USE_EXTERNALURL_FOR_SILENCES = os.environ.get('ALERTMANAGER_USE_EXTERNALURL_FOR_SILENCES') or app.config.get('ALERTMANAGER_USE_EXTERNALURL_FOR_SILENCES',False)

but the plugin is looking for this:

        # if alertmanager is clustered behind a load balancer that mirrors requests we should prefer to create one silence
        # rather than many
        if USE_AM_EXTERNALURL_FOR_SILENCES:

I tried to change the condition to ALERTMANAGER_USE_EXTERNALURL_FOR_SILENCES and it seem to work fine so far

Environment

To Reproduce Steps to reproduce the behavior:

  1. Go to the web ui
  2. Try to ackonowledge an Alertmanager alert. '
  3. See error (include command output)

Traceback (most recent call last): File "/opt/alerta/lib64/python3.6/site-packages/flask/app.py", line 1516, in full_dispatch_request rv = self.dispatch_request() File "/opt/alerta/lib64/python3.6/site-packages/flask/app.py", line 1502, in dispatch_request return self.ensure_sync(self.view_functions[rule.endpoint])(req.view_args) File "/opt/alerta/lib64/python3.6/site-packages/flask_cors/decorator.py", line 128, in wrapped_function resp = make_response(f(*args, *kwargs)) File "/opt/alerta/lib64/python3.6/site-packages/alerta/auth/decorators.py", line 90, in wrapped return f(args, kwargs) File "/opt/alerta/lib64/python3.6/site-packages/alerta/models/metrics.py", line 258, in wrapped response = f(*args, *kwargs) File "/opt/alerta/lib64/python3.6/site-packages/alerta/utils/response.py", line 18, in decorated return func(args, **kwargs) File "/opt/alerta/lib64/python3.6/site-packages/alerta/views/alerts.py", line 173, in action_alert raise ApiError(str(e), 500)

Traceback (most recent call last): File "/opt/alerta/lib64/python3.6/site-packages/flask/app.py", line 1516, in full_dispatch_request rv = self.dispatch_request() File "/opt/alerta/lib64/python3.6/site-packages/flask/app.py", line 1502, in dispatch_request return self.ensure_sync(self.view_functions[rule.endpoint])(req.view_args) File "/opt/alerta/lib64/python3.6/site-packages/flask_cors/decorator.py", line 128, in wrapped_function resp = make_response(f(*args, *kwargs)) File "/opt/alerta/lib64/python3.6/site-packages/alerta/auth/decorators.py", line 90, in wrapped return f(args, kwargs) File "/opt/alerta/lib64/python3.6/site-packages/alerta/models/metrics.py", line 258, in wrapped response = f(*args, *kwargs) File "/opt/alerta/lib64/python3.6/site-packages/alerta/utils/response.py", line 18, in decorated return func(args, **kwargs) File "/opt/alerta/lib64/python3.6/site-packages/alerta/views/alerts.py", line 173, in action_alert raise ApiError(str(e), 500)

For web app issues, include any web browser JavaScript console errors.

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Additional context Add any other context about the problem here.

NOTE: Please provide as much information about your issue as possible. Failure to provide basic details about your specific environment make it impossible to know if an issue has already been fixed, can delay a response and may result in your issue being closed without a resolution.

micwiel commented 2 years ago

Bug seems to be fixed in https://github.com/alerta/alerta-contrib/pull/380/ but the fix is still unavailable in alerta docker image (currently latest=8.7.0) https://github.com/alerta/docker-alerta/releases. Please release new image version.