|
| 1 | +# Implementation Steps |
| 2 | + |
| 3 | +<table> |
| 4 | +<tbody> |
| 5 | +<tr> |
| 6 | +<th align="left">Steps</th> |
| 7 | +<th align="left">Description</th> |
| 8 | +<th align="left">Notes</th> |
| 9 | +</tr> |
| 10 | + |
| 11 | +<tr> |
| 12 | +<td align="left">1</td> |
| 13 | +<td align="left"> |
| 14 | +<b>Navigate to Database Management</b><br> |
| 15 | +<ul> |
| 16 | +<li>Go to OCI Console > Observability & Management > Database Management.</li> |
| 17 | +<li>Click on <b>Administration > 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"> |
| 21 | +</td> |
| 22 | +<td align="left"> |
| 23 | +Ensure that Database Management is already enabled for your target database before proceeding with metric extension creation. |
| 24 | +</td> |
| 25 | +</tr> |
| 26 | + |
| 27 | +<tr> |
| 28 | +<td align="left">2</td> |
| 29 | +<td align="left"> |
| 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> |
| 35 | + |
| 36 | +<b>Example: Current Number of Active Sessions</b><br> |
| 37 | + |
| 38 | +<pre><code>SELECT COUNT(*) AS active_sessions |
| 39 | +FROM V$SESSION |
| 40 | +WHERE STATUS = 'ACTIVE';</code></pre> |
| 41 | +<p>Use this when the target level is CDB.</p> |
| 42 | + |
| 43 | +<img src="./images/ME2.png" height="100" width="200"><br><br> |
| 44 | +<img src="./images/ME3.png" height="100" width="200"><br> |
| 45 | +</td> |
| 46 | +<td align="left"> |
| 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. |
| 49 | +</td> |
| 50 | +</tr> |
| 51 | + |
| 52 | +<tr> |
| 53 | +<td align="left">3</td> |
| 54 | +<td align="left"> |
| 55 | +<b>Test the Metric Extension</b><br> |
| 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> |
| 60 | +<img src="./images/ME4.png" height="100" width="200"><br> |
| 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> |
| 62 | +<img src="./images/ME5.png" height="100" width="200"><br> |
| 63 | +<p>Note the Test ID here.</p> |
| 64 | +</td> |
| 65 | +<td align="left"> |
| 66 | +The metric extension will fail if:<br> |
| 67 | +- The SQL is invalid.<br> |
| 68 | +- Required privileges are missing.<br> |
| 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. |
| 72 | +</td> |
| 73 | +</tr> |
| 74 | + |
| 75 | +<tr> |
| 76 | +<td align="left">4</td> |
| 77 | +<td align="left"> |
| 78 | +<b>Verify Metric in Monitoring Service</b><br> |
| 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 > Observability & Management > Monitoring > 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> |
| 84 | +<img src="./images/ME6.png" height="100" width="200"><br> |
| 85 | +<img src="./images/ME7.png" height="100" width="200"><br> |
| 86 | +<p>You will be able to view the metric in the chart above.</p> |
| 87 | +</td> |
| 88 | +<td align="left"> |
| 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. |
| 90 | +</td> |
| 91 | +</tr> |
| 92 | + |
| 93 | +<tr> |
| 94 | +<td align="left">5</td> |
| 95 | +<td align="left"> |
| 96 | +<b>Publish the Metric</b><br> |
| 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> |
| 100 | +<img src="./images/ME8.png" height="100" width="200"><br> |
| 101 | +<p>The metric extension will now be listed on the main page of Metric Extensions as shown:</p> |
| 102 | +<img src="./images/ME9.png" height="100" width="200"><br> |
| 103 | +</td> |
| 104 | +<td align="left"> |
| 105 | +Publishing makes the metric extension available for enabling on target databases in production. |
| 106 | +</td> |
| 107 | +</tr> |
| 108 | + |
| 109 | +<tr> |
| 110 | +<td align="left">6</td> |
| 111 | +<td align="left"> |
| 112 | +<b>Enable the Metric Extension</b><br> |
| 113 | +<ul> |
| 114 | +<li>Click on the three-dots menu and select <b>Enable > 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> |
| 120 | +<img src="./images/ME12.png" height="100" width="200"><br> |
| 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> |
| 122 | +</td> |
| 123 | +<td align="left"> |
| 124 | +Allow sufficient time for metric collection to start. Initial data points may take 5–6 minutes to appear in the monitoring system. |
| 125 | +</td> |
| 126 | +</tr> |
| 127 | + |
| 128 | +<tr> |
| 129 | +<td align="left">7</td> |
| 130 | +<td align="left"> |
| 131 | +<b>View Metrics in Monitoring Service</b><br> |
| 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> |
| 135 | +<img src="./images/ME13.png" height="100" width="200"><br> |
| 136 | +<p>Click on <b>Update Chart</b> and review the graph:</p> |
| 137 | +<img src="./images/ME14.png" height="100" width="200"><br> |
| 138 | +<p>Click on <b>Show Data Table</b> to see the metric values clearly:</p> |
| 139 | +<img src="./images/ME15.png" height="100" width="200"><br> |
| 140 | +</td> |
| 141 | +<td align="left"> |
| 142 | +After publishing, use the <code>appmgmt</code> namespace (not the test namespace) to view production metrics data. |
| 143 | +</td> |
| 144 | +</tr> |
| 145 | + |
| 146 | +<tr> |
| 147 | +<td align="left">8</td> |
| 148 | +<td align="left"> |
| 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 |
| 152 | + ROUND((1 - (b.BYTES_FREE / a.BYTES_ALLOC)) * 100, 2) AS pct_used |
| 153 | +FROM |
| 154 | + (SELECT SUM(BYTES) AS BYTES_ALLOC |
| 155 | + FROM DBA_DATA_FILES |
| 156 | + WHERE TABLESPACE_NAME = 'SYSTEM') a, |
| 157 | + (SELECT SUM(BYTES) AS BYTES_FREE |
| 158 | + FROM DBA_FREE_SPACE |
| 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> |
| 164 | +<img src="./images/ME16.png" height="100" width="200"><br> |
| 165 | +<p>Select Pluggable DB for PDB-level queries. Test, publish, and enable as before.</p> |
| 166 | +<img src="./images/ME17.png" height="100" width="200"><br> |
| 167 | +</td> |
| 168 | +<td align="left"> |
| 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. |
| 170 | +</td> |
| 171 | +</tr> |
| 172 | + |
| 173 | +<tr> |
| 174 | +<td align="left">9</td> |
| 175 | +<td align="left"> |
| 176 | +<b>View PDB Metrics</b><br> |
| 177 | +<ul> |
| 178 | +<li>Go to Monitoring > Metrics Explorer and select the appropriate options.</li> |
| 179 | +</ul> |
| 180 | +<img src="./images/ME18.png" height="100" width="200"><br> |
| 181 | +<p>Click <b>Update</b> to view the captured metrics.</p> |
| 182 | +<img src="./images/ME19.png" height="100" width="200"><br> |
| 183 | +</td> |
| 184 | +<td align="left"> |
| 185 | +PDB-level metrics will appear under the same monitoring namespace but will be specific to the pluggable database context. |
| 186 | +</td> |
| 187 | +</tr> |
| 188 | +</tbody> |
| 189 | +</table> |
| 190 | + |
| 191 | +## Important Notes |
| 192 | + |
| 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. |
| 195 | +- The metric extension will fail if: |
| 196 | + - The SQL is invalid. |
| 197 | + - Required privileges are missing. |
| 198 | + - Output columns or types are incorrect. |
| 199 | + |
| 200 | +Here is an example of an error that would occur with an incorrect SQL query during the test phase:<br> |
| 201 | +<img src="./images/ME20.png" height="100" width="200"><br> |
| 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. |
| 203 | + |
| 204 | +--- |
| 205 | + |
| 206 | +# License <!-- omit from toc --> |
| 207 | + |
| 208 | +Copyright (c) 2025 Oracle and/or its affiliates. |
| 209 | + |
| 210 | +Licensed under the Universal Permissive License (UPL), Version 1.0. |
| 211 | + |
| 212 | +See [LICENSE](/LICENSE) for more details. |
0 commit comments