Automatically reconnect SSH tunnel DB connection

Hi,

We connect Metabase to a database via an SSH tunnel. Whenever the database goes down (for various reasons) we need to manually reconnect the database. Is there any way to automate this? Via the API (we have looked but couldn’t find anything) or via some other means?

Thanks

Hi @jcandiloro
Currently, there’s several problems with the built-in SSH tunnel, so I would recommend that you create the tunnel manually outside of Metabase:
https://github.com/metabase/metabase/issues/3941
https://github.com/metabase/metabase/issues/6114
https://www.metabase.com/docs/latest/administration-guide/01-managing-databases.html#what-if-the-built-in-ssh-tunnels-dont-fit-my-needs

H @flamber,
Thanks for the reply. Do you happen to know if there are plans to resolve this problem?
Thanks
Jeffery

@jcandiloro Yes, but there’s 1700 other issues, and like many other issues, it turns out it’s more complicated than expected.
Also related issue: https://github.com/metabase/metabase/issues/10081

@flamber Just to expand on @jcandiloro question. The built-in SSH tunnel seems to work fine overall, except it doesn’t reestablish the connection if DB goes off-line. To make it work again we need to go to Metabase and press the “Save changes” button on Database config page. That seems like a little thing to make it work perfectly. For example an API that would allow us to press that “Save changes” button via a script. Would you have any ideas how to achieve that ?

@tomn This is the API, when clicking “Save changes”:
https://github.com/metabase/metabase/blob/master/docs/api-documentation.md#post-apidatabase
The best way to learn the API, is to just use Metabase while having your browser developer Network-tab open and looking at the request, and what data is being send/received.

Thanks @flamber.

Jeffery