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

Pro Tip - Tagging entities which have no autotagging rule support with relationships

r_weber
DynaMight Champion
DynaMight Champion

When creating Dynatrace autotags via the UI supported rules you might miss a few entities you'd like to tag. For example there is no easy way to tag a Kubernetes Cluster or a Container Instance.

You might need that though for API analysis or other usecases.

 

The solution I use to tag the complete stack (K8s cluster, hosts, processes, services, applications, synthetic monitors) for everything that runs/is provided by a specific kubernetes cluster is the following:

(entity Selectors and relationship mapping to the rescue).

 

  1. Identify and tag the kubernetes cluster
  2. Tag all hosts of this cluster, using the toRelationship.isClusterOfHost
  3. Tag all cloud application of this cluster, using the toRelationships.isClusterOfCa
  4. Tag all process groups of the tagged cloud application, using the fromRelationships.isPgOfCa
  5. Tag all process group instances of the tagged process groups, using the fromRelationships.isInstanceOf
  6. Tag all services that are provided by the tagged process groups, using the fromRelationships.runsOn
  7. Tag all applications that are calling the tagged service, using the fromRelationships.calls
  8. tag all synthetic monitors that are monitoring the tagged applications, using the fromRelationships.monitors

A concrete example (I'm using YAML notation for the JSON formated auto-tag rule used by the DT API):

 

  name: dev-stage
  description:
  entitySelectorBasedRules:
  - enabled: true
    entitySelector: type(KUBERNETES_CLUSTER),entityName(_dev)
    valueFormat: ''
  - enabled: true
    entitySelector: type(HOST),toRelationships.isClusterOfHost(type(KUBERNETES_CLUSTER),tag(dev-stage))
    valueFormat: ''
  - enabled: true
    entitySelector: type(CLOUD_APPLICATION_NAMESPACE),toRelationships.isClusterOfNamespace(type(KUBERNETES_CLUSTER),tag(dev-stage))
    valueFormat: ''
  - enabled: true
    entitySelector: type(CLOUD_APPLICATION),toRelationships.isClusterOfCa(type(KUBERNETES_CLUSTER),tag(dev-stage))
    valueFormat: ''
  - enabled: true
    entitySelector: type(PROCESS_GROUP),fromRelationships.isPgOfCa(type(CLOUD_APPLICATION),tag(dev-stage))
    valueFormat: ''
  - enabled: true
    entitySelector: type(PROCESS_GROUP_INSTANCE),fromRelationships.isInstanceOf(type(PROCESS_GROUP),tag(dev-stage))
    valueFormat: ''
  - enabled: true
    entitySelector: type(CONTAINER_GROUP_INSTANCE),fromRelationships.isCgiOfCluster(type(KUBERNETES_CLUSTER),tag(dev-stage))
    valueFormat: ''
  - enabled: true
    entitySelector: type(SERVICE),fromRelationships.runsOn(type(PROCESS_GROUP),tag(dev-stage))
    valueFormat: ''
  - enabled: true
    entitySelector: type(APPLICATION),fromRelationships.calls(type(SERVICE),tag(dev-stage))
    valueFormat: ''
  - enabled: true
    entitySelector: type(SYNTHETIC_TEST),fromRelationships.monitors(type(APPLICATION),tag(dev-stage))
    valueFormat: ''
  rules: []

 

 

At first this seems counter intuitive as the first rule would ONLY tag the Kubernetes cluster and the other rules would not do anything (because of the entitySelector filter tag(dev-stage) - which is a reference to the tag we are just defining).
But once the first rule is applied to the K8s cluster all the other rules start to 'unfold': the HOSTs are tagged with the same tag, the CLOUD_APPLICATIONS.
Once the CLOUD_APPLICATIONS are tagged the depending PROCESS_GROUPS are also tagged and so on.
The CONTAINER_GROUP instances are tagged as well (you cannot directly select them in non-entity selector based rules).

This ruleset basically triggers a chain-reaction of applying the same tag across the different dependencies that Dynatrace detected on the fly. Which dependencies you want to consider for this is up to you (whatever you can find in the from/to relationships of an entity is possible).

 

Where would you like to use this:

 

  • This is fantastic for "dynamic" and simplified management zone assignment
  • It is also great in combination with custom metric charts (also using entity selectors) for metrics on entities that you cannot tag otherwise (e.g. container instance metrics)
  • It's also perfect for tagging entities that do not yet exist or create a dependency at some point.
    (e.g. a service that suddenly calls a already tagged service would be tagged and thus shows up on your dashboard that has a tagging filter)

 

Thought I share this tagging strategy 😉

 

kr,

Reinhard

Certified Dynatrace Master, Dynatrace Partner - 360Performance.net
3 REPLIES 3

Karolina_Linda
Community Team
Community Team

Thank you, Reinhard! That's a really comprehensive tip article 🙂 I hope many other Dynatrace users will find it super useful :dynatrace:

Keep calm and build Community!

theharithsa
Dynatrace Champion
Dynatrace Champion

This is super useful and indeed Protip. I'd love to use this in our customer places. Thanks for sharing, Reinhard. 

Love more, hate less; Technology for all, together we grow.

Kenny_Gillette
DynaMight Leader
DynaMight Leader

This is golden!  Thanks for putting this together.  Helped me a whole lot on learning how to do this tagging this morning.

Dynatrace Certified Professional

Featured Posts