Read-only monitoring of a two-node Oracle AI Database 26ai RAC: a least-privilege common user, python-oracledb Thin mode, Prometheus and Grafana.
Alhamdulillah. This is Part 2 of the ODAR series. Part 1 covered the design, management VM, API and audit trail. This part connects ODAR to the RAC cluster and turns the database readings into metrics and a dashboard.
The rule for this part was simple: monitoring must not need privileges that allow it to change the database. The monitoring connection uses one common account with CREATE SESSION and explicit SELECT grants on the ten views used by ODAR. The account is not used for SYSDBA administration; account creation and grants were performed separately as SYSDBA.
| Part | Topic |
|---|---|
| 1 | Design, management VM, FastAPI skeleton and audit trail |
| 2 (this post) | Read-only RAC monitoring with a least-privilege user, Prometheus and Grafana |
| 3 | AI-assisted diagnostics with a sanitizer and controlled recommendations |
| 4 | Allowlisted automation, approval workflow, kill switch and identity hardening |
Bringing the lab up in the right order
ODAR reaches the cluster through SCAN, and SCAN resolution comes from a small BIND server (dns1). On the first start I booted dns1 and, about thirty seconds later, both RAC nodes. dns1 did not finish booting. Its console stopped in initramfs, and from the other VMs its address was unreachable:
# Bash, on the management VM$ ping -c 2 <dns-ip>From <mgmt-ip> icmp_seq=1 Destination Host Unreachable$ dig @<dns-ip> rac-scan.lab.local +time=2 +tries=1;; connection timed out; no servers could be reached
Rebooting dns1 independently resolved the issue, and SCAN then resolved to all three addresses. Since then the startup order has been fixed: start dns1 first and wait until it answers, then start the RAC nodes, then ODAR. I did not investigate the original boot hang further; starting dns1 independently has been reliable.
The second surprise was the database itself. CRS came up on both nodes, but the database remained offline because it had been explicitly stopped with srvctl during the previous lab session. I checked the database resource state and then started the database:
# Bash, as root on rac1$ crsctl stat res -t -w "TYPE = ora.database.type"ora.racdb.db 1 OFFLINE OFFLINE Instance Shutdown,STABLE 2 OFFLINE OFFLINE Instance Shutdown,STABLE# Start the database$ srvctl start database -db RACDB
Both instances and the PDB service returned successfully. This was a lab startup-state issue, not a database failure.
The monitoring account
ODAR uses a common user created in CDB$ROOT, with its own profile, CREATE SESSION and SELECT on the ten Oracle views required by the monitoring code. The setup shown here does not grant SYSDBA, DBA or SELECT ANY DICTIONARY.
-- SQL*Plus, as SYSDBA in CDB$ROOTCREATE PROFILE C##ODAR_MON_PROFLIMIT PASSWORD_LIFE_TIME UNLIMITED FAILED_LOGIN_ATTEMPTS 10 CONTAINER=ALL;CREATE USER C##ODAR_MONIDENTIFIED BY "<password>"PROFILE C##ODAR_MON_PROFCONTAINER=ALL;GRANT CREATE SESSION TO C##ODAR_MON CONTAINER=ALL;GRANT SELECT ON SYS.GV_$INSTANCETO C##ODAR_MON CONTAINER=ALL;GRANT SELECT ON SYS.V_$DATABASETO C##ODAR_MON CONTAINER=ALL;GRANT SELECT ON SYS.GV_$PDBSTO C##ODAR_MON CONTAINER=ALL;GRANT SELECT ON SYS.GV_$ACTIVE_SERVICESTO C##ODAR_MON CONTAINER=ALL;GRANT SELECT ON SYS.GV_$SESSIONTO C##ODAR_MON CONTAINER=ALL;GRANT SELECT ON SYS.V_$CONTAINERSTO C##ODAR_MON CONTAINER=ALL;GRANT SELECT ON SYS.CDB_TABLESPACE_USAGE_METRICSTO C##ODAR_MON CONTAINER=ALL;GRANT SELECT ON SYS.DBA_TABLESPACE_USAGE_METRICSTO C##ODAR_MON CONTAINER=ALL;GRANT SELECT ON SYS.V_$RECOVERY_FILE_DESTTO C##ODAR_MON CONTAINER=ALL;GRANT SELECT ON SYS.V_$ASM_DISKGROUP_STATTO C##ODAR_MON CONTAINER=ALL;ALTER USER C##ODAR_MONSET CONTAINER_DATA=ALLCONTAINER=CURRENT;
CONTAINER_DATA=ALL configures which container rows a common user can see in applicable container-data objects when connected to the CDB root. It does not grant object access by itself; the explicit SELECT grants above provide that access. Since ODAR currently connects directly through the managed PDB service, this setting is not used by the current connection. It is retained for a possible future root-level connection.
The profile’s unlimited password lifetime is a lab convenience so the password does not expire during an extended test. It is not a general production recommendation. Production deployments should follow their organisation’s password rotation, secret-storage and account-lifecycle policies.
I checked the direct object grants reported by the database:
-- SQL*Plus, as SYSDBA in CDB$ROOTSET LINES 150 PAGES 50COL table_name FORMAT a32SELECT NVL(table_name,'-') table_nameFROM dba_tab_privsWHERE grantee='C##ODAR_MON'ORDER BY 1;TABLE_NAME--------------------------------CDB_TABLESPACE_USAGE_METRICSDBA_TABLESPACE_USAGE_METRICSGV_$ACTIVE_SERVICESGV_$INSTANCEGV_$PDBSGV_$SESSIONV_$ASM_DISKGROUP_STATV_$CONTAINERSV_$DATABASEV_$RECOVERY_FILE_DEST10 rows selected.
This output confirms the ten direct object-grant entries. A complete privilege audit would also inspect DBA_SYS_PRIVS and DBA_ROLE_PRIVS; the object-grant query alone does not prove the absence of inherited or separately granted privileges.
Connecting through SCAN, without an Oracle Client
ODAR uses python-oracledb Thin mode, so Oracle Client libraries are not installed on the management VM. The Python virtual environment uses python-oracledb 26.2.0, and the application loads its Oracle username, password and DSN from /etc/odar/odar.env.
The first DSN in the draft used the default CDB service, RACDB.lab.local. During final integration testing I checked the actual Clusterware service configuration rather than assuming that the default service was the best endpoint for the monitoring application.
# On rac1, as grid$ srvctl config service -db RACDBService name: RACDB_RACPDB1Cardinality: 2Service role: PRIMARYManagement policy: AUTOMATICPluggable database name: RACPDB1Preferred instances: racdb1,racdb2Service is enabled
The service was running on both instances, and GV$ACTIVE_SERVICES showed it on INST_ID 1 and 2. My first Python connection attempt using the short service name RACDB_RACPDB1 returned DPY-6001 / ORA-12514: that exact short name was not registered with the SCAN listener.
I inspected the SCAN listener services. The listeners advertised the fully qualified service as racdb_racpdb1.lab.local, with READY handlers for both racdb1 and racdb2. The corrected DSN therefore uses the fully qualified name:
rac-scan.lab.local:1521/racdb_racpdb1.lab.local
The Python Thin-mode connection then succeeded. I queried the session context to confirm which service, container and instance had accepted the connection:
SELECT SYS_CONTEXT('USERENV', 'SERVICE_NAME') AS service_name, SYS_CONTEXT('USERENV', 'CON_NAME') AS container_name, SYS_CONTEXT('USERENV', 'INSTANCE_NAME') AS instance_nameFROM dual;SERVICE_NAME RACDB_RACPDB1.lab.localCONTAINER_NAME RACPDB1INSTANCE_NAME racdb2
The session landed on racdb2, which is expected because the Clusterware-managed service is configured with both RAC instances as preferred instances. I then tested every monitoring query using the actual ODAR monitoring credentials and this corrected DSN.
| Monitoring query | Rows returned | Result |
|---|---|---|
| Instances | 2 | PASS |
| Database | 1 | PASS |
| PDBs | 2 | PASS |
| Services | 4 | PASS |
| Sessions | 2 | PASS |
| Tablespaces | 7 | PASS |
| FRA | 1 | PASS |
| ASM disk groups | 3 | PASS |
All eight query groups passed. This confirmed that the account could retrieve the RAC-wide instance, PDB, service, session and storage information required by ODAR through the managed PDB service.
I backed up /etc/odar/odar.env, changed only ODAR_ORA_DSN to the verified fully qualified service, checked that the odar user could still read the file, and restarted both odar-api and odar-exporter. Both systemd services returned to active/running. No RAC database, SCAN listener or Clusterware service restart was needed.
ODAR_ORA_DSN=rac-scan.lab.local:1521/racdb_racpdb1.lab.local
From queries to metrics
For history and dashboards, ODAR has a separate exporter process listening on port 9161. It runs fixed monitoring queries and publishes their results in Prometheus text exposition format.
| Metric | Source | Meaning |
|---|---|---|
odar_oracle_up | Connection test | 1 when ODAR can query Oracle |
odar_instance_up | GV$INSTANCE | 1 per instance that is OPEN |
odar_pdb_open_rw | GV$PDBS | 1 per PDB and instance in READ WRITE |
odar_sessions_user, odar_sessions_active_user, odar_sessions_blocked | GV$SESSION | User, active and blocked sessions per instance |
odar_tablespace_used_pct | CDB_TABLESPACE_USAGE_METRICS | Used percentage of max size, per PDB tablespace in the current monitoring connection |
odar_fra_used_pct, odar_fra_reclaimable_pct | V$RECOVERY_FILE_DEST | FRA usage and reclaimable space percentages |
odar_asm_dg_used_pct, odar_asm_dg_free_mb | V$ASM_DISKGROUP_STAT | ASM disk group usage and free space |
odar_scrape_duration_seconds | Exporter | Time taken by one exporter collection |
Each collector query is handled independently. If one view fails, the exporter logs that collector failure and continues attempting the other collectors. One limitation is that a successful HTTP scrape does not, by itself, prove that every individual collector succeeded. A future improvement is a per-collector success metric so that a missing series can be distinguished from a healthy zero.
After correcting the DSN, I checked the exporter directly:
$ curl -s http://localhost:9161/metrics | grep '^odar_'odar_oracle_up 1.0odar_instance_up{db_instance="racdb1",host="rac1.lab.local"} 1.0odar_instance_up{db_instance="racdb2",host="rac2.lab.local"} 1.0odar_pdb_open_rw{db_instance="racdb1",pdb="RACPDB1"} 1.0odar_pdb_open_rw{db_instance="racdb2",pdb="RACPDB1"} 1.0odar_sessions_blocked{db_instance="racdb1"} 0.0odar_sessions_blocked{db_instance="racdb2"} 0.0odar_fra_used_pct 15.485
The final exporter output also included seven tablespace series and three ASM disk group series. The labels identify the database instance using db_instance, and the host label identifies the RAC node.
Prometheus, and a label name it already owns
Prometheus 3 runs on the same management VM and scrapes the exporter every 30 seconds, with a 20-second timeout. The configuration used for this lab is:
# /etc/prometheus/prometheus.ymlglobal: scrape_interval: 30sscrape_configs: - job_name: odar_oracle scrape_timeout: 20s static_configs: - targets: ['localhost:9161'] labels: cluster: 'RACDB'
The lab uses Prometheus’ default 15-day time retention; the scrape configuration shown above does not set a separate retention flag.
The first query against the exporter looked wrong. Prometheus returned the scrape target as the instance label for both Oracle instances. Prometheus attaches its own instance label to scraped series, and with the default label handling it keeps that target label and renames the conflicting exporter label to exported_instance.
I changed the exporter’s database-instance label to db_instance. The Prometheus query then returned two distinct series:
odar_instance_upodar_instance_up{cluster="RACDB",db_instance="racdb1", host="rac1.lab.local",job="odar_oracle"} 1odar_instance_up{cluster="RACDB",db_instance="racdb2", host="rac2.lab.local",job="odar_oracle"} 1
The lesson is to avoid using instance and job as custom exporter label names.

