Closed decentral1se closed 4 years ago
Oh wait...
>>> api = Client(endpoint="http://localhost:8080/api", key="...mykey...")
>>> api.heartbeat("alerta-mailer/...mysmtphost...")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/venv/lib/python3.7/site-packages/alertaclient/api.py", line 211, in heartbeat
r = self.http.post('/heartbeat', data)
File "/venv/lib/python3.7/site-packages/alertaclient/api.py", line 515, in post
return self._handle_error(response)
File "/venv/lib/python3.7/site-packages/alertaclient/api.py", line 543, in _handle_error
raise UnknownError(resp['message'])
alertaclient.exceptions.UnknownError: Missing required scope: write:heartbeats
So, I had the wrong scope! I only gave "read". So, this is something that can be documented then if you'll accept the PR? We could also perhaps improve the error message for this heartbeats request error message?
However, the "Authentication failed" notice remains, so that now narrows it down to amqp or smtp... I will keep digging...
Aha,
>>> conn = Connection("mongodb://alerta:mypw@myhost/kombu")
>>> import mailer
>>> consumer = mailer.FanoutConsumer(connection=conn)
Traceback (most recent call last):
File "/venv/lib/python3.7/site-packages/kombu/transport/virtual/base.py", line 921, in create_channel
return self._avail_channels.pop()
IndexError: pop from empty list
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/venv/lib/python3.7/site-packages/kombu/utils/objects.py", line 42, in __get__
return obj.__dict__[self.__name__]
KeyError: 'client'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/venv/lib/python3.7/site-packages/mailer.py", line 91, in __init__
self.channel = self.connection.channel()
File "/venv/lib/python3.7/site-packages/kombu/connection.py", line 288, in channel
chan = self.transport.create_channel(self.connection)
File "/venv/lib/python3.7/site-packages/kombu/connection.py", line 839, in connection
self._connection = self._establish_connection()
File "/venv/lib/python3.7/site-packages/kombu/connection.py", line 794, in _establish_connection
conn = self.transport.establish_connection()
File "/venv/lib/python3.7/site-packages/kombu/transport/virtual/base.py", line 941, in establish_connection
self._avail_channels.append(self.create_channel(self))
File "/venv/lib/python3.7/site-packages/kombu/transport/virtual/base.py", line 923, in create_channel
channel = self.Channel(connection)
File "/venv/lib/python3.7/site-packages/kombu/transport/mongodb.py", line 120, in __init__
self.client
File "/venv/lib/python3.7/site-packages/kombu/utils/objects.py", line 44, in __get__
value = obj.__dict__[self.__name__] = self.__get(obj)
File "/venv/lib/python3.7/site-packages/kombu/transport/mongodb.py", line 359, in client
return self._create_client()
File "/venv/lib/python3.7/site-packages/kombu/transport/mongodb.py", line 351, in _create_client
database = self._open()
File "/venv/lib/python3.7/site-packages/kombu/transport/mongodb.py", line 310, in _open
version_str = mongoconn.server_info()['version']
File "/venv/lib/python3.7/site-packages/pymongo/mongo_client.py", line 1623, in server_info
session=session)
File "/venv/lib/python3.7/site-packages/pymongo/database.py", line 611, in command
read_preference) as (sock_info, slave_ok):
File "/usr/local/lib/python3.7/contextlib.py", line 112, in __enter__
return next(self.gen)
File "/venv/lib/python3.7/site-packages/pymongo/mongo_client.py", line 1101, in _socket_for_reads
with self._get_socket(server) as sock_info:
File "/usr/local/lib/python3.7/contextlib.py", line 112, in __enter__
return next(self.gen)
File "/venv/lib/python3.7/site-packages/pymongo/mongo_client.py", line 1058, in _get_socket
with server.get_socket(self.__all_credentials) as sock_info:
File "/usr/local/lib/python3.7/contextlib.py", line 112, in __enter__
return next(self.gen)
File "/venv/lib/python3.7/site-packages/pymongo/pool.py", line 1006, in get_socket
sock_info.check_auth(all_credentials)
File "/venv/lib/python3.7/site-packages/pymongo/pool.py", line 677, in check_auth
auth.authenticate(credentials, self)
File "/venv/lib/python3.7/site-packages/pymongo/auth.py", line 563, in authenticate
auth_func(credentials, sock_info)
File "/venv/lib/python3.7/site-packages/pymongo/auth.py", line 540, in _authenticate_default
return _authenticate_scram(credentials, sock_info, 'SCRAM-SHA-1')
File "/venv/lib/python3.7/site-packages/pymongo/auth.py", line 262, in _authenticate_scram
res = sock_info.command(source, cmd)
File "/venv/lib/python3.7/site-packages/pymongo/pool.py", line 579, in command
unacknowledged=unacknowledged)
File "/venv/lib/python3.7/site-packages/pymongo/network.py", line 150, in command
parse_write_concern_error=parse_write_concern_error)
File "/venv/lib/python3.7/site-packages/pymongo/helpers.py", line 155, in _check_command_response
raise OperationFailure(msg % errmsg, code, response)
pymongo.errors.OperationFailure: Authentication failed.
So, this consumer invocation could also bring a better error message. Still investigating how to solve this one...
Ok, so since I have a "alerta" channel created on the mongodb side and not "kombu", then I was finally able to connect by specifying my amqp_url for both mailer and amqp to "/alerta". I am now manually testing this works.
So, I guess this is a documentation issue.
Also, to note, I'm running it by overriding the entrypoint and doing nohup alerta-mailer &
. I wonder if that is the best way? I am not sure but it would certainly be good to document this approach or?
The best approach would be to install alerta-mailer
into a dedicated container and not into the same container as the Alerta API and web UI.
Fixed 43875990713913e8836d27c1a987f8dc51353b8c
Issue Summary When I run https://github.com/alerta/alerta-contrib/tree/master/integrations/mailer#deployment I see the following logs. Unfortunately, I have no idea at which point the authentication is failing: amqp, api, smtp? As for the 403 error, I have manually validated that my key works by running Client(...) in the Python REPL.
I have no files in alerta.rules.d.
Here's my alerta.conf:
Here's my alertad.conf:
Here's my Dockerfile:
Environment
OS: Linux
API version: 7.4.5
Deployment: Docker
Database: MongoDB
Server config: Auth enabled? Yes Auth provider? Keycloak Customer views? No
web UI version: 7.4.5
CLI version: 7.4.0
To Reproduce Steps to reproduce the behavior:
For web app issues, include any web browser JavaScript console errors.
Expected behavior Alerta-mailer can authenticate and query the heartbet successfully
Screenshots N/A
Additional context Here's a gist of the configs when I asked on the Gitter: https://gist.github.com/decentral1se/8d6551909a7d6b25826d4ff8ca32c364.