<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Entity Selector host custom metadata in Dynatrace tips</title>
    <link>https://community.dynatrace.com/t5/Dynatrace-tips/Entity-Selector-host-custom-metadata/m-p/221459#M1010</link>
    <description>&lt;P&gt;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&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;just want to share this as I was unable to find documentation or post related to this.&lt;/P&gt;&lt;P&gt;my starting point was a post from the community:&amp;nbsp;&lt;A href="https://community.dynatrace.com/t5/Open-Q-A/Entity-Selector/td-p/205554" target="_blank" rel="noopener"&gt;https://community.dynatrace.com/t5/Open-Q-A/Entity-Selector/td-p/205554&amp;nbsp;&lt;/A&gt;however the details I needed were not part of the post&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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 &lt;STRONG&gt;properties.customHostMetadata &lt;/STRONG&gt;)&lt;/P&gt;&lt;PRE&gt;https://dt-host/e/[env-id]/api/v2/entities?entitySelector=type(HOST),entityId(HOST-X)&amp;amp;fields=properties.customHostMetadata&lt;/PRE&gt;&lt;P&gt;Result will be something like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;{
   "totalCount":1,
   "pageSize":50,
   "entities":[
      {
         "entityId":"HOST-XXXXXXXXXXXXX",
         "type":"HOST",
         "displayName":"random.madeup.server",
         "properties":{
            "customHostMetadata":[
               {
                  "value":"hello",
                  "key":{
                     "source":"ENVIRONMENT",
                     "key":"myRealMetadata"
                  }
               }
            ]
         }
      }
   ]
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;each value from customHostMetadata will contain source, key and value (if present), source is used in the next step&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now, the actual examples:&lt;/P&gt;&lt;P&gt;get all host where &lt;STRONG&gt;ENVIRONMENT&lt;/STRONG&gt; (source) metada with name:&amp;nbsp;&lt;STRONG&gt;myRealMetadata&lt;/STRONG&gt; exists (regardless its value)&lt;/P&gt;&lt;PRE&gt;entitySelector=type(HOST),customHostMetadata([ENVIRONMENT]myRealMetadata)&lt;/PRE&gt;&lt;P&gt;the opposite (adding the "negate" statement):&lt;/P&gt;&lt;PRE&gt;entitySelector=type(HOST),not(customHostMetadata([ENVIRONMENT]myRealMetadata))&lt;/PRE&gt;&lt;P&gt;get all host where environment metada with name:&amp;nbsp;&lt;STRONG&gt;myRealMetadata&lt;/STRONG&gt; exists and has the value "&lt;STRONG&gt;hello&lt;/STRONG&gt;"&lt;/P&gt;&lt;PRE&gt;entitySelector=type(HOST),customHostMetadata([ENVIRONMENT]myRealMetadata:hello)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 24 Aug 2023 01:01:51 GMT</pubDate>
    <dc:creator>axel_tapia</dc:creator>
    <dc:date>2023-08-24T01:01:51Z</dc:date>
    <item>
      <title>Entity Selector host custom metadata</title>
      <link>https://community.dynatrace.com/t5/Dynatrace-tips/Entity-Selector-host-custom-metadata/m-p/221459#M1010</link>
      <description>&lt;P&gt;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&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;just want to share this as I was unable to find documentation or post related to this.&lt;/P&gt;&lt;P&gt;my starting point was a post from the community:&amp;nbsp;&lt;A href="https://community.dynatrace.com/t5/Open-Q-A/Entity-Selector/td-p/205554" target="_blank" rel="noopener"&gt;https://community.dynatrace.com/t5/Open-Q-A/Entity-Selector/td-p/205554&amp;nbsp;&lt;/A&gt;however the details I needed were not part of the post&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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 &lt;STRONG&gt;properties.customHostMetadata &lt;/STRONG&gt;)&lt;/P&gt;&lt;PRE&gt;https://dt-host/e/[env-id]/api/v2/entities?entitySelector=type(HOST),entityId(HOST-X)&amp;amp;fields=properties.customHostMetadata&lt;/PRE&gt;&lt;P&gt;Result will be something like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;{
   "totalCount":1,
   "pageSize":50,
   "entities":[
      {
         "entityId":"HOST-XXXXXXXXXXXXX",
         "type":"HOST",
         "displayName":"random.madeup.server",
         "properties":{
            "customHostMetadata":[
               {
                  "value":"hello",
                  "key":{
                     "source":"ENVIRONMENT",
                     "key":"myRealMetadata"
                  }
               }
            ]
         }
      }
   ]
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;each value from customHostMetadata will contain source, key and value (if present), source is used in the next step&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now, the actual examples:&lt;/P&gt;&lt;P&gt;get all host where &lt;STRONG&gt;ENVIRONMENT&lt;/STRONG&gt; (source) metada with name:&amp;nbsp;&lt;STRONG&gt;myRealMetadata&lt;/STRONG&gt; exists (regardless its value)&lt;/P&gt;&lt;PRE&gt;entitySelector=type(HOST),customHostMetadata([ENVIRONMENT]myRealMetadata)&lt;/PRE&gt;&lt;P&gt;the opposite (adding the "negate" statement):&lt;/P&gt;&lt;PRE&gt;entitySelector=type(HOST),not(customHostMetadata([ENVIRONMENT]myRealMetadata))&lt;/PRE&gt;&lt;P&gt;get all host where environment metada with name:&amp;nbsp;&lt;STRONG&gt;myRealMetadata&lt;/STRONG&gt; exists and has the value "&lt;STRONG&gt;hello&lt;/STRONG&gt;"&lt;/P&gt;&lt;PRE&gt;entitySelector=type(HOST),customHostMetadata([ENVIRONMENT]myRealMetadata:hello)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Aug 2023 01:01:51 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Dynatrace-tips/Entity-Selector-host-custom-metadata/m-p/221459#M1010</guid>
      <dc:creator>axel_tapia</dc:creator>
      <dc:date>2023-08-24T01:01:51Z</dc:date>
    </item>
    <item>
      <title>Re: Entity Selector host custom metadata</title>
      <link>https://community.dynatrace.com/t5/Dynatrace-tips/Entity-Selector-host-custom-metadata/m-p/248590#M1296</link>
      <description>&lt;P&gt;Good stuff. I found this in my search for how to create custom metadata for entities.&amp;nbsp; Specifically, custom entities that I've created through the Metrics Ingest API v2 or Extensions 2.0.&amp;nbsp; I can find info in their docs about setting metadata for metrics, but nothing about metadata for Entities.&lt;/P&gt;&lt;P&gt;I know I can go in the &lt;STRONG&gt;Topology model&lt;/STRONG&gt; 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?&amp;nbsp; Their docs are kind of all over the place and sort of vague....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jun 2024 16:16:02 GMT</pubDate>
      <guid>https://community.dynatrace.com/t5/Dynatrace-tips/Entity-Selector-host-custom-metadata/m-p/248590#M1296</guid>
      <dc:creator>36Krazyfists</dc:creator>
      <dc:date>2024-06-18T16:16:02Z</dc:date>
    </item>
  </channel>
</rss>

