22 Mar 2023 07:03 AM
Hello,
My host group (or my namespaces in k8S env) contains app_env information and I use them to create 2 distinguished tags "app:xxx" and "env:xxx" on hosts, process and services side.
Afterward, I create management zones and I use an entity selector as condition to add databases automatically based on origin calls service tags values like below :
Solved! Go to Solution.
22 Mar 2023 08:23 AM - last edited on 23 Mar 2023 07:40 AM by MaciejNeumann
Hi Aurelien,
You can try to use this kind of MetricSelector expression based on HostGroup instead of tag (restrictive indeed) :
Case 1 : several host group
type(service),databaseName.exists(),toRelationships.calls(
type(service),fromRelationships.runsOnHost(
type(host),fromRelationships.isInstanceOf(type(HOST_GROUP),entityName.in("env1, env2, ...")
Case 2 : one host group
entityName.contains("env1")
Why make your life difficult? 😄
Can you test it ?
I hope it helps.
Thanks
22 Mar 2023 03:51 PM
Hello @uros_djukic1
It's brilliant thank you, it works great :
type(service),databaseName.exists(),toRelationships.calls(type(service),fromRelationships.runsOnHost(type(host),fromRelationships.isInstanceOf(type(HOST_GROUP),entityName.contains("app1-prod"))))
Do you have an equivalent for kubernetes based on kubernetes namespace value ?
Because, I can do it with the entity selector below but only egal and exist are available (I would like contains) :
type(service),databaseName.exists(),toRelationships.calls(type(service),fromRelationships.runsOn(type(process_group),metadata("KUBERNETES_NAMESPACE:gp-sales-app1-prod")))
https://www.dynatrace.com/support/help/shortlink/api-entities-v2-selector#attribute
Thank you very much
23 Mar 2023 10:45 AM
For Kubernete try this :
type(service),databaseName.exists(),toRelationships.calls(type(~"SERVICE~"),fromRelationship.runsOn(type(PROCESS_GROUP),toRelationship.isNamespaceOfPg(type(~"CLOUD_APPLICATION_NAMESPACE~"),entityName.contains(~"app1-prod~"))))
My MetricExpression :
builtin:service.requestCount.server:filter(and(or(in("dt.entity.service",entitySelector("type(service),toRelationships.calls(type(~"SERVICE~"),fromRelationship.runsOn(type(PROCESS_GROUP),toRelationship.isNamespaceOfPg(type(~"CLOUD_APPLICATION_NAMESPACE~"),entityName.contains(~"online~"))))"))))):splitBy("dt.entity.service"):sort(value(auto,descending)):limit(20)
Result :
23 Mar 2023 11:31 AM
You rock @uros_djukic1 ! It's perfect for my need, thank you very much.
10 Oct 2023 03:08 PM
Hi Aurelien, the purposed solution works, by the way if you want to apply an AND in service filter, you can do as follows:
type(SERVICE),databaseName.exists(),toRelationships.calls(type(SERVICE),tag("env:prod"),tag("app:app"))
11 Oct 2023 08:50 AM
Hello @paolo_fumanelli ,
You will make my day better, so simple solution to manage tags on entity selector, I tried it on service entity only :
OR LOGICAL between tags values :
type(SERVICE),tag("env:prod","app:myappname")
LOGICAL AND between tags values :
type(SERVICE),tag("env:prod"),tag("app:myappname")
Thank you. Regards
11 Oct 2023 09:07 AM
Sure, that works for any entitySelector. All provided criteria (separated by comma) must be fullfilled (AND logic), while when providing more that one value in the same criteria (if the criteria accepts this), OR logic is applied.
Glad to have helped you