Blog Feed

OEM Incidents and AI Vector Search

In this post I want to provide a practical use of the AI Vector search functionality in the Oracle database. The use case is to be able to use AI Vector search on data that Oracle Enterprise Manager (EM) produces. In this case incidents data. The idea is to be able to search incidents using vectors in Oracle.

But what is Vector search and why we want to use it?
Vector search is a feature that enables searching data by semantics or meanings and values. We want to use it in combination with an LLM in order to ask questions about our data. What kind of data? In this case EM’s incident data.



There are several challenges that we’ll have to work on in order to be able to use AI Vector search. The first challenge is that AI Vector search is a feature of the 26AI (former 23AI) database. Oracle EM doesn’t support 26AI as a repository database. Oracle EM 24AI only supports 19.22 as a repository database as of today. So the question is, how we can me this work?

We will have to use an intermediate Oracle database for the AI Vector functionality. I decided to use the 26AI free version of the Oracle database. You can download a VirtualBox appliance image and run it in your personal computer. There are several limitations of the 26AI free version but it works for my use case.



Now that I have the 26AI appliance and database running, I need to bring the Oracle EM Incident data over. There are several ways to extract the data:

  • Connect through SQL Plus to the repository database
  • Use REST APIs
  • Use EMCLI

I decided to use REST APIs as it gives me the data in JSON format. Then I can format the in any shape or form needed.

Oracle EM exposes several REST APIs so we can consume data on external systems. There’s a whole framework behind these REST APIs.



We are going to call below REST API from the host where the 26AI free database is running.

$ curl -X GET -u sysman:<password> -H "Content-Type:application/json"  https://EM_HOST:EM_CONSOLE_HTTPS_PORT/em/api/incidents --insecure

This produces a JSON output with the first set of all open incidents with the most recently created incidents listed first.

I can create a Shell script that executes this CURL command, obtains the data in JSON format and then executes jq in order to convert it into CSV format. It will look similar to this:

#!/bin/bash

# Fetch JSON data using curl

