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

Add databases automatically in a management zone based on relationship

AurelienGravier
DynaMight Mentor
DynaMight Mentor

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
4 REPLIES 4

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 Mentor
DynaMight Mentor

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 Mentor
DynaMight Mentor

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

Observability consultant - Dynatrace Associate/Pro/Services certified