iamseth / oracledb_exporter

Prometheus Oracle database exporter.
MIT License
479 stars 236 forks source link

DATA_SOURCE_NAME without the password #450

Open iwonaclk opened 4 months ago

iwonaclk commented 4 months ago

What is the current behavior?

According to the documentation, the DATA_SOURCE_NAME needs to have the following string format (containing the user and pass):

"Ensure that the environment variable DATA_SOURCE_NAME is set correctly before starting. DATA_SOURCE_NAME should be in Oracle Database connection string format: oracle://user:pass@server/service_name[?OPTION1=VALUE1[&OPTIONn=VALUEn]...]"

What is the expected behavior?

Is there an easy way to set the DATA_SOURCE_NAME without telling the user and pass openly?

What is the motivation / use case for changing the behavior?

I would like to avoid showing the user and pass in DATA_SOURCE_NAME because of security purposes.

I can add an entry with the user and password into the Oracle Wallet, but how should look the DATA_SOURCE_NAME then?

Please tell us about your environment:

OracleDB_Exporter 0.5.2 Oracle Client FULL 19.3.0 Oracle Database 19

lucian-vanghele commented 4 months ago

I also tried this, documentation found is a bit confusing/unclear, some people pretend they made it work however for me it didn't work. Try playing with TNS_ADMIN, DATA_SOOURCE_NAME, WALLET_PATH ...

lucian-vanghele commented 4 months ago

I made it work, it is about how you define your entry inside the wallet: mkstore -wrl -createCredential

The db_connect_string must be identical to the connection string that you specify in the URL used in the datasource definition (the part of the string that follows the @). It can be either the short form or the long form of the URL.

Jansy-rm commented 4 months ago

Relieved to read someone has got it working. Any chance you could provide an example of a URL and db_connect_string that works for you?

Jansy-rm commented 4 months ago

Managed to get it working using a SEP Wallet.

export DATA_SOURCE_NAME='oracle://username@hostname:1521/service?TRACE FILE=/tmp/trace.log&wallet=wallet_location'

mkstore -wrl -create mkstore -wrl -createCredential '(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=hostname)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=service)))' username "password"

/usr/local/bin/oracledb_exporter --default.metrics "/etc/oracledb_exporter/default-metrics.toml" --log.level debug --web.listen-address 0.0.0.0:9110`