Skip to content

Commit 37e0c65

Browse files
final modifications
final modifications
1 parent 4d29a17 commit 37e0c65

File tree

3 files changed

+87
-110
lines changed

3 files changed

+87
-110
lines changed

manageability-and-operations/observability-and-manageability/database-management/Custom Metrics/README.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
1-
# Creating Metric Extensions for Database using OCI Database Management Service
1+
# Creating Metric Extensions for Oracle Database using OCI Database Management Service
22

3-
Metric Extensions are helpful when the metric you are looking for doesn't exist out of the box. In such cases, you may create your own custom metric and use it for monitoring the database.
3+
Metric extensions are useful when the metric you are looking for does not exist out of the box. In such cases, you can create your own custom metric and use it for monitoring your database.
44

55
This guide explains how to create metric extensions step by step.
66

77
## What Are Metric Extensions?
88

9-
**Metric Extensions** are custom, user-defined SQL-based metrics collected by OCI Database Management. They supplement standard metrics, providing additional insights (e.g., error counts, job statuses, or resource KPIs not tracked by default).
9+
**Metric extensions** are custom, user-defined, SQL-based metrics collected by OCI Database Management. They supplement standard metrics, providing additional insights (for example, error counts, job statuses, or resource KPIs not tracked by default).
1010

