burningalchemist / sql_exporter

Database-agnostic SQL Exporter for Prometheus

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The problem of specifying a schema when capturing PostgreSQL metrics

gangzi59185 opened this issue Β· comments

When I was capturing metrics in PostgreSQL, the data_ Source_ Name doesn't know how to configure a specific schema. When connecting to PostgreSQL normally, the parameter after the driver is, but it doesn't work here

Hi @gangzi59185, I need more context to help you. Please share your DSN with redacted sensitive data. πŸ‘

Also, please refer to the schema names here (we use dbUrl dependency to handle DSN): https://github.com/xo/dburl

image The above are the parameters I connected to, because PostgreSQL has the concept of scheme, which defaults to pubic. However, my scheme is datago, and I don't know how to configure DSN to read data from datago's scheme

Hey @gangzi59185, I guess the problem is that you're using special characters (@) in your password, so the entire string contains 2 @ making DSN impossible to parse.

In the README.md we have the following part:

If your DSN contains special characters in any part of your connection string (including
passwords), you might need to apply URL encoding (percent-encoding) to them. For example,
p@$$w0rd#abc then becomes p%40%24%24w0rd%23abc.

So in your case the password Datago@2021 should become Datago%402021. Please, give it a shot and let me know.

P.S. I was referring to the URL scheme name (postgres://) and not the database schema. It looks correct to me. πŸ‘

data_source_name: 'postgres://datago:xxxx@xxx:8000/mdmc_db?sslmode=disable&search_path=datago_db'
Thank you for your reply. I have fixed the password issue, but my problem is not a password issue. It is about the specified scheme in PostgreSQL. I have resolved it and added the parameter search_ Path=datago_ DB to specify a certain scheme, successfully read scheme=datago_ Data of db

Hey @gangzi59185, I apologize, the terms are confusing. πŸ‘ I'm glad you've found the solution, though. πŸ˜… May I ask why can't you specify schema in your query? This is a pretty common practice. If not provided, it falls back to public, indeed. But otherwise it should generally work, so you don't need to specify it explicitly. Unless, there is a special situation, of course. πŸ™‚

Haha, you're right. Thank you for your suggestion