Create a Metric Extension Template
You can create a Metric Extension Template to define the SQL query, bind variables, metrics, dimensions, and recommended collection settings for Metric Extensions.
Ensure that the template’s SQL query is applicable to the selected databases and that the database users used for testing and metric collection have the privileges required to run it.
To create a Metric Extension Template:
- Sign in to the Oracle Cloud Infrastructure console.
- Open the navigation menu, click Observability & Management. Under Database Management, click Administration.
- In the left pane, under Template Library, click Metric Extension Templates.
- Ensure that the correct compartment is selected in the Compartment applied filter.
- Click Create metric extension template.
- In the Create Metric Extension template panel:
- Provide the template information:
- Name: Enter a name for the template.
- Description: Optionally, enter a description for the Metric Extension Template.
- Monitoring namespace: Specify the namespace in which the collected metrics will be published. For new Metric Extensions, use a custom namespace. Namespaces beginning with
oracle_oroci_are not supported, exceptoracle_metric_extensions_appmgmt, which is retained for compatibility with legacy Metric Extensions. - Monitoring resource group: Optionally, specify a resource group name to organize the collected metrics within the Monitoring namespace.
You can change the Monitoring namespace and resource group when creating a Metric Extension from the template.
- Specify the recommended collection schedule:
- Schedule unit: Select the unit for the collection interval.
- Schedule value: Select the collection interval value.
You can choose a different schedule for each Metric Extension.
- Provide the metric query. In the SQL query field, enter a read-only SQL query without a trailing semicolon. Every column returned by the top-level query must represent a metric or dimension and have a double-quoted alias:
- Use the
metric_prefix for numeric metric values. - Use the
dimension_prefix for dimensions.
For example, the following query defines the metric
UsedPercentand the dimensionTablespaceName.SELECT tablespace_name AS "dimension_TablespaceName", used_percent AS "metric_UsedPercent" FROM dba_tablespace_usage_metrics WHERE tablespace_name = :tablespace_namePerform calculations within the SQL query; separate hidden columns and post-query compute expressions are not supported.
Note
Database Management adds theresourceIdandresourceNamedimensions to the collected metrics. Do not declare these dimensions in the template query. - Use the
- If the SQL query uses bind variables, in the Bind variables section, click Add bind variable and configure the following fields:
- Name: Specify the bind variable name used in the SQL query.
- Data type: Select the data type of the bind variable.
- Required at runtime: Enable this option to require a value when testing the template or creating a Metric Extension.
- Default value: Specify a default value if Required at runtime is not enabled.
- Description: Optionally, enter a description of the bind variable.
For the example in the SQL query step, configure the
tablespace_namebind variable with Data type set to String, enable Required at runtime, and leave the default value unset. Supply its value when testing the template and creating a Metric Extension.
- Provide the template information:
- Click Create.
The new template is listed on the Metric Extension Templates page with the Draft status.
You can click the Actions icon (
) for the template and perform the following tasks:
- Edit: Click to update the template information, recommended collection schedule, SQL query, or bind variable definitions. For published templates, only the name and description can be edited.
- Test: Click to test the template against a Managed Database and review the query results.
- Clone: Click to create a copy of the template.
- Publish: Click to publish the draft template and make it available for creating Metric Extensions.
- Create Metric Extension: Click to create a Metric Extension from a published template.
- Delete: Click to delete the draft template.
- Copy OCID: Click to copy the template’s OCID.