cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

DQL database service response time split by ipAddress

I would appreciate if someone could lend a hand with my query.

So I trying to get our DB2 response times split by IP-address and my current query template looks like this. 
It currently splits the data by dt.entity.ipAddress and dt.entity.service but I would need the response time summarized by IP-address without the split on different database services.

Just couldn't figure out by myself how to archive that one.

timeseries interval: 1h, response_time = sum(dt.service.request.response_time),
by: { dt.entity.ipAddress, dt.entity.service },
filter: { in(dt.entity.service, classicEntitySelector("type(service),databaseVendor(\"DB2\")")) }
| sort arraySum(response_time) desc
| fieldsAdd entityAttr(dt.entity.service, "ipAddress")
| limit 50

3 REPLIES 3

Radu
Dynatrace Champion
Dynatrace Champion

Hello. There are a couple of things wrong which I will try to explain.

First, let's understand the Service entity. It does not actually have an attribute called "ipAddress" as we do not register IP Addresses against services. Going by relation, the closest entity that holds an IP Address is the Host entity. This means that you can "walk" the relationship from the Service to the Host (if the database has a monitored host). If your database only has a Service, extracting an IP Address is not possible.

Second, some of the DQL syntax is incorrect. The `dt.entity.` prefix only applies to entity types which ipAddress is not, so we cannot use `dt.entity.ipAddress`. 

To extract the IP address from the Host, we'll first get the Host IDs and then lookup their IP Addresses.

timeseries interval: 1h,
ResponseTime = avg(dt.service.request.response_time),
by: { ServiceId = dt.entity.service },
filter: {
// Adapt the selector to look for Services related to Hosts
in(dt.entity.service, classicEntitySelector( """type("SERVICE"),databaseVendor("DB2"),fromRelationships.runsOnHost(type("HOST"))""" ))
}
// Add the service name (for readability) + Host IDs
| fieldsAdd ServiceName = entityName(ServiceId, type:"dt.entity.service")
// Service may run on multiple hosts so we need to 'expand' the array
| expand host = entityAttr(ServiceId, "runs_on", type:"dt.entity.service")[dt.entity.host]
// Now we can lookup each host's IP Addresses
| fieldsAdd IpAddresses = entityAttr(host, "ipAddress", type:"dt.entity.host")
// Remove unnecessary fields and keep result like this to see IPs per service instance
| fields timeframe, interval, ServiceId, ResponseTime, ServiceName, IpAddresses
// OR aggregate it to see IPs across all service instances
| summarize {
ResponseTime = avg(ResponseTime[]),
IpAddresses = arrayFlatten(collectArray(IpAddresses))
},
by: { timeframe, interval, ServiceId, ServiceName}

 

 I hope this helps you out.

GerardJ
Advisor

Hi @Radu
Very good and detailed explanation !
Just a little addition, entityAttr() does exist and for example we could use it like this to avoid the second lookup :

| fieldsAdd IpAddress=entityAttr(svc.host, "ipAddress", type:"dt.entity.host")

 

Gerard

Radu
Dynatrace Champion
Dynatrace Champion

Gerard, many thanks for pointing this out! It slipped my search completely.

I will rewrite my answer based on this as it simplified the query massively 🙂

Featured Posts