The Prometheus Targets page showed odar_oracle and prometheus both UP. The Oracle scrape shown in this later capture completed in approximately 98 ms. This is Prometheus’ HTTP scrape duration, which is different from the exporter’s own odar_scrape_duration_seconds collection-time metric.
I also queried the metrics directly in Prometheus to verify the values, not just the target state.
Prometheus query validation
The Oracle connectivity query returned 1:
odar_oracle_up
The RAC instance query returned two series, both equal to 1:
odar_instance_up

The PDB query returned RACPDB1 in READ WRITE mode on both instances:
odar_pdb_open_rw

The blocked-session query returned zero on both instances:
odar_sessions_blocked

The ASM query returned all three disk groups:
odar_asm_dg_used_pct
| ASM disk group | Used percentage |
|---|---|
| CRS | 3.3724% |
| DATA | 18.7240% |
| RECO | 10.7292% |

Grafana, provisioned from files
Grafana 13 reads its data source and dashboard from provisioning files, so the dashboard definition lives in Git rather than only inside Grafana’s database. The Prometheus data source is configured as follows:
# /etc/grafana/provisioning/datasources/odar-prometheus.yamlapiVersion: 1datasources: - name: Prometheus-ODAR uid: odar-prom type: prometheus access: proxy url: http://localhost:9090 isDefault: true
The dashboard JSON is generated by a Python script in the repository. After the exporter label rename, the dashboard briefly showed old series alongside the new ones because the earlier series were still inside the selected time window. I filtered the dashboard queries using the new label, for example:
odar_instance_up{db_instance!=""}
That removed the old series from the dashboard panels.