1111
## Note
12-
[Metric Extensions](https://docs.oracle.com/en-us/iaas/database-management/doc/work-metric-extensions.html#DBMGM-GUID-6D5E80AA-ABA5-4FBA-A63F-106CEE39C3F7) is currently only available for External Databases. Hence if the database is an OCI database, as in this case (Oracle Base Database), then it needs to be registered in Database Management as an External Database.
12+
[Metric extensions](https://docs.oracle.com/en-us/iaas/database-management/doc/work-metric-extensions.html#DBMGM-GUID-6D5E80AA-ABA5-4FBA-A63F-106CEE39C3F7) are currently available **only for External Databases**. Therefore, if your database is an OCI database (as in this case, Oracle Base Database), it must be registered in Database Management as an External Database.
1313

1414
## Prerequisites
1515

16-
- OCI tenancy with Database Management enabled
17-
- Target Oracle Database registered in Database Management as [External Database](https://docs.oracle.com/en-us/iaas/database-management/doc/external-database-related-prerequisite-tasks.html#DBMGM-GUID-84B74F18-F672-4DDC-8505-ACF249293D64)
18-
- Have the required [policies](https://docs.oracle.com/en-us/iaas/database-management/doc/perform-general-oracle-cloud-infrastructure-prerequisite-tasks.html#DBMGM-GUID-DCC3067D-5123-468E-A938-D310CC685674) in place
16+
- OCI tenancy with Database Management enabled.
17+
- Target Oracle Database registered in Database Management as an [External Database](https://docs.oracle.com/en-us/iaas/database-management/doc/external-database-related-prerequisite-tasks.html#DBMGM-GUID-84B74F18-F672-4DDC-8505-ACF249293D64).
18+
- Required [policies](https://docs.oracle.com/en-us/iaas/database-management/doc/perform-general-oracle-cloud-infrastructure-prerequisite-tasks.html#DBMGM-GUID-DCC3067D-5123-468E-A938-D310CC685674) in place.
1919

2020
## Step-by-Step Guide
21-
[Implementation Steps](./create_metric_extension.md)
2221

23-
# License
22+
See [Implementation Steps](./create_metric_extension.md) for details.
23+
24+
## License
2425

2526
Copyright (c) 2025 Oracle and/or its affiliates.
2627

manageability-and-operations/observability-and-manageability/database-management/Custom Metrics/create_metric_extension.md

Lines changed: 76 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
2-
# **Implementation Steps**
1+
# Implementation Steps
32

43
<table>
54
<tbody>
@@ -13,14 +12,12 @@
1312
<td align="left">1</td>
1413
<td align="left">
1514
<b>Navigate to Database Management</b><br>
16-
17-
• Go to OCI Console > Observability & Management > Database Management.<br>
18-
• Click on Administration > Metric Extensions.<br>
19-
• Choose the target database for which you want to create the metric extension.<br><br>
20-
21-
<img src="./images/ME1.png" height="100" width="200" align="left">
22-
23-
&nbsp;
15+
<ul>
16+
<li>Go to OCI Console &gt; Observability &amp; Management &gt; Database Management.</li>
17+
<li>Click on <b>Administration &gt; Metric Extensions</b>.</li>
18+
<li>Choose the target database for which you want to create the metric extension.</li>
19+
</ul>
20+
<img src="./images/ME1.png" height="100" width="200">
2421
</td>
2522
<td align="left">
2623
Ensure that Database Management is already enabled for your target database before proceeding with metric extension creation.
@@ -30,88 +27,78 @@ Ensure that Database Management is already enabled for your target database befo
3027
<tr>
3128
<td align="left">2</td>
3229
<td align="left">
33-
<b>Create Metric Extension at the CDB level</b><br>
34-
35-
• Click on Create Metric Extension.<br>
36-
• Fill in the metric extension details as shown below —
30+
<b>Create a Metric Extension at the CDB Level</b><br>
31+
<ul>
32+
<li>Click on <b>Create Metric Extension</b>.</li>
33+
<li>Fill in the metric extension details as shown below:</li>
34+
</ul>
3735

3836
<b>Example: Current Number of Active Sessions</b><br>
3937

40-
```sql
41-
SELECT COUNT(*) AS active_sessions
38+
<pre><code>SELECT COUNT(*) AS active_sessions
4239
FROM V$SESSION
43-
WHERE STATUS = 'ACTIVE';
44-
```
40+
WHERE STATUS = 'ACTIVE';</code></pre>
41+
<p>Use this when the target level is CDB.</p>
4542

46-
Use this when target level is CDB.
47-
48-
<img src="./images/ME2.png" height="100" width="200" >&nbsp;&nbsp;&nbsp;
49-
<img src="./images/ME3.png" height="100" width="200" ><br>
50-
51-
&nbsp;
43+
<img src="./images/ME2.png" height="100" width="200"><br><br>
44+
<img src="./images/ME3.png" height="100" width="200"><br>
5245
</td>
5346
<td align="left">
54-
The SQL must return only one value to represent the metric point on the graph. It could be a string or a number.
55-
56-
The unit field must be a valid unit: 'percent', 'count', 'seconds', 'MB', etc.
47+
The SQL must return only one value to represent the metric point on the graph. It must be a numeric value.<br><br>
48+
The unit field must be a valid unit: <code>percent</code>, <code>count</code>, <code>seconds</code>, <code>MB</code>, etc.
5749
</td>
5850
</tr>
5951

6052
<tr>
6153
<td align="left">3</td>
6254
<td align="left">
6355
<b>Test the Metric Extension</b><br>
64-
65-
Enter the details as shown in the example above and click on Create and test.
66-
67-
In the next window, select the database to test with and click on Test as shown below.
68-
56+
<ul>
57+
<li>Enter the details as shown in the example above and click on <b>Create and test</b>.</li>
58+
<li>In the next window, select the database to test with and click on <b>Test</b> as shown below.</li>
59+
</ul>
6960
<img src="./images/ME4.png" height="100" width="200"><br>
70-
71-
It may take a few seconds to a couple of minutes to complete the tests and return the results. Once you see “Success,” the results will be displayed.
72-
61+
<p>It may take a few seconds to a couple of minutes to complete the test and return the results. Once you see “Success,” the results will be displayed.</p>
7362
<img src="./images/ME5.png" height="100" width="200"><br>
74-
75-
Note the Test ID here.
63+
<p>Note the Test ID here.</p>
7664
</td>
7765
<td align="left">
7866
The metric extension will fail if:<br>
79-
- SQL is invalid.<br>
67+
- The SQL is invalid.<br>
8068
- Required privileges are missing.<br>
81-
- Output columns or types are incorrect.<br>
82-
83-
Hence login to the DB beforehand and test the SQL first to ensure the queries are valid and return the expected data.
69+
- Output columns or data types are incorrect.<br>
70+
<br>
71+
It is recommended to log in to the database and test your SQL query beforehand to ensure it is valid and returns the expected data.
8472
</td>
8573
</tr>
8674

8775
<tr>
8876
<td align="left">4</td>
8977
<td align="left">
9078
<b>Verify Metric in Monitoring Service</b><br>
91-
• Leave the previous page as it is and open a new tab or duplicate the tab and follow the steps below.<br>
92-
• From the main menu — OCI Console > Observability & Management > Monitoring > Metrics Explorer<br>
93-
• Now select the following as shown. Note that the metric namespace would be the one ending with appmgmt_test and click on Update Chart.<br>
94-
79+
<ul>
80+
<li>Leave the previous page as is, and open a new tab (or duplicate the tab) to follow these steps:</li>
81+
<li>From the main menu, go to OCI Console &gt; Observability &amp; Management &gt; Monitoring &gt; Metrics Explorer.</li>
82+
<li>Select the following options as shown. Note that the metric namespace will end with <code>appmgmt_test</code>. Click on <b>Update Chart</b>.</li>
83+
</ul>
9584
<img src="./images/ME6.png" height="100" width="200"><br>
9685
<img src="./images/ME7.png" height="100" width="200"><br>
97-
Then you will be able to view this metric in the metric graph above.
86+
<p>You will be able to view the metric in the chart above.</p>
9887
</td>
9988
<td align="left">
100-
During testing phase, use the namespace ending with "appmgmt_test" to verify the metric is working correctly before publishing.
89+
During the testing phase, use the namespace ending with <code>appmgmt_test</code> to verify that the metric is working as expected before publishing.
10190
</td>
10291
</tr>
10392

10493
<tr>
10594
<td align="left">5</td>
10695
<td align="left">
10796
<b>Publish the Metric</b><br>
108-
109-
Now that we successfully see what we want, let us go ahead and publish this metric.<br>
110-
Go back to the metric extension page, click on Publish and then confirm Publish.
111-
97+
<ul>
98+
<li>Once you have confirmed the metric is working, return to the metric extension page and click on <b>Publish</b>. Then confirm the publish operation.</li>
99+
</ul>
112100
<img src="./images/ME8.png" height="100" width="200"><br>
113-
114-
It should now be listed in the main page of Metric Extensions as shown.<br>
101+
<p>The metric extension will now be listed on the main page of Metric Extensions as shown:</p>
115102
<img src="./images/ME9.png" height="100" width="200"><br>
116103
</td>
117104
<td align="left">
@@ -122,109 +109,97 @@ Publishing makes the metric extension available for enabling on target databases
122109
<tr>
123110
<td align="left">6</td>
124111
<td align="left">
125-
<b>Enable Metric Extension</b><br>
126-
127-
Click on the 3-dots menu and click on Enable > Select resources.<br>
128-
Select the database from the list and click Enable on selected resources.<br>
129-
Confirm Enable again when asked.<br>
130-
131-
<img src="./images/ME10.png" height="100" width="200"><br>
132-
133-
134-
<img src="./images/ME11.png" height="100" width="200"><br>
135-
112+
<b>Enable the Metric Extension</b><br>
113+
<ul>
114+
<li>Click on the three-dots menu and select <b>Enable &gt; Select resources</b>.</li>
115+
<li>Select the database from the list and click <b>Enable on selected resources</b>.</li>
116+
<li>Confirm the enable action when prompted.</li>
117+
</ul>
118+
<img src="./images/ME10.png" height="100" width="200"><br><br>
119+
<img src="./images/ME11.png" height="100" width="200"><br><br>
136120
<img src="./images/ME12.png" height="100" width="200"><br>
137-
138-
This will take some time to execute and once you see success, check back after at least 5–6 minutes to see at least 2 metric points on the Metrics Explorer graph as shown below.
121+
<p>This may take some time to execute. After you see success, check back after at least 5–6 minutes to see at least two metric points on the Metrics Explorer graph, as shown below.</p>
139122
</td>
140123
<td align="left">
141-
Allow sufficient time for the metric collection to start. Initial data points may take 5-6 minutes to appear in the monitoring system.
124+
Allow sufficient time for metric collection to start. Initial data points may take 56 minutes to appear in the monitoring system.
142125
</td>
143126
</tr>
144127

145128
<tr>
146129
<td align="left">7</td>
147130
<td align="left">
148131
<b>View Metrics in Monitoring Service</b><br>
149-
150-
Now that we have already published the metric extension, make sure to select the namespace appmgmt and not the test one as before.<br>
151-
132+
<ul>
133+
<li>After publishing the metric extension, make sure to select the namespace <code>appmgmt</code> (not the test one used earlier).</li>
134+
</ul>
152135
<img src="./images/ME13.png" height="100" width="200"><br>
153-
154-
Click on Update Chart and review the graph.<br>
136+
<p>Click on <b>Update Chart</b> and review the graph:</p>
155137
<img src="./images/ME14.png" height="100" width="200"><br>
156-
157-
Click on Show Data Table to see the metric values clearly<br>
138+
<p>Click on <b>Show Data Table</b> to see the metric values clearly:</p>
158139
<img src="./images/ME15.png" height="100" width="200"><br>
159-
160140
</td>
161141
<td align="left">
162-
After publishing, use the "appmgmt" namespace (not the test namespace) to view production metrics data.
142+
After publishing, use the <code>appmgmt</code> namespace (not the test namespace) to view production metrics data.
163143
</td>
164144
</tr>
165145

166146
<tr>
167147
<td align="left">8</td>
168148
<td align="left">
169-
<b>Create Metric Extension at the PDB level — % Storage Used in SYSTEM Tablespace in PDB</b><br><br>
170-
171-
```sql
172-
SELECT
149+
<b>Create a Metric Extension at the PDB Level — % Storage Used in SYSTEM Tablespace in PDB</b><br>
150+
<br>
151+
<pre><code>SELECT
173152
ROUND((1 - (b.BYTES_FREE / a.BYTES_ALLOC)) * 100, 2) AS pct_used
174153
FROM
175154
(SELECT SUM(BYTES) AS BYTES_ALLOC
176155
FROM DBA_DATA_FILES
177156
WHERE TABLESPACE_NAME = 'SYSTEM') a,
178157
(SELECT SUM(BYTES) AS BYTES_FREE
179158
FROM DBA_FREE_SPACE
180-
WHERE TABLESPACE_NAME = 'SYSTEM') b;
181-
```
182-
183-
Use this when Target Level is PDB.
184-
185-
Follow the exact same steps as we did for CDB query above. I will only note the changes below.<br>
159+
WHERE TABLESPACE_NAME = 'SYSTEM') b;</code></pre>
160+
<p>Use this when the target level is PDB.</p>
161+
<ul>
162+
<li>Follow the same steps as for the CDB-level query above. Note the following changes:</li>
163+
</ul>
186164
<img src="./images/ME16.png" height="100" width="200"><br>
187-
Select Pluggable DB for PDB level query. Test, Publish and Enable as we did earlier.<br>
165+
<p>Select Pluggable DB for PDB-level queries. Test, publish, and enable as before.</p>
188166
<img src="./images/ME17.png" height="100" width="200"><br>
189-
190167
</td>
191168
<td align="left">
192-
For PDB-level metrics, ensure you select "Pluggable DB" as the target level and that the SQL query is appropriate for PDB context.
169+
For PDB-level metrics, ensure you select "Pluggable DB" as the target level and that the SQL query is appropriate for the PDB context.
193170
</td>
194171
</tr>
195172

196173
<tr>
197174
<td align="left">9</td>
198175
<td align="left">
199176
<b>View PDB Metrics</b><br>
200-
201-
Go to Monitoring -> Metrics Explorer and select these options.<br>
202-
177+
<ul>
178+
<li>Go to Monitoring &gt; Metrics Explorer and select the appropriate options.</li>
179+
</ul>
203180
<img src="./images/ME18.png" height="100" width="200"><br>
204-
205-
Click on Update to view the captured metrics.<br>
181+
<p>Click <b>Update</b> to view the captured metrics.</p>
206182
<img src="./images/ME19.png" height="100" width="200"><br>
207183
</td>
208184
<td align="left">
209185
PDB-level metrics will appear under the same monitoring namespace but will be specific to the pluggable database context.
210186
</td>
211187
</tr>
212-
213188
</tbody>
214189
</table>
215190

216-
## **Important Notes**
191+
## Important Notes
217192

218-
- The SQL must return only one value to represent the metric point on the graph. It could be a string or a number.
219-
- The unit field must be a valid unit: 'percent', 'count', 'seconds', 'MB', etc.
193+
- The SQL must return only one value to represent the metric point on the graph. It must be a numeric value.
194+
- The unit field must be a valid unit: <code>percent</code>, <code>count</code>, <code>seconds</code>, <code>MB</code>, etc.
220195
- The metric extension will fail if:
221-
- SQL is invalid.
196+
- The SQL is invalid.
222197
- Required privileges are missing.
223198
- Output columns or types are incorrect.
224199

225-
Here's an example of what an incorrect SQL query error would look like during Test phase.<br>
200+
Here is an example of an error that would occur with an incorrect SQL query during the test phase:<br>
226201
<img src="./images/ME20.png" height="100" width="200"><br>
227-
Hence login to the DB beforehand and test the SQL first to ensure the queries are valid and return the expected data.
202+
It is recommended to log in to the database and test the SQL first to ensure the queries are valid and return the expected data.
228203

229204
---
230205

manageability-and-operations/observability-and-manageability/database-management/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Reviewed: 27.09.2024
1414
- [Database Management Demo](https://www.youtube.com/watch?v=3k9jrkOlBkc)
1515
- [OCI Database Management PDB Support](https://learnoci.cloud/oci-database-management-new-features-announced-f9991cba2cc2)
1616
- [How to enable OCI Observability for OCI native database deploy](https://medium.com/@erikasciunzi/enable-observability-for-oci-native-database-deploy-235484953e46)
17+
- [Creating Metric Extensions for Oracle Database using OCI Database Management Service](./Custom%20Metrics/README.md)
1718

1819
# Useful Links
1920

0 commit comments

Comments
 (0)