JSON_DATA=$(curl -X GET -u sysman:<password> -H "Content-Type:application/json"  https://EM_HOST:EM_CONSOLE_HTTPS_PORT/em/api/incidents --insecure)

# Define the jq filter to extract and format data into CSV
# @csv: Convert the array into a CSV-formatted string
JQ_FILTER='.[].results | [.id, .displayId, .message, .severity, .status, .isOpen, .timeCreated, .timeUpdated, .target_names] | @csv' # Example filter

# Extract data and format as CSV using jq
CSV_CONTENT=$(echo "$JSON_DATA" | jq -r "$JQ_FILTER")

# Define CSV header (adjust to match your selected fields)
CSV_HEADER="id,displayId,message,severity, status, isOpen, timeCreated, timeUpdated, target_names"

# Output to a CSV file
echo "$CSV_HEADER" > incidents.csv
echo "$CSV_CONTENT" >> incidents.csv

echo "CSV data saved to incidents.csv"

We need now to insert this data into the 26AI free database and create the Vectors. Before we do that we need to find a way to generate the vectors from our incident data. For that we will use a model provided by Oracle named all-MiniLM-L12-v2.

Let’s download and load the model into our 26AI free database.

$ mkdir -p /home/oracle/onnx
$ cd /home/oracle/onnx

$ wget https://adwc4pm.objectstorage.us-ashburn-1.oci.customer-oci.com/p/VBRD9P8ZFWkKvnfhrWxkpPe8K03-JIoM5h_8EJyJcpE80c108fuUjg7R5L5O7mMZ/n/adwc4pm/b/OML-Resources/o/all_MiniLM_L12_v2_augmented.zip

$ unzip -oq all_MiniLM_L12_v2_augmented.zip
$ sqlplus sys as sysdba

SQL> create user em_inc identified by password quota unlimited on users;
SQL> grant create session, db_developer_role, create mining model to em_inc;

SQL> create or replace directory model_onnx as '/home/oracle/onnx';
SQL> grant read, write on directory model_onnx to em_inc;
SQL> begin
  dbms_vector.drop_onnx_model (
    model_name => 'ALL_MINILM_L12_V2',
    force => true);

  dbms_vector.load_onnx_model (
    directory  => 'model_onnx',
    file_name  => 'all_MiniLM_L12_v2.onnx',
    model_name => 'ALL_MINILM_L12_V2');
end;
/
SQL> select model_name, algorithm, mining_function from   user_mining_models where  model_name = 'ALL_MINILM_L12_V2';

MODEL_NAME                     ALGORITHM  MINING_FUNCTION
------------------------------ ---------- ---------------
ALL_MINILM_L12_V2              ONNX       EMBEDDING

At this point I can generate the Vector embeddings for the incident data.



We will now import our incident data from the CSV file and create the vector.

SQL> conn em_inc/password
SQL> create table incidents as
select id, displayId, message, severity, status, isOpen, timeCreated, timeUpdated, target_names
from   external (
         (
           id  varchar2(40),
           displayId        number(6),
           message   varchar2(500),
           severity   varchar2(100),
           status  varchar(400),
           isOpen  varchar(50),
           timeCreated varchar(400),
           timeUpdated varchar(400),
           target_names varchar(1500)
         )
         type oracle_loader
         default directory model_dir
         access parameters (
           records delimited by newline
           skip 1
           badfile model_dir
           logfile model_dir:'incidents_ext_tab_%a_%p.log'
           discardfile model_dir
           fields csv with embedded terminated by ',' optionally enclosed by '"'
           missing field values are null
        )
        location ('incidents.csv')
        reject limit unlimited
      );

SQL> alter table incidents add (
  incidents_vector vector
);

SQL> update incidents
set incidents_vector = vector_embedding(all_minilm_l12_v2 using message as data);

SQL> commit;

Let’s now perform a Vector similarity search using the VECTOR_DISTANCE function. This first query will do a search on “Incidents related to agents” query Vector.

SQL> SELECT vector_distance(incidents_vector, (vector_embedding(all_minilm_l12_v2 using 'Incidents related to agents' as data)), EUCLIDEAN) as distance,
       message
FROM   incidents
order by distance
FETCH EXACT FIRST 10 ROWS ONLY;
DISTANCEMESSAGE
0.98592836033379427Process em_agent crashed unexpectedly.
0.98592836033379427Process em_agent crashed unexpectedly.
0.98592836033379427Process em_agent crashed unexpectedly.
1.08642161802020090Number of Active Agents crossed the critical threshold (1). Current value: 0
1.09352931649992050Agent Unreachable (REASON = Unable to connect to the agent at https://host:3872/emd/main/ [Connection refused]). Host is reachable.
1.09352931649992050Agent Unreachable (REASON = Unable to connect to the agent at https://host:3872/emd/main/ [Connection refused]). Host is reachable.
1.09352931649992050Agent Unreachable (REASON = Unable to connect to the agent at https://host:3872/emd/main/ [Connection refused]). Host is reachable.
1.23613168789133000Process ora_pmon crashed unexpectedly.
1.23613168789133000Process ora_pmon crashed unexpectedly.

Let’s analyze these results. The shortest distance in the Similarity Vector search is for the message containing the same exact word “agent”, the second closest distance is for messages having the word “Agent” and the third one is for messages not having the word “a(A)gent”.



With this functionality we can perform Similarity Vector searches on our EM incident data.

Thanks,
Alfredo

Oracle EM Agent Preferred Connect Descriptor

The USE_SID_AS_SERVICE_LISTENER=ON saga

If you are migrating to multi-tenant architecture of the Oracle database, you’ll find out that in order to connect to the pluggable database (PDB) you must use the service name for the PDB. But, what if you have a legacy application that can only use SID instead of the service name?

For that, you can enable the parameter USE_SID_AS_SERVICE_LISTENER in the listener configuration, so the service name will act as an SID.

Problem solved, right? Well, the problem is now with applications that require the service name and not the SID. One of them is Oracle Enterprise Manager (EM). If you turn on this parameter at the listener level then, you won’t be able to connect to the databases and they will show down (red) in the EM console.

So, what can we do? In EM 13.5 RU16 or higher there’s functionality that allows EM to connect to the database by using an Agent preferred connect descriptor. This way, you can provide the connect descriptor using the service name.

One important note to mention is that you must have RU16 or higher applied to both, the OMS and the Agents in order to enable this functionality.

Follow the My Oracle Support Note “EM 13c: How To Enable Agent Preferred Connect Descriptor Support For RAC Instance, Single Instance DB (Doc ID 2963079.1) ” to enable this functionality. You will have to restart your OMS, so be prepared.

After you enable this setting, navigate to the Monitoring Configuration of your target and look for the new Agent preferred descriptor section. It looks like the image below.

Add the proper connect descriptor and viola! EM is now able to connect to your target.

Is always recommended to turn the USE_SID_AS_SERVICE_LISTENER parameter off after migrations and upgrades. Sometimes this is not an option if you have legacy applications though. This feature allows you connect your EM when the parameter USE_SID_AS_SERVICE_LISTENER must be turned on.

Thanks,
Alfredo

Monitor Oracle DBs in RDS With Enterprise Manager

In this blog I want to provide some important steps if you want to monitor Oracle databases running on AWS RDS.

The first step is to have an Oracle Enterprise Manager (EM) installation. This can be on-prem or running on EC2. If you need to setup EM in EC2 you can use one of the pre-built images that already contains an Oracle database. You are going to need this database for the EM repository.
One quick example can be the Oracle database 19c image by cloudimg running on Oracle Linux. Just make sure you add enough space in the filesystem so you can also install the EM software.

Once the EC2 instance is up and running, go ahead and patch the Oracle database with the latest RU (RU28 as of today).

Download the Oracle EM 13.5 software from oracle.com and also download the latest RU available (RU27 as of today).

Install EM 13.5 and patch it with RU27. Follow below videos if you need additional guidance on how to install and patch EM.



Next we are going to follow the instructions that RDS has available for the EM agent installation. Remember that because there’s no actual access to the RDS host, we can’t install the EM agent using the traditional way.



Verify all the network pre-reqs so your RDS instance can actually reach your EM installation running on EC2. If you EM is running on-prem then a VPN setup will be required.

Now is time to create an option group once all the network pre-reqs are met. The option group is how we actually ask the RDS console to provide us the option to deploy an EM agent. The option for the option group needs to be OEM_AGENT.

Before you deploy the option group to your RDS instance, you will have to provide information about your EM instance, including:

  • EM Host Name
  • EM upload port
  • EM registration key

Then deploy the option group to your RDS instance.

Once the deployment finishes, you will actually have the EM agent up and running in your RDS instance and showing up in the EM console.

The next step is to discover your DB instance and the listener. Follow below link for the documentation.



Hope this set of steps help you with the monitoring setup of your RDS database with Oracle Enterprise Manager.

Thanks,
Alfredo

Upgrade Enterprise Manager to 24ai

In this post I want to share my experience while executing the upgrade of Oracle Enterprise Manager from 13.5 to 24ai.

As always. Please go ahead and read the Oracle documentation on how to upgrade EM to 24ai.



My EM demo environment was running EM 13.5 RU21 and the EM repository database 19c RU18. As per of the EM pre-reqs you need to be at least on EM13.5 RU22 and the DB needs to have the latest RU available.

So before even trying to upgrade, I needed to patch my EM. I decided to skip the patch but the UI is really good at reminding it.

So, I patched my EM to RU25 and the EM repository DB to RU26.

Let me execute the 24ai installer and follow the instructions.

Here I decided to upgrade my 13.5 environment instead of creating a new one.
There are 2 options though. Upgrade end-to-end or just install the binaries and proceed with the upgrade later.

NOTE: I chose end-to-end first, but ended going back and selecting the second option. The wizard gives a failure in the pre-reqs as it knows that RU 1 is already available for 24ai and you must install it before attempting the upgrade. I’ll share a MOS note on how to deploy it in subsequent steps.

I skipped the software updates.

Then the UI ran the pre-checks.

The pre-checks failed due the fact that 24ai RU1 needed to be applied.

I had to use below MOS note in order to apply RU1 with the bitonly option.

13.5: How to Apply Release Update on the OMS During the Install/Upgrade (Doc ID 2810169.1)

Select your new 24ai home location.

Type the EM repository connection details.

I performed to upgrade using the SYS DB account.

I had an issue with Plug-ins. My environment had 2 plug-ins deployed that are no longer supported in 24ai. I had to use EMCLI commands to un-deploy them.



After un-deploying the, I was able to continue.

I just proceed with the upgrade.

Now it’s time to run the ConfigureGC.sh script.

It asks for the system to be upgraded.

Type the EM repository connection details once again.

Select the DB user for the upgrade. In my case SYS was fine.

All the pre-reqs were successful. I selected the default EM ports and proceeded with the upgrade.

NOTE: The wizard will also upgrade the EM central agent. In previous EM upgrades that was a manual step.

It took about an hour for the wizard to complete.

Don’t forget to run the root.sh script on your new agent. I had an issue where EM was throwing a weird error while connecting to DBs.

Failed to ascii decode encrypted-text (status=1) After EM Upgrade (Doc ID 2655512.1)

After that, EM 24ai RU1 is up and running.

Hope that you find this post useful.

Thanks,
Alfredo

Oracle Enterprise Manager 24AI – New Features

Oracle Enterprise Manager 24AI was announced on December 2024 during the Oracle Enterprise Manager Technology Forum 2024. If you would like to see all the Forum’s recordings please register below.



In this post, I want to provide a quick overview of the most interesting new features of EM 24AI to you.

Oracle EM 24AI provides a set of new features based on 4 focus areas:

  • Platform Modernization
  • Operational Continuity
  • AI Insights
  • Performance and Automation

I’m going to share only the features available as of today with the first release of EM 24AI.

Platform Modernization

  • New Navigation Menu allows you to easily search and access monitoring and administration options from anywhere.
  • Dashboard Enhancements to select the duration of time for which you want to display data.
  • Target Monitoring Using Remote Agents without requiring an agent to be installed on the same host as the targets.
  • Support for Oracle Key Vault and secrets management appliance to store, manage and share security objects and encryption keys.
  • EM pages enhancements using JET to easily access features with a re-organized menu, enabling direct navigation to each component.
  • Data Masking and Subsetting enhancements with a unified console experience.

Operational Continuity

  • Zero Downtime Monitoring that process and handles incident and notification capabilities even during planned maintenance.
  • New Job System Console which provided deeper information regarding your jobs and job system.
  • REST APIs enhancements that include the ability to control target blackouts.

Performance and Automation

  • New swim lanes visualization in ADDM Spotlight that use time-series data aggregated to display findings by overall impact for each ADDM task.
  • New Metrics to Monitor Raft-based Sharding for 23c and later.
  • New DBSAT 3.1 Standards.
  • New SCAP Standards for Oracle Linux 7,8 and 9.
  • Redesigned Plug-Ins for Non-Oracle targets including Microsoft IIS, JBoss EPA, Apache Tomcat and IBM Websphere.

AI Insights features will be coming in future release updates. If you want to learn more about this new release of Oracle Enterprise Manager please click below.



I’ll cover the upgrade process from Enterprise Manager 13.5 to 23AI in the next blog post.

Thanks,
Alfredo

Extract OCI Resource Status Using APIs

In this blog, I want to show you a way to extract every resource in a compartment along with their status using a Python script and OCI APIs.

There are several pre-reqs that you need to fulfil in order to be able to connect using APIs to OCI. Follow the same pre-reqs as in my previous blog about Metric Extensions.

Step 1 – Prerequisites



Once you have created an OCI user, setup API Keys and setup your Python host; then, go ahead and create a Python script similar to the one below.

#!/usr/bin/python3

# This is a sample python script that searches resources in a compartment
# Run this script on the client that you want to monitor.
# Command: python script_name.py

import oci,subprocess,os,datetime,json
from pytz import timezone

# using default configuration file (~/.oci/config)
from oci.config import from_file
config = from_file()

# initialize service client with default config file

search_client = oci.resource_search.ResourceSearchClient(config)
query = f"query all resources where compartmentId = '<compartment OCID>' && lifeCycleState != 'AVAILABLE' && lifeCycleState != 'ACTIVE' && lifeCycleState != 'Assigned' && lifeCycleState != 'Running' && lifeCycleState != 'Succeeded' && lifeCycleState != 'Deleted'"
search_response = search_client.search_resources(
    search_details=oci.resource_search.models.StructuredSearchDetails(
        type="Structured",
        query=query,
    ),
    limit=1000,
)
print(f"Compartment has {len(search_response.data.items)} resources")

json_format = json.loads(str(search_response.data.items))

# Iterate through the JSON array
for item in json_format:
    print(item["display_name"], item["lifecycle_state"])

As you can see from the script. We are using OCI Search in order to get all resources in a compartment (<compartment OCID>) and also we all filtering the search to only show resources that are either down, terminated or failed.

Once you get the list of resources in your compartment you can create a text/csv file and share the list with all the interested parties.

Another option is the ability to combine this with the Monitoring Service and create a Metric Extension (ME). The metric extension will hold the list of resources that have that specific lifecycle_state. Once the date is contained in the ME you can send notifications or create a dashboard showing these resources.

Thanks,
Alfredo

Send OCI Alerts Notifications To 3rd Party Systems (Object Storage)

Hi there!

In this blog, I want to show how you can send an OCI Alert Notification to a 3rd party system. The way I describe this tutorial is by sending the notification to an OCI Storage bucket so you can ingest it using the tool of preference.

First of all I would describe the services used:

  • OCI Monitoring Service
  • OCI Streams Service
  • OCI Connector Hub
  • OCI Storage Service

Let’s go an create a Storage bucket in order to hold these notifications.
Create a Storage bucket

Once you have the Storage bucket ready, go ahead and create a Stream pool and a Stream.
Create a Stream Pool

Don’t forget to create the Stream.

Now is time to create an alarm and send the notification to the Stream we just created.
Create an Alarm

During the alarm creation, be sure to select the Stream as a destination.

At this point every single time the alarm generates a notification, it will be send to the Streaming service. Now we need to send this notification from the Streaming service to our Storage bucket. We need to create a Connector Hub for that.
Create a Connector Hub

The Connector Hub configuration will look like below.

After this, the notification that was stored in the Streaming service will be moved to your Storage bucket.

Keep in mind that you need to set several policies for this to work.
Connector Hub policies

Another important consideration is the fact that the Streaming service encrypts the data at rest. So when you open one of those files inside your Storage bucket, you will find them encrypted. You could decrypt them using base64 functions.

Thanks,
Alfredo

Monitor MySQL HeatWave with OCI Database Management

In this post I want to show you how you can monitor your MySQL Heatwave databases with OCI Database Management Cloud Service. Is worth to mention that this Cloud Service provides this functionality free of cost and is automatically enabled for below configurations:

  • Standalone
  • High Availability

Let’s start by creating a new Heatwave instance.

You will notice that Database Management is automatically enabled.

The Database Management service will then publish several metrics related to your Heatwave instance.

You can of course use the alarms and notification services to setup alerts on important metrics.

Last but not least navigate to the Performance Hub page to find out real time performance information for the queries inside your Heatwave instance.

If you want to learn more about this service follow the link below.



Thanks,
Alfredo

Integrate EM Metrics With Third-Party Tools Using REST APIs

I want to share how to use Enterprise Manager’s (EM) REST APIs to query metric data and integrate with 3rd party tools.

First of all, always follow the documentation. Below is the link to the EM’s REST API functionality.



Using the EM’s REST API functionality we can query the EM repository using a web service. Let’s follow below steps.

a) Create a new EM user who is going to have the privileges to query the EM’s repository. Navigate to Setup -> Security -> Administrators.

Administrators navigation

b) Create a new Repository User.

Administrator creation

c) I’m going to create a new Administrator named ABC.

Administrator creation

d) Create a new Named Credential. Navigate to Setup -> Security -> Named Credentials.

