SnowAlert icon indicating copy to clipboard operation
SnowAlert copied to clipboard

Make WebUI errors clearer when env vars missing

Open bhasampa opened this issue 4 years ago • 5 comments

Hi, I had followed steps to install snowalert and metadata got created into snowalert database into snowflake successfully.

But when I try to access web UI on alert page I am not getting any part of the page

Application Server is logging error message as following: 172.17.0.1 - - [26/May/2020:11:28:00 +0000] "GET /api/sa/rules HTTP/1.1" 200 13 "http://192.168.0.95:8000/dashboard/alerts/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36" [8] ./../../../venv/bin/gunicorn:8 in sys.exit(run()) ./../../../venv/lib/python3.7/site-packages/gunicorn/app/wsgiapp.py:58 in run WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run() ./../../../venv/lib/python3.7/site-packages/gunicorn/app/base.py:228 in run super().run() ./../../../venv/lib/python3.7/site-packages/gunicorn/app/base.py:72 in run Arbiter(self).run() ./../../../venv/lib/python3.7/site-packages/gunicorn/arbiter.py:202 in run self.manage_workers() ./../../../venv/lib/python3.7/site-packages/gunicorn/arbiter.py:545 in manage_workers self.spawn_workers() ./../../../venv/lib/python3.7/site-packages/gunicorn/arbiter.py:616 in spawn_workers self.spawn_worker() ./../../../venv/lib/python3.7/site-packages/gunicorn/arbiter.py:583 in spawn_worker worker.init_process() ./../../../venv/lib/python3.7/site-packages/gunicorn/workers/base.py:140 in init_process self.run() ./../../../venv/lib/python3.7/site-packages/gunicorn/workers/sync.py:123 in run self.run_for_one(timeout) ./../../../venv/lib/python3.7/site-packages/gunicorn/workers/sync.py:67 in run_for_one self.accept(listener) ./../../../venv/lib/python3.7/site-packages/gunicorn/workers/sync.py:29 in accept self.handle(listener, client, addr) ./../../../venv/lib/python3.7/site-packages/gunicorn/workers/sync.py:134 in handle self.handle_request(listener, req, client, addr) ./../../../venv/lib/python3.7/site-packages/gunicorn/workers/sync.py:175 in handle_request respiter = self.wsgi(environ, resp.start_response) ./../../../venv/lib/python3.7/site-packages/flask/app.py:2464 in call return self.wsgi_app(environ, start_response) ./../../../venv/lib/python3.7/site-packages/flask/app.py:2447 in wsgi_app response = self.full_dispatch_request() ./../../../venv/lib/python3.7/site-packages/flask/app.py:1950 in full_dispatch_request rv = self.dispatch_request() ./../../../venv/lib/python3.7/site-packages/flask/app.py:1936 in dispatch_request return self.view_functionsrule.endpoint ./webui/api/rules.py:61 in get_rules for rule in rules ./webui/api/rules.py:45 in { ./../../../venv/lib/python3.7/site-packages/runners/helpers/db.py:139 in fetch res = execute(ctx, query, fix_errors, params) ./../../../venv/lib/python3.7/site-packages/runners/helpers/db.py:179 in execute log.info(e, f"ignoring error '{e}' in query >{query}<") --- printed exception w/ trace --- ./../../../venv/lib/python3.7/site-packages/runners/helpers/db.py:168 in execute return ctx.cursor().execute(query, params=params) ./../../../venv/lib/python3.7/site-packages/snowflake/connector/cursor.py:570 in execute errvalue) ./../../../venv/lib/python3.7/site-packages/snowflake/connector/errors.py:97 in errorhandler_wrapper cursor.errorhandler(connection, cursor, errorclass, errorvalue) ./../../../venv/lib/python3.7/site-packages/snowflake/connector/errors.py:73 in default_errorhandler done_format_msg=errorvalue.get(u'done_format_msg')) snowflake.connector.errors.ProgrammingError: 002043 (02000): SQL compilation error: Object does not exist, or operation cannot be performed. [8] ignoring error '002043 (02000): SQL compilation error: Object does not exist, or operation cannot be performed.' in query >SHOW VIEWS LIKE '%_%_%' IN rules< 172.17.0.1 - - [26/May/2020:11:28:06 +0000] "GET /api/sa/rules HTTP/1.1" 200 13 "http://192.168.0.95:8000/

Please do let me know how to proceed further on it.

Thanks, Bhaskar

bhasampa avatar May 26 '20 11:05 bhasampa

Look in the History tab and double check that the user executing the query has been granted privileges to access the snowalert.rules schema and views inside of it. Let me know if that doesn't fully make sense and I can drill down into more detail.

sfc-gh-afedorov avatar May 26 '20 20:05 sfc-gh-afedorov

The SQL is getting fired from snowalert application to snowflake as following: [Snowalert user is having access to execute the SQL]. SHOW VIEWS LIKE '%_%_%' IN rules -- The wild card value is not getting populated on snowalert application side. [In what scenario snowalert application will not pass desired value in above SQL].

bhasampa avatar May 27 '20 06:05 bhasampa

The wildcards are not meant to be replaced -- the query is looking for all the rules in the rules schema.

sfc-gh-afedorov avatar May 27 '20 17:05 sfc-gh-afedorov

I resolved the issue thanks for your pointers which helped me to debug.

on security env file I had given following environment variables. OAUTH_CONNECTION_DATABASE=snowalert OAUTH_CONNECTION_ROLE=snowalert

bhasampa avatar May 27 '20 19:05 bhasampa

Thanks, I see -- let me keep this one open so that I remember to make the error clearer.

sfc-gh-afedorov avatar May 27 '20 19:05 sfc-gh-afedorov