# How to set/change Elastic Agent with same hostname

**URL:** <https://discuss.elastic.co/t/how-to-set-change-elastic-agent-with-same-hostname/354766>\
**Category:** Elastic Agent\
**Created:** [March 5, 2024, 6:40pm UTC](https://discuss.elastic.co/t/how-to-set-change-elastic-agent-with-same-hostname/354766 "2024-03-05T18:40:27Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![djarami726](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/djarami726/32/108821_2.png) [@djarami726](https://discuss.elastic.co/u/djarami726)\
**Post date:** [March 5, 2024, 6:40pm UTC](https://discuss.elastic.co/t/how-to-set-change-elastic-agent-with-same-hostname/354766/1 "2024-03-05T18:40:27Z")

</div>

I have installed the elastic agent on two linux VM machines and they have the same hostname on both VMs. Unfortunately, only one shows up on my list of installed agents.

How do i change the name used for elastic agent when I install it or modify the configuration?

Thank you!

---

<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:** [March 5, 2024, 8:59pm UTC](https://discuss.elastic.co/t/how-to-set-change-elastic-agent-with-same-hostname/354766/2 "2024-03-05T20:59:05Z")

</div>

Hi @djarami726

Are you using self managed or fleet managed agen

---

<div class="post-metadata">

**Author:** ![djarami726](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/djarami726/32/108821_2.png) [@djarami726](https://discuss.elastic.co/u/djarami726)\
**Post date:** [March 6, 2024, 3:53pm UTC](https://discuss.elastic.co/t/how-to-set-change-elastic-agent-with-same-hostname/354766/4 "2024-03-06T15:53:57Z")

</div>

Fleet managed agent - installed via token.

---

<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:** [March 6, 2024, 11:11pm UTC](https://discuss.elastic.co/t/how-to-set-change-elastic-agent-with-same-hostname/354766/5 "2024-03-06T23:11:28Z")

</div>

When You add the agent at the bottom. You can see where it says just host name or fully qualified. Did you try to fully qualified host name?

---

<div class="post-metadata">

**Author:** ![djarami726](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/djarami726/32/108821_2.png) [@djarami726](https://discuss.elastic.co/u/djarami726)\
**Post date:** [March 7, 2024, 6:32pm UTC](https://discuss.elastic.co/t/how-to-set-change-elastic-agent-with-same-hostname/354766/6 "2024-03-07T18:32:43Z")

</div>

I saw that and I have it enabled, but only the short name shows up on the data and the list of agents

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/1/3/1363ea516d08ae89360a435a4d29aec67f761671.png)

---

<div class="post-metadata">

**Author:** ![leandrojmp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/leandrojmp/32/107231_2.png) [@leandrojmp](https://discuss.elastic.co/u/leandrojmp)\
**Post date:** [March 8, 2024, 3:52am UTC](https://discuss.elastic.co/t/how-to-set-change-elastic-agent-with-same-hostname/354766/7 "2024-03-08T03:52:18Z")

</div>

> [@djarami726](#):
>
> Unfortunately, only one shows up on my list of installed agents.

Having two hosts with the same hostname should make no difference for fleet as it uses a uuid to identify the agents.

Can you confirm that the agent is correctly running on both VMs?

Also, can you run the following request on Kibana Dev Tools and share the response?

```auto
GET kbn:/api/fleet/agents?page=1&perPage=20&showInactive=true&kuery=(local_metadata.host.hostname: "hostname")

```

Just replace _hostname_ with the hostname of your VMs, This will query fleet for any agent with the specified _hostname_

---

<div class="post-metadata">

**Author:** ![djarami726](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/djarami726/32/108821_2.png) [@djarami726](https://discuss.elastic.co/u/djarami726)\
**Post date:** [March 8, 2024, 3:53pm UTC](https://discuss.elastic.co/t/how-to-set-change-elastic-agent-with-same-hostname/354766/8 "2024-03-08T15:53:37Z")

</div>

Thank you. This was helpful.

I'm definitely not getting the fully qualified domain on the hostnames though but the data from this query gives me the ip address - so that will help me.

I still have to fix the hostname on the vm because the metrics data will have the same hostname for both agents/servers and that will give me incorrect information.

Thank you

---

<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:** [April 5, 2024, 3:54pm UTC](https://discuss.elastic.co/t/how-to-set-change-elastic-agent-with-same-hostname/354766/9 "2024-04-05T15:54:00Z")

</div>

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