The dashboard shows Oracle reachability, the number of RAC instances, individual instance status, blocked sessions, FRA usage, user sessions per instance, ASM disk group utilisation and tablespace usage. It uses a 24-hour time range and a 30-second refresh interval.
Accessing ODAR from the Windows host
The management VM has two network interfaces: the NAT interface and the VirtualBox host-only interface. The host-only address used by the Windows host is 192.168.56.60. The FastAPI process listens on 0.0.0.0:8000, and I verified the health endpoint from the Windows browser using the host-only address.

The Oracle health endpoint returned overall: OK, with two instances open and RACPDB1 READ WRITE on both instances.

What the 24-hour view showed
The first exporter reading and the later dashboard view showed changes in storage utilisation. The later readings captured during the final validation were:
| Metric | First captured reading | Later reading |
|---|---|---|
| FRA used | 5.7% | 15.5% |
| ASM RECO disk group used | 4.3% | 10.7% |
| ASM DATA disk group used | 16.3% | 18.7% |
The cluster was mostly idle during that period. I have not investigated the reason for the increase, so I am not going to guess at the cause. The next step is to examine V$RECOVERY_AREA_USAGE, archived log history and the backup/retention picture. FRA used space and reclaimable space are different measurements; an increase in FRA usage does not by itself establish how much space is unreclaimable.
The point for now is that without a trend, an FRA at 15% might look perfectly healthy. With the trend showing it was closer to 6% earlier, it becomes a question worth investigating.
Network exposure
The exporter (9161) is not opened through the firewall; Prometheus reads it locally on the management VM. Prometheus (9090) and Grafana (3000) have firewalld rich rules allowing the host-only lab subnet (192.168.56.0/24). Both NAT and host-only interfaces belong to the same active public zone, so these restrictions are based on source address rather than being bound exclusively to the host-only interface. SSH is also enabled in that zone.
Grafana has its own administrator login. The lab currently uses HTTP rather than HTTPS. This is an isolated home-lab configuration, not a security design to copy directly into production. A production deployment would need stronger network isolation, TLS, identity management and an organisation-approved security configuration.
Limits of this setup
- There are no alert rules yet. The dashboard shows metrics and trends; it does not notify anyone.
- Metrics are sampled every 30 seconds, so short-lived spikes between scrapes may be missed.
CDB_TABLESPACE_USAGE_METRICSwas responsive in this lab but may be slower on databases with many PDBs and tablespaces. The exporter collection-duration metric helps track that overhead.- Each collector logs its own query failures, but a successful Prometheus scrape does not prove that every collector succeeded. Per-collector health metrics are a future improvement.
- One exporter connects through SCAN. If the cluster or SCAN is unavailable,
odar_oracle_up = 0provides the main connectivity signal, but does not identify the failed infrastructure component. - The current setup uses HTTP and is intended only for the isolated lab network.
- Because ODAR connects through the RACPDB1 PDB service, tablespace monitoring currently covers the PDB only. CDB root tablespaces, including SYSTEM and SYSAUX, are not included in the dashboard. Root-level tablespace monitoring would require a separate connection through the CDB root service.
Lessons from Part 2
- A read-only monitoring account can use a short, explicit list of object grants. Identify the required views first and grant only those.
- Understand
CONTAINER_DATAwhen a common user needs container-aware visibility. - Verify the actual service registration with Clusterware and the SCAN listeners. Do not assume the short service name is the exact name advertised by the listener.
- Test every monitoring query using the actual application account and connection service before changing the live application configuration.
- Avoid
instanceandjobas custom Prometheus exporter label names. - Start infrastructure dependencies such as DNS first, and wait for them before starting the cluster.
- Validate the metrics in Prometheus before relying on Grafana panels.
- A trend tells you more than a single reading. FRA at 15% means something different when it was 6% two days earlier.
Next: AI diagnostics that cannot act
Part 3 adds the AI layer: a sanitizer that masks hostnames, IP addresses and secrets before anything leaves the VM; a provider-independent interface with a mock provider for development; structured diagnostic findings; and an approval flag that the AI cannot switch off.
ما شاء الله. ODAR now has a working read-only monitoring path from the Oracle RAC cluster to FastAPI, Prometheus and Grafana. The code is on GitHub: Syedanwarahmed/odar.
Disclaimer: ODAR is a personal home-lab project, not an Oracle product. The implementation described here was tested in a non-production environment using Oracle AI Database 26ai RAC. It is not production-certified. Review privileges, network controls, identity verification, secrets management and operational procedures before adapting any part of this implementation. Hostnames and IP addresses shown are lab values.
