28 Sep 2024 06:43 PM
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.
29 Sep 2024 08:54 PM
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
30 Sep 2024 10:49 AM
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:
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
30 Sep 2024 11:08 AM
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
30 Sep 2024 01:52 PM
@krzysztof_hoja thanks, second query indeed is solving the issue, thanks a lot.
is there an other option to list workloads?
30 Sep 2024 05:50 PM
If you want data related variable, one fed by DQL results is the easiest one to use.
30 Sep 2024 09:55 PM - edited 30 Sep 2024 09:56 PM
Hmm… the workload name (without a lot of trash) should be usable as a variable to create a tile that queries all related services
01 Oct 2024 11:25 AM - edited 01 Oct 2024 11:25 AM
I am not sure what is your question here....
Query retrieving e.g. response time takes workload name ($Entity matching name of CLOUD_APPLICATION).
01 Oct 2024 05:51 PM - edited 01 Oct 2024 05:52 PM
@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?