Named Credential creation

e) Click on Create.

Named Credential creation

f) I’m going to create NC_ABC Named Credential.

Named Credential creation

g) Enable the repository REST APIs in EM. For that execute below emctl command.

emctl set property -name oracle.sysman.db.restfulapi.executesql.repository.query.enable -value true -sysman_pwd "sysman"

Now is time to test our REST APIs.

I’m going to test them out using 2 different mechanisms. For the first one, let’s use CURL.

$ curl -k -u ABC -H "Content-Type: application/json" -d '{"sqlStatement": "SELECT * FROM sysman.MGMT$TARGET_METRIC_SETTINGS", "credential": {"DBCredsMonitoring":"NC_ABC"}, "maxRowLimit": 10, "maxColumnLimit": 2}' https://<EM_Host>:<EM Port>/em/websvcs/restful/emws/oracle.sysman.db/executesql/repository/query/v1

Here are the results based on my demo environment:

REST API results from CURL

The second test is by using Ansible. If you are not familiar on how to configure Ansible in order to work with EM, please follow the Oracle Live Labs that we created about this.



I’m going to create a new YAML file (test.yml) in order to test the REST API.

---
- name: Using a REST API
  become: false
  hosts: emserver
  gather_facts: false
  tasks:

    - name: Query Metric Settings
      uri:
        url: https://emcc.marketplace.com:7803/em/websvcs/restful/emws/oracle.sysman.db/executesql/repository/query/v1
        method: POST
        return_content: yes
        force_basic_auth: yes
        validate_certs: no
        body_format: json
        url_username: ABC
        url_password: *******
        headers:
           Content-Type: application/json
        body:
          {
            "sqlStatement": "SELECT * FROM sysman.MGMT$TARGET_METRIC_SETTINGS", "maxRowLimit": 2, "maxColumnLimit": 29
          }
      register: results

    - name: Print returned json dictionary
      debug:
        var: results.json

