[BUG] AttributeError: 'KeyError' object has no attribute 'code'
Giancarlo1974 opened this issue · 3 comments
I use rancher-alerting-drivers-prom2teams
Today the pod doesn't send alert do Teams
In the POD i see these logs:
`
2022-02-14 13:04:21,619 - flask.app - ERROR - Exception on /v2/msteams-alert-common [POST]
Mon, Feb 14 2022 2:04:21 pm | Traceback (most recent call last):
Mon, Feb 14 2022 2:04:21 pm | File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 2292, in wsgi_app
Mon, Feb 14 2022 2:04:21 pm | response = self.full_dispatch_request()
Mon, Feb 14 2022 2:04:21 pm | File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1815, in full_dispatch_request
Mon, Feb 14 2022 2:04:21 pm | rv = self.handle_user_exception(e)
Mon, Feb 14 2022 2:04:21 pm | File "/usr/local/lib/python3.8/site-packages/flask_restplus/api.py", line 583, in error_router
Mon, Feb 14 2022 2:04:21 pm | return original_handler(e)
Mon, Feb 14 2022 2:04:21 pm | File "/usr/local/lib/python3.8/site-packages/flask_restplus/api.py", line 583, in error_router
Mon, Feb 14 2022 2:04:21 pm | return original_handler(e)
Mon, Feb 14 2022 2:04:21 pm | File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1718, in handle_user_exception
Mon, Feb 14 2022 2:04:21 pm | reraise(exc_type, exc_value, tb)
Mon, Feb 14 2022 2:04:21 pm | File "/usr/local/lib/python3.8/site-packages/flask/_compat.py", line 35, in reraise
Mon, Feb 14 2022 2:04:21 pm | raise value
Mon, Feb 14 2022 2:04:21 pm | File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1813, in full_dispatch_request
Mon, Feb 14 2022 2:04:21 pm | rv = self.dispatch_request()
Mon, Feb 14 2022 2:04:21 pm | File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1799, in dispatch_request
Mon, Feb 14 2022 2:04:21 pm | return self.view_functionsrule.endpoint
Mon, Feb 14 2022 2:04:21 pm | File "/usr/local/lib/python3.8/site-packages/flask_restplus/api.py", line 325, in wrapper
Mon, Feb 14 2022 2:04:21 pm | resp = resource(*args, **kwargs)
Mon, Feb 14 2022 2:04:21 pm | File "/usr/local/lib/python3.8/site-packages/flask/views.py", line 88, in view
Mon, Feb 14 2022 2:04:21 pm | return self.dispatch_request(*args, **kwargs)
Mon, Feb 14 2022 2:04:21 pm | File "/usr/local/lib/python3.8/site-packages/flask_restplus/resource.py", line 44, in dispatch_request
Mon, Feb 14 2022 2:04:21 pm | resp = meth(*args, **kwargs)
Mon, Feb 14 2022 2:04:21 pm | File "/usr/local/lib/python3.8/site-packages/prom2teams/app/versions/v2/namespace.py", line 27, in post
Mon, Feb 14 2022 2:04:21 pm | self.sender.send_alerts(alerts, app.config['MICROSOFT_TEAMS'][connector])
Mon, Feb 14 2022 2:04:21 pm | File "/usr/local/lib/python3.8/configparser.py", line 1254, in getitem
Mon, Feb 14 2022 2:04:21 pm | raise KeyError(key)
Mon, Feb 14 2022 2:04:21 pm | KeyError: 'msteams-alert-common'
Mon, Feb 14 2022 2:04:21 pm | 2022-02-14 13:04:21,619 - prom2teams_app - ERROR - An unhandled exception occurred. 'msteams-alert-common'
Mon, Feb 14 2022 2:04:21 pm | Traceback (most recent call last):
Mon, Feb 14 2022 2:04:21 pm | File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 2292, in wsgi_app
Mon, Feb 14 2022 2:04:21 pm | response = self.full_dispatch_request()
Mon, Feb 14 2022 2:04:21 pm | File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1815, in full_dispatch_request
Mon, Feb 14 2022 2:04:21 pm | rv = self.handle_user_exception(e)
Mon, Feb 14 2022 2:04:21 pm | File "/usr/local/lib/python3.8/site-packages/flask_restplus/api.py", line 583, in error_router
Mon, Feb 14 2022 2:04:21 pm | return original_handler(e)
Mon, Feb 14 2022 2:04:21 pm | File "/usr/local/lib/python3.8/site-packages/flask_restplus/api.py", line 583, in error_router
Mon, Feb 14 2022 2:04:21 pm | return original_handler(e)
Mon, Feb 14 2022 2:04:21 pm | File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1718, in handle_user_exception
Mon, Feb 14 2022 2:04:21 pm | reraise(exc_type, exc_value, tb)
Mon, Feb 14 2022 2:04:21 pm | File "/usr/local/lib/python3.8/site-packages/flask/_compat.py", line 35, in reraise
Mon, Feb 14 2022 2:04:21 pm | raise value
Mon, Feb 14 2022 2:04:21 pm | File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1813, in full_dispatch_request
Mon, Feb 14 2022 2:04:21 pm | rv = self.dispatch_request()
Mon, Feb 14 2022 2:04:21 pm | File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1799, in dispatch_request
Mon, Feb 14 2022 2:04:21 pm | return self.view_functionsrule.endpoint
Mon, Feb 14 2022 2:04:21 pm | File "/usr/local/lib/python3.8/site-packages/flask_restplus/api.py", line 325, in wrapper
Mon, Feb 14 2022 2:04:21 pm | resp = resource(*args, **kwargs)
Mon, Feb 14 2022 2:04:21 pm | File "/usr/local/lib/python3.8/site-packages/flask/views.py", line 88, in view
Mon, Feb 14 2022 2:04:21 pm | return self.dispatch_request(*args, **kwargs)
Mon, Feb 14 2022 2:04:21 pm | File "/usr/local/lib/python3.8/site-packages/flask_restplus/resource.py", line 44, in dispatch_request
Mon, Feb 14 2022 2:04:21 pm | resp = meth(*args, **kwargs)
Mon, Feb 14 2022 2:04:21 pm | File "/usr/local/lib/python3.8/site-packages/prom2teams/app/versions/v2/namespace.py", line 27, in post
Mon, Feb 14 2022 2:04:21 pm | self.sender.send_alerts(alerts, app.config['MICROSOFT_TEAMS'][connector])
Mon, Feb 14 2022 2:04:21 pm | File "/usr/local/lib/python3.8/configparser.py", line 1254, in getitem
Mon, Feb 14 2022 2:04:21 pm | raise KeyError(key)
Mon, Feb 14 2022 2:04:21 pm | KeyError: 'msteams-alert-common'
Mon, Feb 14 2022 2:04:21 pm | 2022-02-14 13:04:21,622 - werkzeug - INFO - 10.42.0.66 - - [14/Feb/2022 13:04:21] "POST /v2/msteams-alert-common HTTP/1.1" 500 -
Mon, Feb 14 2022 2:04:21 pm | 2022-02-14 13:04:21,633 - werkzeug - ERROR - Error on request:
Mon, Feb 14 2022 2:04:21 pm | Traceback (most recent call last):
Mon, Feb 14 2022 2:04:21 pm | File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 2292, in wsgi_app
Mon, Feb 14 2022 2:04:21 pm | response = self.full_dispatch_request()
Mon, Feb 14 2022 2:04:21 pm | File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1815, in full_dispatch_request
Mon, Feb 14 2022 2:04:21 pm | rv = self.handle_user_exception(e)
Mon, Feb 14 2022 2:04:21 pm | File "/usr/local/lib/python3.8/site-packages/flask_restplus/api.py", line 583, in error_router
Mon, Feb 14 2022 2:04:21 pm | return original_handler(e)
Mon, Feb 14 2022 2:04:21 pm | File "/usr/local/lib/python3.8/site-packages/flask_restplus/api.py", line 583, in error_router
Mon, Feb 14 2022 2:04:21 pm | return original_handler(e)
Mon, Feb 14 2022 2:04:21 pm | File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1718, in handle_user_exception
Mon, Feb 14 2022 2:04:21 pm | reraise(exc_type, exc_value, tb)
Mon, Feb 14 2022 2:04:21 pm | File "/usr/local/lib/python3.8/site-packages/flask/_compat.py", line 35, in reraise
Mon, Feb 14 2022 2:04:21 pm | raise value
Mon, Feb 14 2022 2:04:21 pm | File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1813, in full_dispatch_request
Mon, Feb 14 2022 2:04:21 pm | rv = self.dispatch_request()
Mon, Feb 14 2022 2:04:21 pm | File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1799, in dispatch_request
Mon, Feb 14 2022 2:04:21 pm | return self.view_functionsrule.endpoint
Mon, Feb 14 2022 2:04:21 pm | File "/usr/local/lib/python3.8/site-packages/flask_restplus/api.py", line 325, in wrapper
Mon, Feb 14 2022 2:04:21 pm | resp = resource(*args, **kwargs)
Mon, Feb 14 2022 2:04:21 pm | File "/usr/local/lib/python3.8/site-packages/flask/views.py", line 88, in view
Mon, Feb 14 2022 2:04:21 pm | return self.dispatch_request(*args, **kwargs)
Mon, Feb 14 2022 2:04:21 pm | File "/usr/local/lib/python3.8/site-packages/flask_restplus/resource.py", line 44, in dispatch_request
Mon, Feb 14 2022 2:04:21 pm | resp = meth(*args, **kwargs)
Mon, Feb 14 2022 2:04:21 pm | File "/usr/local/lib/python3.8/site-packages/prom2teams/app/versions/v2/namespace.py", line 27, in post
Mon, Feb 14 2022 2:04:21 pm | self.sender.send_alerts(alerts, app.config['MICROSOFT_TEAMS'][connector])
Mon, Feb 14 2022 2:04:21 pm | File "/usr/local/lib/python3.8/configparser.py", line 1254, in getitem
Mon, Feb 14 2022 2:04:21 pm | raise KeyError(key)
Mon, Feb 14 2022 2:04:21 pm | KeyError: 'msteams-alert-common'
Mon, Feb 14 2022 2:04:21 pm |
Mon, Feb 14 2022 2:04:21 pm | During handling of the above exception, another exception occurred:
Mon, Feb 14 2022 2:04:21 pm |
Mon, Feb 14 2022 2:04:21 pm | Traceback (most recent call last):
Mon, Feb 14 2022 2:04:21 pm | File "/usr/local/lib/python3.8/site-packages/werkzeug/serving.py", line 306, in run_wsgi
Mon, Feb 14 2022 2:04:21 pm | execute(self.server.app)
Mon, Feb 14 2022 2:04:21 pm | File "/usr/local/lib/python3.8/site-packages/werkzeug/serving.py", line 294, in execute
Mon, Feb 14 2022 2:04:21 pm | application_iter = app(environ, start_response)
Mon, Feb 14 2022 2:04:21 pm | File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 2309, in call
Mon, Feb 14 2022 2:04:21 pm | return self.wsgi_app(environ, start_response)
Mon, Feb 14 2022 2:04:21 pm | File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 2295, in wsgi_app
Mon, Feb 14 2022 2:04:21 pm | response = self.handle_exception(e)
Mon, Feb 14 2022 2:04:21 pm | File "/usr/local/lib/python3.8/site-packages/flask_restplus/api.py", line 583, in error_router
Mon, Feb 14 2022 2:04:21 pm | return original_handler(e)
Mon, Feb 14 2022 2:04:21 pm | File "/usr/local/lib/python3.8/site-packages/flask_restplus/api.py", line 583, in error_router
Mon, Feb 14 2022 2:04:21 pm | return original_handler(e)
Mon, Feb 14 2022 2:04:21 pm | File "/usr/local/lib/python3.8/site-packages/flask/app.py", line 1748, in handle_exception
Mon, Feb 14 2022 2:04:21 pm | return self.finalize_request(handler(e), from_error_handler=True)
Mon, Feb 14 2022 2:04:21 pm | File "/usr/local/lib/python3.8/site-packages/prom2teams/app/api.py", line 32, in error_handler
Mon, Feb 14 2022 2:04:21 pm | return str(e), e.code
Mon, Feb 14 2022 2:04:21 pm | AttributeError: 'KeyError' object has no attribute 'code'
`
L'alert via mail run correctly
These are the labels
Labels
alertname = Some clusters
cluster = tsm-dev
code = c-7c7cv
container = pushgateway
endpoint = http
job = rancher+central+monitoring
message = node: trr-tsm-kd4 Drain failed: drain did not complete within 120s
namespace = cattle-monitoring-system
pod = prometheus-pushgateway-58d84867db-kcr4d
prometheus = cattle-monitoring-system/rancher-monitoring-prometheus
service = prometheus-pushgateway
severity = critical
Occurs when the rancher-alerting-drivers-prom2teams configMap is configured incorrectly:
The [Microsoft Teams] section is missing.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.