Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grafana Database Tables inside PostgreSQL Schema #18714

Closed
gopalakrishnan-subramani opened this issue Aug 25, 2019 · 7 comments
Closed

Grafana Database Tables inside PostgreSQL Schema #18714

gopalakrishnan-subramani opened this issue Aug 25, 2019 · 7 comments

Comments

@gopalakrishnan-subramani

One of our customer uses grafana, they have a requirement to keep the grafana tables used for users, org, roles, dashboards etc inside their database with a postgresql schema like "grafana.user".

I see the grafana table structures, I don't see grafana has option to use schema for the tables.

Is it possible to achieve this without code change in go language.

@dprokop
Copy link
Member

dprokop commented Aug 26, 2019

@gopalakrishnan-subramani Looking at the code it seems like this is not possible, as the only thing configurable is the database name. But let me verify that with @marefr. Marcus, is there any workaround fur such case?

@liorld
Copy link

liorld commented Aug 26, 2019

not yet

@marefr
Copy link
Contributor

marefr commented Aug 26, 2019

Think using a custom search_path in the postgres database should work. We fixed a bug earlier that shown that users we're using a custom schema with Postgres and Grafana, see #17357 for reference.

@dprokop dprokop closed this as completed Aug 27, 2019
@ocherfas
Copy link

I came across a similar issue where I wanted the ability to configure the database schema name for the postgres connection. Are there any plans for implementing such a thing?

@marefr
Copy link
Contributor

marefr commented Aug 31, 2020

@ocherfas use a custom search_path as I refer to in #18714 (comment)

@ocherfas
Copy link

ocherfas commented Aug 31, 2020

@marefr I tried to use a custom search_path but I get an error on grafana initialization:
msg="Server shutdown" logger=server reason="Service init failed: Migration failed err: pq: relation "migration_log" does not exist"
I think this is somewhat related to the fix you referred to on #17357
I'm using grafana 7.0.5.

Any suggestions?

@ocherfas
Copy link

ocherfas commented Sep 1, 2020

It seems that the problem was that I had leftovers from previous grafana initialization on the public schema, and even through I changed the search_path for grafana user it still somehow found the previous migration_log table and failed.
So after cleanup it did work, but I still think this is not a very solid solution. For example in our case, we use grafana as part of our solution, so when we deploy our solution on a customer site, a reasonable request would be to create a database for us on his PostgreSQL and give us a user that can control that database. It would be a bit "weird" to ask him to create an extra user and configure its search_path to "grafana" schema.
So I still wonder if you might consider adding the custom schema option for database.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants