oracle / oracle-db-appdev-monitoring

Metrics exporter and samples for unified observability for data-centric app dev and microservices
http://developer.oracle.com/microservices
Other
78 stars 23 forks source link

failed to connect to local PDB on an Oracle Base Database DB System in OCI Cloud #110

Closed tux-jochen closed 4 months ago

tux-jochen commented 4 months ago

installed oracledb_exporter from binary 1.3.0 on the DB System

excute as oracle user ./startExporter.sh

ts=2024-07-18T13:33:50.693Z caller=main.go:72 level=info msg="FREE_INTERVAL end var is not present, will not periodically attempt to release memory" ts=2024-07-18T13:33:50.694Z caller=main.go:79 level=info msg="RESTART_INTERVAL env var is not present, so will not restart myself periodically" ts=2024-07-18T13:33:50.695Z caller=collector.go:361 level=debug msg="Launching connection to localhost:1521/JOCHEN01" ts=2024-07-18T13:33:50.695Z caller=collector.go:374 level=debug msg="connection properties: user=system password=SECRET-*** connectString=localhost:1521/MyPDBName configDir=\nconnectionClass= enableEvents=0 externalAuth=0 heterogeneousPool=0 initOnNewConnection=0\nlibDir= noBreakOnContextCancel=0 noTimezoneCheck=0 perSessionTimezone=0 pingInterval=0s\npoolIncrement=0 poolMaxSessions=0 poolMinSessions=0 poolSessionMaxLifetime=0s\npoolSessionTimeout=0s poolWaitTimeout=0s prelim=0 standaloneConnection=0 sysasm=0\nsysdba=0 sysoper=0 timezone=" ts=2024-07-18T13:33:50.695Z caller=collector.go:379 level=debug setmaxidleconnectionsto=0 ts=2024-07-18T13:33:50.695Z caller=collector.go:381 level=debug setmaxopenconnectionsto=10 ts=2024-07-18T13:33:50.695Z caller=collector.go:384 level=debug msg="Successfully configured connection to localhost:1521/JOCHEN01" ts=2024-07-18T13:33:50.748Z caller=collector.go:391 level=info msg="Could not set CLIENT_INFO." ts=2024-07-18T13:33:50.748Z caller=collector.go:396 level=info msg="dbtype err =pool=0x29f1410 stats=busy=0 open=0 max=0 maxLifetime=1h0m0s timeout=5m0s waitTimeout=30s params={authMode:0 connectionClass: connectionClassLength:0 purity:0 newPassword: newPasswordLength:0 appContext: numAppContext:0 externalAuth:0 externalHandle: pool:0x29f1410 tag: tagLength:0 matchAnyTag:0 outTag: outTagLength:0 outTagFound:0 shardingKeyColumns: numShardingKeyColumns:0 superShardingKeyColumns: numSuperShardingKeyColumns:0 outNewSession:0}: ORA-24415: Missing or null username." ts=2024-07-18T13:33:50.748Z caller=collector.go:402 level=info msg="got error checking my database role" ts=2024-07-18T13:33:50.748Z caller=collector.go:404 level=info msg="Connected as SYSDBA? " ts=2024-07-18T13:33:50.748Z caller=collector.go:272 level=debug msg="error = pool=0x29f1410 stats=busy=0 open=0 max=0 maxLifetime=1h0m0s timeout=5m0s waitTimeout=30s params={authMode:0 connectionClass: connectionClassLength:0 purity:0 newPassword: newPasswordLength:0 appContext: numAppContext:0 externalAuth:0 externalHandle: pool:0x29f1410 tag: tagLength:0 matchAnyTag:0 outTag: outTagLength:0 outTagFound:0 shardingKeyColumns: numShardingKeyColumns:0 superShardingKeyColumns: numSuperShardingKeyColumns:0 outNewSession:0}: ORA-24415: Missing or null username." ts=2024-07-18T13:33:50.749Z caller=collector.go:283 level=error msg="Error pinging oracle" error="pool=0x29f1410 stats=busy=0 open=0 max=0 maxLifetime=1h0m0s timeout=5m0s waitTimeout=30s params={authMode:0 connectionClass: connectionClassLength:0 purity:0 newPassword: newPasswordLength:0 appContext: numAppContext:0 externalAuth:0 externalHandle: pool:0x29f1410 tag: tagLength:0 matchAnyTag:0 outTag: outTagLength:0 outTagFound:0 shardingKeyColumns: numShardingKeyColumns:0 superShardingKeyColumns: numSuperShardingKeyColumns:0 outNewSession:0}: ORA-24415: Missing or null username." ts=2024-07-18T13:33:50.749Z caller=main.go:107 level=info msg="Starting oracledb_exporter" version=1.3.0 ts=2024-07-18T13:33:50.749Z caller=main.go:108 level=info msg="Build context" build="(go=go1.22.4, platform=linux/amd64, user=, date=, tags=unknown)" ts=2024-07-18T13:33:50.749Z caller=main.go:109 level=info msg="Collect from: " metricPath=/metrics

