# Filtering Logs by Server Groups in Fleet-Managed Agents

**URL:** <https://discuss.elastic.co/t/filtering-logs-by-server-groups-in-fleet-managed-agents/375067>\
**Category:** Elastic Agent\
**Tags:** fleet\
**Created:** [February 26, 2025, 10:05am UTC](https://discuss.elastic.co/t/filtering-logs-by-server-groups-in-fleet-managed-agents/375067 "2025-02-26T10:05:42Z")\
**Posts on this page:** 1\
**Showing post:** 4

<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:** [February 26, 2025, 2:23pm UTC](https://discuss.elastic.co/t/filtering-logs-by-server-groups-in-fleet-managed-agents/375067/4 "2025-02-26T14:23:31Z")

</div>

> [@gaimes410](#):
>
> Instead of creating a new policy per group, my idea was to assign the group name as a label or metadata field to the agent during enrollment, so I can later filter logs based on that group. Is there a way to achieve this within Fleet-managed agents?

Thinking better I think you may not need one policy per group, maybe you could just use the same policies, but in the custom field uses an environment variable.

This environment variable would need to exist **on every machine** and be a system level variable that the elastic agent process would have access.

Check this answer on a similar [post](https://discuss.elastic.co/t/multi-tenant-with-fleet-and-one-single-policy-with-integrations/373019/3).

---

_[View the full topic](https://discuss.elastic.co/t/filtering-logs-by-server-groups-in-fleet-managed-agents/375067)._
