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

Add databases automatically in a management zone based on relationship

AurelienGravier
DynaMight Champion
DynaMight Champion

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 :

type(SERVICE),databaseName.exists(),toRelationships.calls(type(SERVICE),tag("env:prod","app:app"))
 
It almost works ! The problem is the logical condition between tags is a OR condition as indicated here :
"An entity with any of the specified tags is included to the response."
 
I could use only one tag env:app-prod on my services, process, and host but I want to know if you have other ideas.
 
Thank you.
Regards.
Observability consultant - Dynatrace Associate/Pro/Services certified
7 REPLIES 7

uros_djukic1
Dynatrace Advisor
Dynatrace Advisor

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




AurelienGravier
DynaMight Champion
DynaMight Champion

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

Observability consultant - Dynatrace Associate/Pro/Services certified

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 : 

uros_djukic1_0-1679568057425.png

uros_djukic1_1-1679568210262.png

 

 

AurelienGravier
DynaMight Champion
DynaMight Champion

You rock @uros_djukic1  ! It's perfect for my need, thank you very much.

Observability consultant - Dynatrace Associate/Pro/Services certified

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"))

 

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



Observability consultant - Dynatrace Associate/Pro/Services certified

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

Featured Posts