Oracle Prometheus Part 1


This is my step-by-step guide to monitor an Oracle DB with Prometheus. It is highly inspired by Dirk Nachbars blog post. In this post we will install it without interactive mode, so the whole process can be automated.

git clone https://github.com/oracle/docker-images.git

Download Oracle 19 installation zip and save it in OracleDatabase/SingleInstance/19.3.0.

Build docker image:

./buildDockerImage.sh -v 19.3.0 -e -i

The build should finish with:

...
  Oracle Database Docker Image for 'ee' version 19.3.0 is ready to be extended:

    --> oracle/database:19.3.0-ee

  Build completed in 1015 seconds.
docker run --name firstDB -p 1521:1521 oracle/database:19.3.0-ee

There is also an option to set a password, that I forgot here to set:

 -e ORACLE_PWD: The Oracle Database SYS, SYSTEM and PDB_ADMIN password (default: auto generated)

Change the password afterwards:

docker exec 28fa48acdbf5 /opt/oracle/setPassword.sh dirk

(Note: very shi**ty password)

Create a DB user that queries the metrics:

create user prometheus identified by prometheus;
grant connect, select any dictionary, create procedure to prometheus;

As user prometheus create the procedure that creates the metrics, see the source at the above mentioned blog.

Now we are going to install and set up the Oracle REST Data Services (ORDS). I downloaded version 19.4 from Oracle Technical Resources. Create directories where the configuration and parameter files will be stored, here as an example:

mkdir /YOUR_BASE_PATH/ords/conf
mkdir /YOUR_BASE_PATH/ords/params

Create the following files and adapt them to your needs. Store them in /YOUR_BASE_PATH/ords/params

db_params.properties

db.hostname=localhost
db.port=1521
db.servicename=ORCLPDB1
error.keepErrorMessages=true
error.maxEntries=50
jdbc.DriverType=thin
jdbc.InactivityTimeout=1800
jdbc.InitialLimit=3
jdbc.MaxConnectionReuseCount=1000
jdbc.MaxLimit=10
jdbc.MaxStatementsLimit=10
jdbc.MinLimit=1
jdbc.statementTimeout=900
db.password=prometheus
db.username=prometheus
resource.templates.enabled=true
rest.services.ords.add=true
user.public.password=prometheus
plsql.gateway.add=true

ords_params.properties

db.hostname=localhost
db.port=1521
db.servicename=ORCLPDB1
sys.user=sys
sys.password=dirk
plsql.gateway.add=true
rest.services.ords.add=true
schema.tablespace.default=USERS
schema.tablespace.temp=TEMP
standalone.http.port=8080
standalone.mode=false
standalone.static.images=/path/to/images
standalone.use.https=false
user.apex.listener.password=password
user.apex.restpublic.password=password
user.public.password=prometheus
user.tablespace.default=USERS
user.tablespace.temp=TEMP

Start the installation process

java -jar ords.war configdir /YOUR_BASE_PATH/ords/conf
java -jar ords.war install --parameterFile /YOUR_BASE_PATH/ords/params/ords_params.properties --silent

After that, set up the database definition and define the mapped URL for the above created definition.

java -jar ords.war setup --database prometheus_metrics --parameterFile /YOUR_BASE_PATH/ords/params/db_params.properties --silent
java -jar ords.war map-url --type base-path /prometheus_metrics prometheus_metrics

Start jetty in stand-alone mode

java -jar ords.war standalone

If something went wrong I highly recommend removing the installation as I encountered problems resuming failed installations. You can uninstall with:

java -jar ords.war uninstall

Finally you can check the output at http://localhost:8080/ords/prometheus_metrics/PROMETHEUS_METRICS

In the next part we will set up Prometheus and Grafana, stay tuned!