Let’s execute this using Ansible.

ansible-playbook /home/oracle/ansible/yml/test.yml -u oracle --private-key=~/.ssh/dtkey.ssh

Here the results:

REST API results from Ansible

With this you can get the desired results from the EM’s repository using this REST API.

Thanks,
Alfredo

Extend Your Oracle Monitoring With Configuration Extensions

As soon as you enable the Database Lifecycle Management Pack; Oracle Enterprise Manager will automatically collect hundreds of configuration items of your database estate. However if you need to customize this collection, Configuration Extensions provide a way to identify files and other configuration data that Cloud Control does not already collect.

In this blog, I’ll show you how I created a Configuration Extension (CE) in order to collect DB Services data.

CE’s are found under the Enterprise -> Configuration menus.

While in the CE dashboard, you can create, edit, delete and deploy CE’s using the available menu.

Let’s click the “Create” button.

Using the CE create wizard type a name for the CE, a target type and a Sample Target. As soon as you select “Database Instance” for the Target Type a new option will enable. This option is to select between “Files & Commands” or “SQL”.

In this example I’m going to choose “SQL” and then type the required SQL required to retrieve the data I need from the DB. Let’s type “select name as service_name from dba_services”. Also type “service_name” in the alias section and choose the “Database Query Parser”.

The entries should look similar to the screenshot above.

The data extracted from the DB in the CE is in XML format. We need to add parser rules in order to match and identify nodes in the parsed tree. Click on the number of “Rules” in the table. In this case click on the number “0”.

On the Parser Rule page click “Add” and type this condition and expression:

  • Condition: /root/row
  • Expression: SERVICE_NAME/text()

This will allow the parser to use the text inside the SERVICE_NAME node as the name of the row. Click the return button.

Now we can click on the “Preview” button from the menu.

It will show you the preview output. Similar like this:

Click “OK” and then click “Save”.

Select your newly created CE and click on “Manage Deployments” button. Select the targets where you want to deploy the CEs and click “Apply”.

It will look similar to the screen below:

Navigate to the configuration of your target and verify the CE is correctly pulling the desired configuration data.

Now we have our CE correctly gathering the desired configuration data of our DB.

You can find the documentation for Configuration Extensions below.



Hope this helps to provide some clarity on how to create Configuration Extensions in Oracle Enterprise Manager.

Thanks,
Alfredo