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)

 

0 REPLIES 0

Featured Posts