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

Entity Selector host custom metadata

axel_tapia
Observer

Today I spend most of my day trying to find an example for entitySelector where certain custom host metadata is present (or not present), after asking dynatrace support finally fot the right syntax for this

 

just want to share this as I was unable to find documentation or post related to this.

my starting point was a post from the community: https://community.dynatrace.com/t5/Open-Q-A/Entity-Selector/td-p/205554 however the details I needed were not part of the post

 

First, I don't know all the "sources" for customHostMetadata, you can start querying a single HOST to get the customHostMetadata using entities api (notice the fields, I am grabbing only properties.customHostMetadata )

https://dt-host/e/[env-id]/api/v2/entities?entitySelector=type(HOST),entityId(HOST-X)&fields=properties.customHostMetadata

Result will be something like:

 

{
   "totalCount":1,
   "pageSize":50,
   "entities":[
      {
         "entityId":"HOST-XXXXXXXXXXXXX",
         "type":"HOST",
         "displayName":"random.madeup.server",
         "properties":{
            "customHostMetadata":[
               {
                  "value":"hello",
                  "key":{
                     "source":"ENVIRONMENT",
                     "key":"myRealMetadata"
                  }
               }
            ]
         }
      }
   ]
}

 

each value from customHostMetadata will contain source, key and value (if present), source is used in the next step

 

Now, the actual examples:

get all host where ENVIRONMENT (source) metada with name: myRealMetadata exists (regardless its value)

entitySelector=type(HOST),customHostMetadata([ENVIRONMENT]myRealMetadata)

the opposite (adding the "negate" statement):

entitySelector=type(HOST),not(customHostMetadata([ENVIRONMENT]myRealMetadata))

get all host where environment metada with name: myRealMetadata exists and has the value "hello"

entitySelector=type(HOST),customHostMetadata([ENVIRONMENT]myRealMetadata:hello)

 

1 REPLY 1

36Krazyfists
Helper

Good stuff. I found this in my search for how to create custom metadata for entities.  Specifically, custom entities that I've created through the Metrics Ingest API v2 or Extensions 2.0.  I can find info in their docs about setting metadata for metrics, but nothing about metadata for Entities.

I know I can go in the Topology model settings and create rules to extract metric dimensions into custom entities with attributes, but I'm not sure if that's the same thing as metadata or properties or whatever?  Their docs are kind of all over the place and sort of vague....

 

Featured Posts