# How to change an agent name

**URL:** <https://discuss.elastic.co/t/how-to-change-an-agent-name/305091>\
**Category:** APM\
**Tags:** java\
**Created:** [May 18, 2022, 3:50pm UTC](https://discuss.elastic.co/t/how-to-change-an-agent-name/305091 "2022-05-18T15:50:52Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![SamuelSMendes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/samuelsmendes/32/104246_2.png) [@SamuelSMendes](https://discuss.elastic.co/u/SamuelSMendes)\
**Post date:** [May 18, 2022, 3:50pm UTC](https://discuss.elastic.co/t/how-to-change-an-agent-name/305091/1 "2022-05-18T15:50:52Z")

</div>

So, I've been looking for a way to change the Java agent name. Silly thing but still would help a lot in situations like "group by agent.name". While is not on topic it would be awsome to see how this is made with Django - Python agent as well.

Best regards!  
 ![Captura de Tela (280)](https://us1.discourse-cdn.com/elastic/original/3X/c/c/cc1e7d523b7e9008ef72466541c1039d0e29d1aa.png)

---

<div class="post-metadata">

**Author:** ![Jack\_Shirazi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jack_shirazi/32/91641_2.png) [@Jack\_Shirazi](https://discuss.elastic.co/u/Jack_Shirazi)\
**Post date:** [May 18, 2022, 4:27pm UTC](https://discuss.elastic.co/t/how-to-change-an-agent-name/305091/2 "2022-05-18T16:27:52Z")

</div>

I don't think it's a settable value. Afaict it's hardcoded [here](https://github.com/elastic/apm-agent-java/blob/main/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/metadata/ServiceFactory.java#L32).

---

<div class="post-metadata">

**Author:** ![SamuelSMendes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/samuelsmendes/32/104246_2.png) [@SamuelSMendes](https://discuss.elastic.co/u/SamuelSMendes)\
**Post date:** [May 18, 2022, 4:39pm UTC](https://discuss.elastic.co/t/how-to-change-an-agent-name/305091/3 "2022-05-18T16:39:23Z")

</div>

I see...In any case thanks for reaching out.

Just that info saves alot of time 😅

---

<div class="post-metadata">

**Author:** ![Eyal\_Koren](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eyal_koren/32/36830_2.png) [@Eyal\_Koren](https://discuss.elastic.co/u/Eyal_Koren)\
**Post date:** [May 22, 2022, 7:03am UTC](https://discuss.elastic.co/t/how-to-change-an-agent-name/305091/4 "2022-05-22T07:03:42Z")

</div>

Maybe you can achieve what you need through [`global_labels`](https://www.elastic.co/guide/en/apm/agent/java/current/config-core.html#config-global-labels), which are available in the [python agent](https://www.elastic.co/guide/en/apm/agent/python/current/configuration.html#config-global_labels) as well.

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [May 22, 2022, 3:42pm UTC](https://discuss.elastic.co/t/how-to-change-an-agent-name/305091/5 "2022-05-22T15:42:25Z")

</div>

@SamuelSMendes or beside Eyals probably better solution (`global_labels`) ... You can create a runtime field `agent.friendly_name` or something with some If / Else logic to set the values assuming you have some tag / data that you can use.

---

<div class="post-metadata">

**Author:** ![SamuelSMendes](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/samuelsmendes/32/104246_2.png) [@SamuelSMendes](https://discuss.elastic.co/u/SamuelSMendes)\
**Post date:** [May 23, 2022, 1:01am UTC](https://discuss.elastic.co/t/how-to-change-an-agent-name/305091/6 "2022-05-23T01:01:45Z")

</div>

Thanks for sharing the thoughts @Eyal_Koren and @stephenb. I'll look into it and once I have it all tested I'll be back with the outcome on the topic.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 12, 2022, 9:01pm UTC](https://discuss.elastic.co/t/how-to-change-an-agent-name/305091/7 "2022-06-12T21:01:48Z")

</div>

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.
