# Where the enviroment field is set?

**URL:** <https://discuss.elastic.co/t/where-the-enviroment-field-is-set/265252>\
**Category:** APM\
**Tags:** java\
**Created:** [February 23, 2021, 8:28pm UTC](https://discuss.elastic.co/t/where-the-enviroment-field-is-set/265252 "2021-02-23T20:28:07Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ElasticLiver](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/elasticliver/32/64869_2.png) [@ElasticLiver](https://discuss.elastic.co/u/ElasticLiver)\
**Post date:** [February 23, 2021, 8:28pm UTC](https://discuss.elastic.co/t/where-the-enviroment-field-is-set/265252/1 "2021-02-23T20:28:07Z")

</div>

Hi, where the enviroment field is set? it is set by the agent? or on the server?

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/7/a/7ac7848782c887412a93e5054da5c0d54f52ad24.png)

---

<div class="post-metadata">

**Author:** ![trentm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/trentm/32/77647_2.png) [@trentm](https://discuss.elastic.co/u/trentm)\
**Post date:** [February 23, 2021, 11:00pm UTC](https://discuss.elastic.co/t/where-the-enviroment-field-is-set/265252/2 "2021-02-23T23:00:06Z")

</div>

Hello. It is set by the agent. E.g. for the Java agent see: [Core configuration options | APM Java Agent Reference [1.x] | Elastic](https://www.elastic.co/guide/en/apm/agent/java/current/config-core.html#config-environment)

---

<div class="post-metadata">

**Author:** ![ElasticLiver](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/elasticliver/32/64869_2.png) [@ElasticLiver](https://discuss.elastic.co/u/ElasticLiver)\
**Post date:** [February 24, 2021, 1:13pm UTC](https://discuss.elastic.co/t/where-the-enviroment-field-is-set/265252/3 "2021-02-24T13:13:17Z")

</div>

Thanks, the documentation says that this field is not dynamic, that means that we have to set the name of the enviroment?

---

<div class="post-metadata">

**Author:** ![axw](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/axw/32/28197_2.png) [@axw](https://discuss.elastic.co/u/axw)\
**Post date:** [February 25, 2021, 2:08am UTC](https://discuss.elastic.co/t/where-the-enviroment-field-is-set/265252/4 "2021-02-25T02:08:23Z")

</div>

@ElasticLiver yes, you have to configure the name for each agent, e.g. as an environment variable.

We are also working on making it possible to set this at the APM Server level: [Define a default environment to record on agent data · Issue #4664 · elastic/apm-server · GitHub](https://github.com/elastic/apm-server/issues/4664). If all agents reporting to an APM Server are part of the same environment, then you could set the environment once at the APM Server level instead. If you have agents in multiple environments reporting to one APM Server, then you will need to keep setting the environment per agent.

---

<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:** [March 17, 2021, 10:08pm UTC](https://discuss.elastic.co/t/where-the-enviroment-field-is-set/265252/5 "2021-03-17T22:08:43Z")

</div>

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