# Entity Selector with SQL Server extension 2.3.0

**URL:** <https://community.dynatrace.com/t/entity-selector-with-sql-server-extension-2-3-0/46128>\
**Category:** Extensions\
**Tags:** extensions\
**Created:** [June 14, 2024, 2:44pm UTC](https://community.dynatrace.com/t/entity-selector-with-sql-server-extension-2-3-0/46128 "2024-06-14T14:44:48Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![TimeZero](https://avatars.discourse-cdn.com/v4/letter/t/c37758/32.png) [@TimeZero](https://community.dynatrace.com/u/TimeZero)\
**Post date:** [June 14, 2024, 2:44pm UTC](https://community.dynatrace.com/t/entity-selector-with-sql-server-extension-2-3-0/46128/1 "2024-06-14T14:44:48Z")

</div>

Hi!

We have auto tags for “sql:sql\_server\_availability\_replica” for our SQL Servers, but since the extension upgraded to 2.3.0, it doesn’t work anymore. I know in the patch notes it says the relation changed for the entity selector, so I updated our query, but it still doesn’t work.

Here’s the old query **before** v2.3.0:  
**type(“sql:sql\_server\_availability\_replica”),toRelationships.runsOn(type(“sql:sql\_server\_availability\_database”),fromRelationships.isInstanceOf(type(“sql:sql\_server\_database”),fromRelationships.isChildOf(type(“sql:sql\_server\_instance”),fromRelationships.runsOn(type(“sql:sql\_server\_host”),fromRelationships.isSameAs(type(“HOST”),fromRelationships.isInstanceOf(type(“HOST\_GROUP”),detectedName(“xxxxxxxxxx”)))))))**

Here’s the updated query **after** v2.3.0:

**type(“sql:sql\_server\_availability\_replica”),fromRelationships.runsOn(type(“sql:sql\_server\_instance”),fromRelationships.runsOn(type(“sql:sql\_server\_host”),fromRelationships.isSameAs(type(“HOST”),fromRelationships.isInstanceOf(type(“HOST\_GROUP”),detectedName(“xxxxxxxxxx”)))))**

Any help would be appreciated, thanks!

---

<div class="post-metadata">

**Author:** ![vagiz\_duseev](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/vagiz_duseev/32/39484_2.png) [@vagiz\_duseev](https://community.dynatrace.com/u/vagiz_duseev)\
**Post date:** [June 18, 2024, 2:18pm UTC](https://community.dynatrace.com/t/entity-selector-with-sql-server-extension-2-3-0/46128/2 "2024-06-18T14:18:12Z")

</div>

If we the expression and compare it with relationship definitions from `extension.yaml` downloadable from the Hub we can verify it step by step:

```python
# Get all Availability Replica entities...
type("sql:sql_server_availability_replica"),
# ...which have a toType "RUNS_ON" relationship to Instance entities.
fromRelationships.runsOn(
  # Filter down to only those Instances...
  type("sql:sql_server_instance"),
  # ...that have a toType "RUNS_ON" relationship to SQL Host entitites.
  fromRelationships.runsOn(
    # Filter down to only those SQL Hosts...
    type("sql:sql_server_host"),
    # ...that have a toType "SAME_AS" relationship to actual HOSTs.
    fromRelationships.isSameAs(
      # And finally, only consider HOSTs that are part of the HOST_GROUP...
      type("HOST"),
      fromRelationships.isInstanceOf(
        type("HOST_GROUP"),
        # ...with a specific name.
        detectedName("xxxxxxxxxx")
      )
    )
  )
)

```

Relationship between Availability Replica to Instance:

```ruby
typeOfRelation: RUNS_ON
fromType: sql:sql_server_availability_replica
toType: sql:sql_server_instance
enabled: true
sources:
  - sourceType: Metrics
    condition: $prefix(sql-server)

```

Relationship between Instance and SQL Host:

```ruby
typeOfRelation: RUNS_ON
fromType: sql:sql_server_instance
toType: sql:sql_server_host
enabled: true
sources:
  - sourceType: Metrics
    condition: $prefix(sql-server)

```

Relationship between SQL Host and HOST:

```ruby
typeOfRelation: SAME_AS
fromType: sql:sql_server_host
toType: host
enabled: true
sources:
  - sourceType: Entities
    mappingRules:
      - sourceProperty: dt.ip_addresses
        sourceTransformation: To lower case
        destinationProperty: ipAddress
        destinationTransformation: To lower case

```

Based on the above, the expression of entity selector is correct! The only place I can see it breaking down is in the relationship between the SQL Host and HOST, where it compares the detected IP Addresses of both.

The IP Address of the SQL Server Instance we connect to must match one of the IP Addresses detected on the HOST by OneAgent. But this somehow worked in previous version.

If nothing, I recommend opening a support ticket.

---

<div class="post-metadata">

**Author:** ![nils\_stellhorn](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/nils_stellhorn/32/20154_2.png) [@nils\_stellhorn](https://community.dynatrace.com/u/nils_stellhorn)\
**Post date:** [October 21, 2025, 6:26am UTC](https://community.dynatrace.com/t/entity-selector-with-sql-server-extension-2-3-0/46128/3 "2025-10-21T06:26:27Z")

</div>

I also used that pattern, but based on metadata. Also, in the answer from vagiz\_duseev, the availability databases are missing. So here are all my tagging rules for SQL:

SQL host:

**type(“sql:sql\_server\_host”),fromRelationships.isSameAs(type(“HOST”),tag([Environment]Application:NAME))**

SQL instance:

**type(“sql:sql\_server\_instance”),fromRelationships.runsOn(type(“sql:sql\_server\_host”),fromRelationships.isSameAs(type(“HOST”),tag([Environment]Application:NAME)))**

SQL server database:

**type(sql:sql\_server\_database),fromRelationships.isChildOf(type(sql:sql\_server\_instance),fromRelationships.runsOn(type(“sql:sql\_server\_host”),fromRelationships.isSameAs(type(HOST),tag([Environment]Application:NAME))))**

SQL server availability replica:

**type(“sql:sql\_server\_availability\_replica”),fromRelationships.isSameAs(type(sql:sql\_server\_instance),fromRelationships.runsOn(type(“sql:sql\_server\_host”),fromRelationships.isSameAs(type(“HOST”),tag([Environment]Application:NAME))))**

SQL server availability group:

**type(sql:sql\_server\_availability\_group),toRelationships.isInstanceOf(type(sql:sql\_server\_availability\_replica),fromRelationships.isSameAs(type(sql:sql\_server\_instance),fromRelationships.runsOn(type(“sql:sql\_server\_host”),fromRelationships.isSameAs(type(“HOST”),tag([Environment]Application:NAME)))))**

SQL server availability database:

**type(sql:sql\_server\_availability\_database),fromRelationships.runsOn(type(sql:sql\_server\_availability\_replica),fromRelationships.isSameAs(type(sql:sql\_server\_instance),fromRelationships.runsOn(type(“sql:sql\_server\_host”),fromRelationships.isSameAs(type(“HOST”),tag([Environment]Application:NAME)))))**

---

<div class="post-metadata">

**Author:** ![Damian\_G](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/damian_g/32/2829_2.png) [@Damian\_G](https://community.dynatrace.com/u/Damian_G)\
**Post date:** [November 3, 2025, 6:39pm UTC](https://community.dynatrace.com/t/entity-selector-with-sql-server-extension-2-3-0/46128/4 "2025-11-03T18:39:39Z")

</div>

I’ve tried your tagging rules and the ones related with&nbsp;SQL host,&nbsp;SQL instance and&nbsp;SQL server database worked, but the ones related with&nbsp;SQL server availability replica,&nbsp;SQL server availability group and&nbsp;SQL server availability database didn’t return any data.

---

<div class="post-metadata">

**Author:** ![AntonPineiro](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/antonpineiro/32/49_2.png) [@AntonPineiro](https://community.dynatrace.com/u/AntonPineiro)\
**Post date:** [November 4, 2025, 7:45am UTC](https://community.dynatrace.com/t/entity-selector-with-sql-server-extension-2-3-0/46128/5 "2025-11-04T07:45:44Z")

</div>

Hi,

Topology can be different depending of SQL extension version. Maybe it was updated in a release. I would recommend checking topology relationships&nbsp;in your environment:

 ![AntonPineiro_0-1762242313580.png](https://global.discourse-cdn.com/dynatrace/original/2X/4/46e605a348c0a3c21573fb7dcf0d3103e2e62191.png)

Best regards

---

<div class="post-metadata">

**Author:** ![Damian\_G](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/damian_g/32/2829_2.png) [@Damian\_G](https://community.dynatrace.com/u/Damian_G)\
**Post date:** [November 4, 2025, 8:32am UTC](https://community.dynatrace.com/t/entity-selector-with-sql-server-extension-2-3-0/46128/6 "2025-11-04T08:32:12Z")

</div>

I’ve reviewed the settings and topology of my SQL Extension:

 ![Damian_G_0-1762244319724.png](https://global.discourse-cdn.com/dynatrace/original/2X/f/f185e77a6dc0d500d68be76f38df62f31ee84ac9.png)

**type(“sql:sql\_server\_availability\_replica”),fromRelationships.isSameAs(type(sql:sql\_server\_instance),fromRelationships.runsOn(type(“sql:sql\_server\_host”),fromRelationships.isSameAs(type(“HOST”),tag([Environment]Application:NAME))))**

should work, but I don’t get any entity.

---

<div class="post-metadata">

**Author:** ![nils\_stellhorn](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/nils_stellhorn/32/20154_2.png) [@nils\_stellhorn](https://community.dynatrace.com/u/nils_stellhorn)\
**Post date:** [November 5, 2025, 12:31pm UTC](https://community.dynatrace.com/t/entity-selector-with-sql-server-extension-2-3-0/46128/7 "2025-11-05T12:31:58Z")

</div>

Hi Damian,

I just checked it and we do indeed get the proper data from the relationship-based entity selector. I would recommend to check the relationships for your replicas via the API. You can open up the replica you’re looking at, copy the custom\_device ID and use it in the monitored entities API with the GET /entities/{entityId} API to see the relationships that are present in your environment.

---

<div class="post-metadata">

**Author:** ![AntonPineiro](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/antonpineiro/32/49_2.png) [@AntonPineiro](https://community.dynatrace.com/u/AntonPineiro)\
**Post date:** [November 5, 2025, 1:35pm UTC](https://community.dynatrace.com/t/entity-selector-with-sql-server-extension-2-3-0/46128/8 "2025-11-05T13:35:42Z")

</div>

Hi,

I would recommend create a metric selector per SQL entity:

- Adding a tag from host to sql\_server\_host (is\_same\_as).
- Adding a tag from sql\_server\_host to sql\_server\_instance (runs\_on).
- Adding a tag from sql\_server\_instance to sql\_server\_database (is\_child\_of).
- Adding a tag from&nbsp;sql\_server\_database to sql\_server\_availability\_database (is\_instante\_of).
- Adding a tag from sql\_server\_availability\_database to&nbsp;sql\_server\_availability\_replica (runs\_on).

Issue is you cannot use placeholder, it means, you need to create a custom metric selector adding tag value.

[This product idea](https://community.dynatrace.com/post/244590) would be helpful to avoid creating rules per tag.

Best regards

---

<div class="post-metadata">

**Author:** ![Damian\_G](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/damian_g/32/2829_2.png) [@Damian\_G](https://community.dynatrace.com/u/Damian_G)\
**Post date:** [November 10, 2025, 12:10pm UTC](https://community.dynatrace.com/t/entity-selector-with-sql-server-extension-2-3-0/46128/9 "2025-11-10T12:10:14Z")

</div>

Hi,

Maybe this is solved in newer versions, or maybe I’m wrong, but I couldn’t get relationships (getting information from API, also) between&nbsp;_sql\_server\_availability\_database_ and&nbsp;_sql\_server\_instance_ and, therefore, no option with&nbsp;_sql\_server\_availability\_replica_ and&nbsp;_sql\_server\_availability\_group_. I had to tag the entity using IPs:

**type(“sql:sql\_server\_availability\_database”),device(“172.20.X.X”)**

Thank you!

---

<div class="post-metadata">

**Author:** ![nils\_stellhorn](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/nils_stellhorn/32/20154_2.png) [@nils\_stellhorn](https://community.dynatrace.com/u/nils_stellhorn)\
**Post date:** [November 10, 2025, 12:57pm UTC](https://community.dynatrace.com/t/entity-selector-with-sql-server-extension-2-3-0/46128/10 "2025-11-10T12:57:56Z")

</div>

Hi Damian,

We used version 2.10.4, so we have a newer version than 2.3. Could be that indeed a newer version solves the problem. So there is no relations in the payload when you use the monitored entities API with the custom device ID?

 ![nils_stellhorn_0-1762779463079.png](https://global.discourse-cdn.com/dynatrace/original/3X/5/9/595de904aa01ecf71ed79daa228223d801db18d9.png)
