# IngestMetric affect on a entities by different way of dt.entity.host

**URL:** <https://community.dynatrace.com/t/ingestmetric-affect-on-a-entities-by-different-way-of-dt-entity-host/34607>\
**Category:** Dynatrace API\
**Tags:** dynatrace-api\
**Created:** [March 24, 2022, 9:53am UTC](https://community.dynatrace.com/t/ingestmetric-affect-on-a-entities-by-different-way-of-dt-entity-host/34607 "2022-03-24T09:53:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stef\_Stouf95](https://avatars.discourse-cdn.com/v4/letter/s/b487fb/32.png) [@Stef\_Stouf95](https://community.dynatrace.com/u/Stef_Stouf95)\
**Post date:** [March 24, 2022, 9:53am UTC](https://community.dynatrace.com/t/ingestmetric-affect-on-a-entities-by-different-way-of-dt-entity-host/34607/1 "2022-03-24T09:53:19Z")

</div>

Hi

use case :

i have an server (host0) with a oneagent, i have a script on it to retrieve different metrics of other servers, and push it  
custom.mymetric,hostname=host1 100  
custom.mymetric,hostname=host2 37  
custom.mymetric,hostname=host3 13

i can affect the metric on an entity if i use the DT unique key (dt.entity.host=HOST-XXXXXXXXXX) like that :  
custom.mymetric,dt.entity.host=HOST-XXXXXXXXX1,hostname=host1 100  
custom.mymetric,dt.entity.host=HOST-XXXXXXXXX2,hostname=host2 37  
custom.mymetric,dt.entity.host=HOST-XXXXXXXXX3,hostname=host3 13

but on the server (host0) this unique key is unknown (i can do a call api on master to retrieve but it’s not acceptable on a script launched each 1 minute to retrieve id of X servers)

exist it a method ?

i test that without success :  
custom.mymetric,dt.entity.host=host1,hostname=host1 100  
custom.mymetric,dt.entity.displayname=host1,hostname=host1 100

Thanks

---

<div class="post-metadata">

**Author:** ![Mike\_L](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/mike_l/32/11717_2.png) [@Mike\_L](https://community.dynatrace.com/u/Mike_L)\
**Post date:** [March 24, 2022, 10:26am UTC](https://community.dynatrace.com/t/ingestmetric-affect-on-a-entities-by-different-way-of-dt-entity-host/34607/2 "2022-03-24T10:26:50Z")

</div>

Hi,

If you use the local ingest on the OneAgent the host entity id is added automatically:

> **[Extend metric observability](https://docs.dynatrace.com/docs/ingest-from/extend-dynatrace/extend-metrics)**
>
> Learn how to extend metric observability in Dynatrace.

Mike

---

<div class="post-metadata">

**Author:** ![Stef\_Stouf95](https://avatars.discourse-cdn.com/v4/letter/s/b487fb/32.png) [@Stef\_Stouf95](https://community.dynatrace.com/u/Stef_Stouf95)\
**Post date:** [March 28, 2022, 10:00am UTC](https://community.dynatrace.com/t/ingestmetric-affect-on-a-entities-by-different-way-of-dt-entity-host/34607/3 "2022-03-28T10:00:53Z")

</div>

Hi Mike, thanks for your answer.

indeed it’s work on my example :&nbsp;custom.mymetric,dt.entity.host=HOST-XXXXXXXXX3,hostname=host3 13  
if i execute on the server it take the server context and affect on it without put in dt.entity.host.

but my case is, the api call is done on another server (for exemple a cluster or a silo) that retrieve metrics of lot of servers.  
the only information known is the hostnames not applicable on&nbsp;dt.entity.host field,  
i can do before an api call (/api/v2/entities?pageSize=50&entitySelector=type(“host”),entityName.startsWith(“host1”)), and retrieve this id in payload “entities.entityId”  
but the process is heavier

Thx

---

<div class="post-metadata">

**Author:** ![Julius\_Loman](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/julius_loman/32/51_2.png) [@Julius\_Loman](https://community.dynatrace.com/u/Julius_Loman)\
**Post date:** [March 29, 2022, 7:28am UTC](https://community.dynatrace.com/t/ingestmetric-affect-on-a-entities-by-different-way-of-dt-entity-host/34607/4 "2022-03-29T07:28:26Z")

</div>

[@Stef\_Stouf95](https://community.dynatrace.com/user/47955)&nbsp; yes, you need to specify the entity id, in this case the host id. The host id will never change unless you change the hostgroup and then it’s in fact a new host.

Depending on your script and use case you can either configure it statically in a map in your script or do a lookup on the script startup and then cache the values as required.
