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:

  1. Sign in to the Oracle Cloud Infrastructure console.
  2. Open the navigation menu, click Observability & Management. Under Database Management, click Administration.
  3. In the left pane, under Template Library, click Metric Extension Templates.
  4. Ensure that the correct compartment is selected in the Compartment applied filter.
  5. Click Create metric extension template.
  6. In the Create Metric Extension template panel:
    1. Provide the template information:
      1. Name: Enter a name for the template.
      2. Description: Optionally, enter a description for the Metric Extension Template.
      3. 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_ or oci_ are not supported, except oracle_metric_extensions_appmgmt, which is retained for compatibility with legacy Metric Extensions.
      4. 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.

    2. Specify the recommended collection schedule:
      1. Schedule unit: Select the unit for the collection interval.
      2. Schedule value: Select the collection interval value.

      You can choose a different schedule for each Metric Extension.

    3. 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 UsedPercent and the dimension TablespaceName.

      SELECT tablespace_name AS "dimension_TablespaceName",
             used_percent AS "metric_UsedPercent"
      FROM dba_tablespace_usage_metrics
      WHERE tablespace_name = :tablespace_name

      Perform calculations within the SQL query; separate hidden columns and post-query compute expressions are not supported.

      Note

      Database Management adds the resourceId and resourceName dimensions to the collected metrics. Do not declare these dimensions in the template query.
    4. If the SQL query uses bind variables, in the Bind variables section, click Add bind variable and configure the following fields:
      1. Name: Specify the bind variable name used in the SQL query.
      2. Data type: Select the data type of the bind variable.
      3. Required at runtime: Enable this option to require a value when testing the template or creating a Metric Extension.
      4. Default value: Specify a default value if Required at runtime is not enabled.
      5. Description: Optionally, enter a description of the bind variable.

      For the example in the SQL query step, configure the tablespace_name bind 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.

  7. Click Create.

    The new template is listed on the Metric Extension Templates page with the Draft status.

You can click the Actions icon (Actions) 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.