# How do I create custom metric alert on Oracle DB instance for the metric I am getting out of my custom SQL Extension?

**URL:** <https://community.dynatrace.com/t/how-do-i-create-custom-metric-alert-on-oracle-db-instance-for-the-metric-i-am-getting-out-of-my-custom-sql-extension/46429>\
**Category:** Extensions\
**Tags:** databases, oracle, extensions\
**Created:** [July 2, 2024, 7:16pm UTC](https://community.dynatrace.com/t/how-do-i-create-custom-metric-alert-on-oracle-db-instance-for-the-metric-i-am-getting-out-of-my-custom-sql-extension/46429 "2024-07-02T19:16:47Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![susmita\_k](https://avatars.discourse-cdn.com/v4/letter/s/7993a0/32.png) [@susmita\_k](https://community.dynatrace.com/u/susmita_k)\
**Post date:** [July 2, 2024, 7:16pm UTC](https://community.dynatrace.com/t/how-do-i-create-custom-metric-alert-on-oracle-db-instance-for-the-metric-i-am-getting-out-of-my-custom-sql-extension/46429/1 "2024-07-02T19:16:47Z")

</div>

How do I create custom metric alert on Oracle DB instance for the metric I am getting out of my custom SQL Extension?

I am adding a dimension of custom device by adding custom device filter for the DB instance, but its creating the problem at the environment level. Please suggest.. Do I need to add a dimension in my Extension yaml file ?

---

<div class="post-metadata">

**Author:** ![rudy\_h](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/rudy_h/32/5153_2.png) [@rudy\_h](https://community.dynatrace.com/u/rudy_h)\
**Post date:** [July 3, 2024, 6:39am UTC](https://community.dynatrace.com/t/how-do-i-create-custom-metric-alert-on-oracle-db-instance-for-the-metric-i-am-getting-out-of-my-custom-sql-extension/46429/2 "2024-07-03T06:39:07Z")

</div>

His Susmita,

You may create json files inside alerts folder to define your custom metric alert:

 ![rudy_h_0-1719988713983.png](https://global.discourse-cdn.com/dynatrace/original/2X/7/7a2b7b1c0b994d3fad71b3be8503efee508edc1b.png)

Best Regards,

Rudy

---

<div class="post-metadata">

**Author:** ![susmita\_k](https://avatars.discourse-cdn.com/v4/letter/s/7993a0/32.png) [@susmita\_k](https://community.dynatrace.com/u/susmita_k)\
**Post date:** [July 3, 2024, 12:55pm UTC](https://community.dynatrace.com/t/how-do-i-create-custom-metric-alert-on-oracle-db-instance-for-the-metric-i-am-getting-out-of-my-custom-sql-extension/46429/3 "2024-07-03T12:55:34Z")

</div>

Thanks&nbsp;[@rudy\_h](https://community.dynatrace.com/user/72098). However, I am trying to use the new davis anomaly detector where I am able to create the alert. But the alert is being created at environment level instead of the database instance. I am looking for option on how do configure the source entity to fix this.

---

<div class="post-metadata">

**Author:** ![Mike\_L](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/mike_l/32/11717_2.png) [@Mike\_L](https://community.dynatrace.com/u/Mike_L)\
**Post date:** [July 3, 2024, 3:16pm UTC](https://community.dynatrace.com/t/how-do-i-create-custom-metric-alert-on-oracle-db-instance-for-the-metric-i-am-getting-out-of-my-custom-sql-extension/46429/4 "2024-07-03T15:16:47Z")

</div>

How does your yaml look like? Make sure that the metrics it reports are attached to a generic entity, and that the metrics have that entity type as the&nbsp;sourceEntityType in the metric metadata.

---

<div class="post-metadata">

**Author:** ![susmita\_k](https://avatars.discourse-cdn.com/v4/letter/s/7993a0/32.png) [@susmita\_k](https://community.dynatrace.com/u/susmita_k)\
**Post date:** [July 3, 2024, 3:24pm UTC](https://community.dynatrace.com/t/how-do-i-create-custom-metric-alert-on-oracle-db-instance-for-the-metric-i-am-getting-out-of-my-custom-sql-extension/46429/5 "2024-07-03T15:24:44Z")

</div>

Hi&nbsp;[@Mike\_L](https://community.dynatrace.com/user/11520),

below is my extension.yaml. I have defined my source entity as&nbsp;sourceEntityType: sql:com\_dynatrace\_extension\_sql-oracle\_instance. That is not generic entity, but its the oracle DB extension entity. so do I need to define this entity in my extension.yaml ?

name: custom:dynatrace.x.x.x.db.ext  
version: “0.0.3”  
minDynatraceVersion: “1.283.0”  
author:  
name: Susmita  
metrics:  
- key: dynatrace.x.x.x.db.ext.gg\_replication\_status  
metadata:  
displayName: GG Replication Status  
unit: Count  
description: GG Replication Status  
metricProperties:  
valueType: error  
minValue: 0  
sourceEntityType: sql:com\_dynatrace\_extension\_sql-oracle\_instance  
sqlOracle:  
- group: Golden Gate Replication Status Check  
interval:  
minutes: 5  
subgroups:  
- subgroup: Golden Gate Replication Status Check  
featureSet: Golden Gate Replication Status Check  
ingest: metrics  
query: \>  
my Query  
metrics:  
- key: dynatrace.x.x.x.db.ext.gg\_replication\_status  
value: col:OPT\_TIME\_VAL  
type: gauge  
dimensions:  
- key: gg\_tablename  
value: col:TABLE\_NAME  
- key: gg\_ops\_time\_value  
value: col:OPT\_TIME\_VAL

---

<div class="post-metadata">

**Author:** ![Mike\_L](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/mike_l/32/11717_2.png) [@Mike\_L](https://community.dynatrace.com/u/Mike_L)\
**Post date:** [July 3, 2024, 3:31pm UTC](https://community.dynatrace.com/t/how-do-i-create-custom-metric-alert-on-oracle-db-instance-for-the-metric-i-am-getting-out-of-my-custom-sql-extension/46429/6 "2024-07-03T15:31:18Z")

</div>

This is the definition of that entity:

```markup
- name: sql:com_dynatrace_extension_sql-oracle_host
      displayName: Oracle DB Server
      enabled: true
      rules:
        - idPattern: sql_sql-oracle_{device.address}
          instanceNamePattern: '{instance.host}'
          iconPattern: databaseserver
          sources:
            - sourceType: Metrics
              condition: $prefix(com.dynatrace.extension.sql-oracle)
          attributes:
            - pattern: '{device.address}'
              key: dt.ip_addresses
              displayName: IP Addresses
            - pattern: '{device.name}'
              key: dt.dns_names
              displayName: DNS names
            - pattern: '{device.port}'
              key: dt.listen_ports
              displayName: Listener ports

```

As you can see it requires the dimension instance.host to be added to your metrics, and it requires that the metrics start with com.dynatrace.extension.sql-oracle. For you to attach metrics to that entity you’d have to rename your metrics to fit with that condition, and you’d have to query for the instance host in the group attribute, and move your other queries to the sub group so it inherits the top group dimensions.

Example top group:

```markup
- group: Instance
    query: >
      SELECT
        sys_context('USERENV', 'SERVER_HOST') as SERVER_HOST
      FROM dual
    dimensions:
      - key: instance.host
        value: col:SERVER_HOST

```

---

<div class="post-metadata">

**Author:** ![susmita\_k](https://avatars.discourse-cdn.com/v4/letter/s/7993a0/32.png) [@susmita\_k](https://community.dynatrace.com/u/susmita_k)\
**Post date:** [July 3, 2024, 3:59pm UTC](https://community.dynatrace.com/t/how-do-i-create-custom-metric-alert-on-oracle-db-instance-for-the-metric-i-am-getting-out-of-my-custom-sql-extension/46429/7 "2024-07-03T15:59:29Z")

</div>

So my yaml need to be something as below ?

name: custom:dynatrace.x.x.x.db.ext  
version: “0.0.3”  
minDynatraceVersion: “1.283.0”  
author:  
name: Susmita  
metrics:  
- key: dynatrace.x.x.x.db.ext.gg\_replication\_status  
metadata:  
displayName: GG Replication Status  
unit: Count  
description: GG Replication Status  
metricProperties:  
valueType: error  
minValue: 0  
sourceEntityType: sql:com\_dynatrace\_extension\_sql-oracle\_instance  
sqlOracle:  
- group: Instance  
query: \>  
SELECT  
sys\_context(‘USERENV’, ‘SERVER\_HOST’) as SERVER\_HOST  
FROM dual  
dimensions:  
- key: instance.host  
value: col:SERVER\_HOST  
interval:  
minutes: 5  
subgroups:  
- subgroup: Golden Gate Replication Status Check  
featureSet: Golden Gate Replication Status Check  
ingest: metrics  
query: \>  
my Query  
metrics:  
- key: dynatrace.x.x.x.db.ext.gg\_replication\_status  
value: col:OPT\_TIME\_VAL  
type: gauge  
dimensions:  
- key: gg\_tablename  
value: col:TABLE\_NAME  
- key: gg\_ops\_time\_value  
value: col:OPT\_TIME\_VAL

---

<div class="post-metadata">

**Author:** ![Mike\_L](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/mike_l/32/11717_2.png) [@Mike\_L](https://community.dynatrace.com/u/Mike_L)\
**Post date:** [July 3, 2024, 4:07pm UTC](https://community.dynatrace.com/t/how-do-i-create-custom-metric-alert-on-oracle-db-instance-for-the-metric-i-am-getting-out-of-my-custom-sql-extension/46429/8 "2024-07-03T16:07:58Z")

</div>

Much closer, you just also need to rename the metric to fulfill the metric name startsWith condition. You can check if all is correct if you can split by the Oracle entity when charting the metric in the data explorer.

---

<div class="post-metadata">

**Author:** ![susmita\_k](https://avatars.discourse-cdn.com/v4/letter/s/7993a0/32.png) [@susmita\_k](https://community.dynatrace.com/u/susmita_k)\
**Post date:** [July 3, 2024, 4:10pm UTC](https://community.dynatrace.com/t/how-do-i-create-custom-metric-alert-on-oracle-db-instance-for-the-metric-i-am-getting-out-of-my-custom-sql-extension/46429/9 "2024-07-03T16:10:32Z")

</div>

Okay, so my metric need to be like this as well -&nbsp;sql:com\_dynatrace\_extension\_gg\_replication\_status correct - ?

---

<div class="post-metadata">

**Author:** ![Mike\_L](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/mike_l/32/11717_2.png) [@Mike\_L](https://community.dynatrace.com/u/Mike_L)\
**Post date:** [July 3, 2024, 4:12pm UTC](https://community.dynatrace.com/t/how-do-i-create-custom-metric-alert-on-oracle-db-instance-for-the-metric-i-am-getting-out-of-my-custom-sql-extension/46429/10 "2024-07-03T16:12:23Z")

</div>

In the topology snippet I posted above you can see that the metric name needs to start with

```markup
com.dynatrace.extension.sql-oracle

```
