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

Query Kuberentes workloads

DamianJankowski
Observer

 

Hi,

 

Could you please help me better understand how to query entities and the relationships between them?

 

fetch dt.entity.service
| filter in(id, classicEntitySelector("type(service),fromRelationship.isServiceOf(type(CLOUD_APPLICATION),entityId(\"CLOUD_APPLICATION-D40C6BABEC087314\"))"))

 

 

 

This returns all services related to a specific cloud application. In my case, it includes:

-Requests executed in background threads of SpringBoot for dine-in-api-*

-Web-server for dine-in-api-*

 

What I want to achieve is to get the Kubernetes workload names, which are visible in the “services” application (either in the filter bar or at the top of the service page). I plan to use these names as variables in a dashboard to display metrics like response time or failure rate, split by each service.

8 REPLIES 8

krzysztof_hoja
Dynatrace Pro
Dynatrace Pro

You query is correct. We just need to make it "dynamic" and use filtering criteria "by name" instead of "by id".
In combination with getting metric you mention it will look like:

 

timeseries response_time=avg(dt.service.request.response_time), by: {dt.entity.service},
filter: in( dt.entity.service, 
  classicEntitySelector(concat("type(service),fromRelationship.isServiceOf(type(CLOUD_APPLICATION),entityName(",$Entity,"))")))
| fieldsAdd dt.entity.service.name = entityName(dt.entity.service)

 

As dimensions for this metric contains id of the service, you can add service name using entityName function

 

Hi @krzysztof_hoja 

thanks a lot.

I would say it is only a part of the desired solution, so first I would like to get the pure Kubernetes workload name:

Image 2024-09-30 at 11.42.25.png

Kubernetes workload name is going to be a variable, 

then I would like to query based on that name (e.g. to get 5xx timeseries) to get all related services. 

btw. is it possible to trim service-id from your query as I am getting sth like: SERVICE-86915F82C40F74B8•payments-api PaymentLinksController

 

 

To get list of workload names to use in variable definition:

fetch dt.entity.cloud_application
| fields entity.name
| dedup entity.name

 Of course you can control what fields are in final results using fields of fieldsRemove commands.

timeseries response_time=avg(dt.service.request.response_time), by: {dt.entity.service},
filter: in( dt.entity.service, 
  classicEntitySelector(concat("type(service),fromRelationship.isServiceOf(type(CLOUD_APPLICATION),entityName(",$Entity,"))")))
| fields dt.entity.service = entityName(dt.entity.service), response_time, interval, timeframe

 

@krzysztof_hoja thanks, second query indeed is solving the issue, thanks a lot. 

is there an other option to list workloads? 

If you want data related variable, one fed by DQL results is the easiest one to use.

Hmm… the workload name (without a lot of trash) should be usable as a variable to create a tile that queries all related services

Image 2024-09-30 at 22.52.02.pngImage 2024-09-30 at 22.54.35.png

 

I am not sure what is your question here....

Query retrieving e.g. response time takes workload name ($Entity matching name of CLOUD_APPLICATION).

@krzysztof_hoja I would like a query that returns only the Kubernetes workloads and another one that returns all entities belonging to a specific workload. So the question is - how to achieve that? 

Featured Posts