# Best practices for spot/preemptible instances

**URL:** <https://discuss.elastic.co/t/best-practices-for-spot-preemptible-instances/326812>\
**Category:** Elastic Agent\
**Created:** [March 2, 2023, 12:36am UTC](https://discuss.elastic.co/t/best-practices-for-spot-preemptible-instances/326812 "2023-03-02T00:36:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![marcoderama](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marcoderama/32/117770_2.png) [@marcoderama](https://discuss.elastic.co/u/marcoderama)\
**Post date:** [March 2, 2023, 12:36am UTC](https://discuss.elastic.co/t/best-practices-for-spot-preemptible-instances/326812/1 "2023-03-02T00:36:43Z")

</div>

I'm a noob with this stuff so looking for some guidance.

Say I have a GCP cluster that uses preemptible instances, or an AWS cluster that uses spot instances. If I have an Agent policy with the "Google Cloud Platform" or "AWS" integrations pointed at those clusters and gathering metrics/logs, then I end up with an ever-growing list of agents as the "spot" instances come and go.

How do people manage this? I've only been at this for a few days and already 85% of my agents are listed as "offline". Is there some way to purge old agents or is that not desirable? Do I just have to get used to filtering by "healthy" in the UI?

thanks,  
Marco

P.S. What's the difference between "offline" and "inactive" in the pull-down?

---

<div class="post-metadata">

**Author:** ![Sunile\_Manjee](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sunile_manjee/32/111461_2.png) [@Sunile\_Manjee](https://discuss.elastic.co/u/Sunile_Manjee)\
**Post date:** [March 3, 2023, 5:33pm UTC](https://discuss.elastic.co/t/best-practices-for-spot-preemptible-instances/326812/2 "2023-03-03T17:33:39Z")

</div>

> [@marcoderama](#):
>
> anage this? I've only been at this for a few days and already 85% of my agents are listed as "offline". Is there some way to purge old agents or is that not desirable? Do I just have to get used to filtering by "

If I understand your question correctly, you want to bulk purge offline agents. Have you tried to get a list of agents and then filter by offline?

```auto
curl -X GET "http://localhost:8220/api/fleet/agents" -H "Authorization: Bearer <your_token>"

```

and then you could possibly do a bulk unenroll

```auto
curl -X POST "http://localhost:8220/api/fleet/agents/bulk_unenroll" -H "Authorization: Bearer <your_token>" -H "Content-Type: application/json" --data-raw '{"agents": [<offline_agent_ids>]}' 

```

---

<div class="post-metadata">

**Author:** ![marcoderama](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/marcoderama/32/117770_2.png) [@marcoderama](https://discuss.elastic.co/u/marcoderama)\
**Post date:** [March 11, 2023, 9:23pm UTC](https://discuss.elastic.co/t/best-practices-for-spot-preemptible-instances/326812/3 "2023-03-11T21:23:04Z")

</div>

Thanks Sunile. I hadn't considered that. I don't even know if I really want/should do this anyway.

That said, i stumbled upon the "Unenrollment timeout" setting the other day. This is available under Settings for each Agent policy. Looks like one can automatically unenroll any agent that has been gone for more than a configurable number of seconds. I think this will do what I want. (Whether what I want is a good idea is another question... 🙂

thanks,  
Marco

---

<div class="post-metadata">

**Author:** ![Sunile\_Manjee](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sunile_manjee/32/111461_2.png) [@Sunile\_Manjee](https://discuss.elastic.co/u/Sunile_Manjee)\
**Post date:** [March 20, 2023, 4:43am UTC](https://discuss.elastic.co/t/best-practices-for-spot-preemptible-instances/326812/4 "2023-03-20T04:43:45Z")

</div>

> [@marcoderama](#):
>
> Unenrollment timeout

yes that makes sense. Docs for those who may run into similar issue: [Set unenrollment timeout for ephemeral hosts | Fleet and Elastic Agent Guide [7.17] | Elastic](https://www.elastic.co/guide/en/fleet/7.17/set-enrollment-timeout.html)

---

<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 17, 2023, 4:44am UTC](https://discuss.elastic.co/t/best-practices-for-spot-preemptible-instances/326812/5 "2023-04-17T04:44:18Z")

</div>

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