startExporter.sh

#!/bin/bash
. exporter.env
/usr/local/bin/oracledb_exporter --log.level debug --web.listen-address 0.0.0.0:9161 --default.metrics /etc/oracledb_exporter/default-metrics.toml

exporter.env

#/bin/bash
export LOG_DESTINATION=/var/log/oracledb_exporter/alert.log
export DB_USERNAME=c##_monitoring
export DB_PASSWORT=*******
export DB_CONNECT_STRING=localhost:1521/MyPDBName

Database ist available

sqlplus c##_monitoring/"*********"@MyPDBName

SQL*Plus: Release 19.0.0.0.0 - Production on Thu Jul 18 16:00:14 2024
Version 19.23.0.0.0
Copyright (c) 1982, 2023, Oracle.  All rights reserved.

Connected to:
Oracle Database 19c Standard Edition 2 Release 19.0.0.0.0 - Production
Version 19.23.0.0.0

SQL> 
markxnelson commented 4 months ago

Thanks for reporting the issue. I will try to reproduce it and see what is going on.

markxnelson commented 4 months ago

One quick question - I noticed the file you posted has DB_PASSWORT not DB_PASSWORD. I see the error message is talking about the username not the password, but just wanted to check on that, just in case maybe the error message is misleading.

tux-jochen commented 4 months ago

Thanks, I changed the typo in my exporter.env The log message is the same ts=2024-07-18T14:53:38.320Z caller=collector.go:272 level=debug msg="error = pool=0x7f481c00c750 stats=busy=0 open=0 max=0 maxLifetime=1h0m0s timeout=5m0s waitTimeout=30s params={authMode:0 connectionClass:<nil> connectionClassLength:0 purity:0 newPassword:<nil> newPasswordLength:0 appContext:<nil> numAppContext:0 externalAuth:0 externalHandle:<nil> pool:0x7f481c00c750 tag:<nil> tagLength:0 matchAnyTag:0 outTag:<nil> outTagLength:0 outTagFound:0 shardingKeyColumns:<nil> numShardingKeyColumns:0 superShardingKeyColumns:<nil> numSuperShardingKeyColumns:0 outNewSession:0}: ORA-24415: Missing or null username."

tux-jochen commented 4 months ago

I had special chars in my password and changed the password to a password without special chars. The log changed to olumns:0 superShardingKeyColumns:<nil> numSuperShardingKeyColumns:0 outNewSession:0}: ORA-12514: TNS:listener does not currently know of service requested in connect descriptor" Is the DB_CONNECT_STRING correct?

tux-jochen commented 4 months ago

Solved :-) In OCI we need the domain suffix in DB_CONNECT_STRING DB_CONNECT_STRING=MyPDBName.priv.db.oraclevcn.com The exporter logs show successfull connection Many Thanks for Your help

tux-jochen commented 4 months ago

How can I configure the path and filename of oracles alert.log? In OCI Database Service is the name of the file alert_<cdb_name>.log not alert.log

ts=2024-07-18T15:23:40.133Z caller=alertlog.go:103 level=error msg="Error querying the alert logs"

Or is this a grant problem of the db user?

markxnelson commented 4 months ago

You can specify the location of the output log file using the environment variable LOG_DESTINATION

markxnelson commented 4 months ago

That looks like a grant issue though

markxnelson commented 4 months ago

Your user needs permission to read v$diag_alert_ext

tux-jochen commented 4 months ago

Thanks a lot

tux-jochen commented 4 months ago

works for me