14 Jun 2024 03:44 PM - last edited on 17 Jun 2024 07:41 AM by MaciejNeumann
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!
Solved! Go to Solution.
18 Jun 2024 03:18 PM
If we the expression and compare it with relationship definitions from `extension.yaml` downloadable from the Hub we can verify it step by step:
# 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:
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:
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:
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.