﻿---
title: Set environment variables in an Elastic Agent policy
description: As an advanced use case, you may wish to configure environment variables in your Elastic Agent policy. This is useful, for example, if there are configuration...
url: https://www.elastic.co/elastic/docs-builder/docs/2696/reference/fleet/fleet-agent-environment-variables
products:
  - Elastic Agent
  - Fleet
applies_to:
  - Elastic Cloud Serverless: Generally available
  - Elastic Stack: Generally available
---

# Set environment variables in an Elastic Agent policy
As an advanced use case, you may wish to configure environment variables in your Elastic Agent policy. This is useful, for example, if there are configuration details about the system on which Elastic Agent is running that you may not know in advance. As a solution, you may want to configure environment variables to be interpreted by Elastic Agent at runtime, using information from the running environment.
For Fleet-managed Elastic Agents, you can configure environment variables using the [Env Provider](https://www.elastic.co/elastic/docs-builder/docs/2696/reference/fleet/env-provider). Refer to [Variables and conditions in input configurations](https://www.elastic.co/elastic/docs-builder/docs/2696/reference/fleet/dynamic-input-configuration) in the standalone Elastic Agent documentation for more detail.