flask-dashboard / Flask-MonitoringDashboard

Automatically monitor the evolving performance of Flask/Python web services.
http://flask-monitoringdashboard.readthedocs.io/
MIT License
781 stars 160 forks source link

Flask Dashboard Configuration Issue - Error Connecting to SQL Alchemy Database #316

Open the-contact-departure-corporation opened 4 years ago

the-contact-departure-corporation commented 4 years ago

I have installed Flask-MonitoringDashboard via pip. Upon binding, it states that it is unable to open the database file. I have researched several solutions, all to no avail.

I have the following setup:

My flaskapp.wsgi is located here: /var/www/flaskapp

My configuration file for Flask-MonitoringDashboard is located in /var/www/flaskapp (really it is in /var/www/flaskapp/flaskapp however it is a symlink)

Where I initialize the flask application, I have initialized the main application through connexion, and then I bind flask_monitoringdashboard.

auth = HTTPBasicAuth()
l_app = connexion.App(__name__)

l_app.add_api('swagger.yml')
l_app.secret_key = 'testkey123'
import flask_monitoringdashboard as dashboard

os.environ["FLASK_MONITORING_DASHBOARD_CONFIG"] = '/var/www/flaskapp/flaskapp/config.cfg'

dashboard.config.init_from(envvar='FLASK_MONITORING_DASHBOARD_CONFIG')
dashboard.bind(l_app)

I have set an environment variable, which points to the configuration file outlined in the required style as defined in the project documentation:

os.environ["FLASK_MONITORING_DASHBOARD_CONFIG"] = '/var/www/flaskapp/flaskapp/config.cfg’

The contents of my config.cfg file are below:

[dashboard] DATABASE=sqlite:////var/www/flaskapp/flaskapp/flask_monitoringdashboard.db

I have tried setting this with relative and absolute paths, and it looks like flask_monitoringdashboard.db has relevant information related to Flask-MonitoringDashboard in it (for troubleshooting this the file has been assigned 777 permissions).

Any help solving this would be greatly appreciated. Thank you in advance for your time!

mircealungu commented 4 years ago

Hi @nick-halden-wc !

Can you try to put the DATABASE configuration in the [database] section? The configuration parser expects this.

E.g.

[database]
DATABASE=sqlite:////<path to your project>/dashboard.db
the-contact-departure-corporation commented 4 years ago

Yes, that works. Now, when I go to the default dashboard URL, it says that the dashboard is not found. My configuration file is now the following:

[dashboard]

[database]
DATABASE=sqlite:////var/www/flaskapp/flaskapp/flask_monitoringdashboard.db
mircealungu commented 4 years ago

strange. what if you remove the orphan [dashboard] from the config file?

On 3 Apr 2020, at 22:35, nick-halden-wc notifications@github.com wrote:

Yes, that works. Now, when I go to the default dashboard URL, it says that the dashboard is not found. My configuration file is now the following:

[dashboard]

[database] DATABASE=sqlite://///dashboard.db

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/flask-dashboard/Flask-MonitoringDashboard/issues/316#issuecomment-608646162, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADRNB3TRIN5EMCXFUYXGO3RKZCCVANCNFSM4LZRSEUQ.

the-contact-departure-corporation commented 4 years ago

Sorry it took so long to get back.

If I remove the orphan [dashboard] inside the config file I still get a 404.

I am trying via the default URL: xxx.xxx.xxx.xxx:5000/dashboard/login

SebastianGergen commented 4 years ago

So in general flask monitoring dashboard is supposed to work with connexion?

I get the error message "AttributeError: 'FlaskApp' object has no attribute 'register_blueprint'" when I try to start my connexion based app.

mircealungu commented 4 years ago

@nick-halden-wc : is there any way in which you can help me replicate your setup. i don't feel that i have sufficient information to provide you with help? maybe a dockerfile that recreates the problem?

@SebastianGergen : what is connextion?

SebastianGergen commented 4 years ago

@mircealungu A python-OpenAPI-Flask framework that I use https://connexion.readthedocs.io/en/latest/ and that @nick-halden-wc uses in the opening post. This is how I found this thread :)