# Automate removal of old ActiveGates and OneAgents

**URL:** <https://community.dynatrace.com/t/automate-removal-of-old-activegates-and-oneagents/40126>\
**Category:** Container platforms\
**Tags:** kubernetes, dynatrace-api\
**Created:** [June 8, 2023, 2:27pm UTC](https://community.dynatrace.com/t/automate-removal-of-old-activegates-and-oneagents/40126 "2023-06-08T14:27:16Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![PeterR](https://avatars.discourse-cdn.com/v4/letter/p/9de0a6/32.png) [@PeterR](https://community.dynatrace.com/u/PeterR)\
**Post date:** [June 8, 2023, 2:27pm UTC](https://community.dynatrace.com/t/automate-removal-of-old-activegates-and-oneagents/40126/1 "2023-06-08T14:27:16Z")

</div>

Hi, we multiple dynamic EKS environments that are deployed using Argo & Terraform.  
We also deployed the Dynatrace operator (helm chart) and the Dynakube custom resources (helm chart) for each cluster using&nbsp; Argo & Terraform. We use the Classic Full stack deloyment method because this method is recommended.

Everything is configured as code, and Argo reconciles and scales everything nicely. I can even write a blog about it.

But we have a problem. The clusters shrink and scale and nodes are added and removed on the fly. Also new clusters are added and removed on the fly automatically.

But every time a node (OneAgent) is removed on Kubernetes(Argo) it is not removed in the Dynatrace portal.

So we are left with a lot of OneAgents and Activegates in Dynatrace that not exist anymore. And they still consume Host Units and are billed unfortunately…  
It try to erase them using the Dynatrace API but no luck…

curl -X DELETE “https://{environmentid}.live.dynatrace.com/api/v1/oneagents/HOST-CA604A85B22E06EC” -H “Authorization: Api-Token ${DYNA\_APITOKEN}”

How can we remove old ActiveGates and&nbsp; OneAgents and how do I automate this?

---

<div class="post-metadata">

**Author:** ![ChadTurner](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/chadturner/32/161_2.png) [@ChadTurner](https://community.dynatrace.com/u/ChadTurner)\
**Post date:** [June 23, 2023, 3:33pm UTC](https://community.dynatrace.com/t/automate-removal-of-old-activegates-and-oneagents/40126/2 "2023-06-23T15:33:00Z")

</div>

If the host isn’t being monitored it shouldn’t be consuming Host Units, or be billing you since billing is consumed by Host Unit Hours. What Oneagent Version are they? what Cluster version are you on?

---

<div class="post-metadata">

**Author:** ![PeterR](https://avatars.discourse-cdn.com/v4/letter/p/9de0a6/32.png) [@PeterR](https://community.dynatrace.com/u/PeterR)\
**Post date:** [June 30, 2023, 10:04am UTC](https://community.dynatrace.com/t/automate-removal-of-old-activegates-and-oneagents/40126/3 "2023-06-30T10:04:45Z")

</div>

Hi Chad,

The dynatrace operator manages the versions. Currently these are:  
activegate version 1.267.118.20230602-131900  
oneagent version 1.267.125.20230613-102915

We see that old hosts and oneagents eventually disappear, but it takes a while! I’m not entirely sure for how long they are billed.  
We want to at least make it possible to cleanup faster or delete the hosts with an API call…

---

<div class="post-metadata">

**Author:** ![PeterR](https://avatars.discourse-cdn.com/v4/letter/p/9de0a6/32.png) [@PeterR](https://community.dynatrace.com/u/PeterR)\
**Post date:** [June 30, 2023, 10:09am UTC](https://community.dynatrace.com/t/automate-removal-of-old-activegates-and-oneagents/40126/4 "2023-06-30T10:09:18Z")

</div>

Currently there are 6 kubernetes clusters connected. These are 52 hosts in total, healthy and consuming…

In the deployment status menu I see:

Showing 934&nbsp;hosts.Host unit consumption: 11.355 (for 934 visible&nbsp;hosts) / 11.685 (for 961 total&nbsp;hosts)

---

<div class="post-metadata">

**Author:** ![izabelarokita](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/izabelarokita/32/41812_2.png) [@izabelarokita](https://community.dynatrace.com/u/izabelarokita)\
**Post date:** [May 30, 2025, 10:53am UTC](https://community.dynatrace.com/t/automate-removal-of-old-activegates-and-oneagents/40126/5 "2025-05-30T10:53:04Z")

</div>

Hey&nbsp;[@PeterR](https://community.dynatrace.com/user/48553)&nbsp;, did you manage to find the solution to your problem? If so, it would be amazing if you’ve shared it with the rest of the Community! If not, let me know, and I’ll look for some further assistance&nbsp;😊

---

<div class="post-metadata">

**Author:** ![PeterR](https://avatars.discourse-cdn.com/v4/letter/p/9de0a6/32.png) [@PeterR](https://community.dynatrace.com/u/PeterR)\
**Post date:** [May 30, 2025, 1:15pm UTC](https://community.dynatrace.com/t/automate-removal-of-old-activegates-and-oneagents/40126/6 "2025-05-30T13:15:03Z")

</div>

Hi&nbsp;[@IzabelaRokita](https://community.dynatrace.com/user/67399)&nbsp;,  
Unfortunately, Dynatrace doesn’t support removal of these components and the related data using the API or some other way.  
Thousands of removed hosts and garbage data can’t be deleted. All this useless data is also consuming cost/credits.
