# APM config overriding

**URL:** <https://discuss.elastic.co/t/apm-config-overriding/207854>\
**Category:** APM\
**Tags:** java\
**Created:** [November 14, 2019, 10:12am UTC](https://discuss.elastic.co/t/apm-config-overriding/207854 "2019-11-14T10:12:37Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Svetlana\_Nikitina](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/svetlana_nikitina/32/46276_2.png) [@Svetlana\_Nikitina](https://discuss.elastic.co/u/Svetlana_Nikitina)\
**Post date:** [November 14, 2019, 10:12am UTC](https://discuss.elastic.co/t/apm-config-overriding/207854/1 "2019-11-14T10:12:37Z")

</div>

Guys, first of all thank you for fixing this issue [APM config\_file location](https://discuss.elastic.co/t/apm-config-file-location/203887)  
We have switched to `1.11.0` and it works like a charm

ATM I am experiencing anther issue with configs  
[Docs say](https://www.elastic.co/guide/en/apm/agent/java/master/configuration.html#configuration) that:

> The first configuration sources override the configuration values of over the latter sources.

I am running **Spring Boot App** with properties file, having

```auto
service_name=app-dev

```

and try to override this value by setting `-Delastic.apm.service_name=app-feature-branch` or even by setting env variable `ELASTIC_APM_SERVICE_NAME=app-feature-branch`  
and don't see any effect

Can you please confirm that this feature works for Java?

**Kibana version** : 6.8.0

**Elasticsearch version** : 6.8.0

**APM Server version** : 6.8.0

**APM Agent language and version** : JAVA apm-agent-attach:1.11.0, apm-agent-api:1.11.0

**Java version** : openjdk:11

---

<div class="post-metadata">

**Author:** ![felixbarny](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/felixbarny/32/27341_2.png) [@felixbarny](https://discuss.elastic.co/u/felixbarny)\
**Post date:** [November 14, 2019, 10:43am UTC](https://discuss.elastic.co/t/apm-config-overriding/207854/2 "2019-11-14T10:43:19Z")

</div>

The problem is that currently, the properties file in `src/main/resources` of your Spring Boot app gets treated differently than the `_AGENT_HOME_/elasticapm.properties` file. The former is always applied as the highest prio config source while the latter behaves like documented.

> <https://github.com/elastic/apm-agent-java/blob/0fe2e282e6be953ac6e4cbf69320cd1a928ba2bf/apm-agent-core/src/main/java/co/elastic/apm/agent/impl/ElasticApmTracerBuilder.java#L152-L160>

While I think that's a bug some might rely on that behavior. But as it's not really behaving as documented I'm in favor of changing it.

@Eyal_Koren @Sylvain_Juge wdyt?

---

<div class="post-metadata">

**Author:** ![Svetlana\_Nikitina](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/svetlana_nikitina/32/46276_2.png) [@Svetlana\_Nikitina](https://discuss.elastic.co/u/Svetlana_Nikitina)\
**Post date:** [November 14, 2019, 10:48am UTC](https://discuss.elastic.co/t/apm-config-overriding/207854/3 "2019-11-14T10:48:05Z")

</div>

> [@felixbarny](#):
>
> While I think that's a bug some might rely on that behavior. But as it's not really behaving as documented I'm in favor of changing it.

okay, but then the whole concept of overriding and having central config doesn't make much sense for Spring Boot apps then ☹

---

<div class="post-metadata">

**Author:** ![felixbarny](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/felixbarny/32/27341_2.png) [@felixbarny](https://discuss.elastic.co/u/felixbarny)\
**Post date:** [November 14, 2019, 12:18pm UTC](https://discuss.elastic.co/t/apm-config-overriding/207854/4 "2019-11-14T12:18:15Z")

</div>

You mean even when fixing the order so that it matches the order described in the the documentation?

---

<div class="post-metadata">

**Author:** ![Svetlana\_Nikitina](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/svetlana_nikitina/32/46276_2.png) [@Svetlana\_Nikitina](https://discuss.elastic.co/u/Svetlana_Nikitina)\
**Post date:** [November 14, 2019, 4:12pm UTC](https://discuss.elastic.co/t/apm-config-overriding/207854/5 "2019-11-14T16:12:35Z")

</div>

> [@felixbarny](#):
>
> You mean even when fixing the order so that it matches the order described in the the documentation?

Sorry, if i wrote it unclear in the beginning

I mean, I think we should fix the implementation for spring boot to be the same as defined in the docs, so property file (even located in resorces folder) has the least prio and can be overridden upon app deployment with values from environment and from central config

---

<div class="post-metadata">

**Author:** ![felixbarny](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/felixbarny/32/27341_2.png) [@felixbarny](https://discuss.elastic.co/u/felixbarny)\
**Post date:** [November 14, 2019, 4:23pm UTC](https://discuss.elastic.co/t/apm-config-overriding/207854/6 "2019-11-14T16:23:36Z")

</div>

I agree. Let's see what the others think.

---

<div class="post-metadata">

**Author:** ![Eyal\_Koren](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/eyal_koren/32/36830_2.png) [@Eyal\_Koren](https://discuss.elastic.co/u/Eyal_Koren)\
**Post date:** [November 17, 2019, 6:35am UTC](https://discuss.elastic.co/t/apm-config-overriding/207854/7 "2019-11-17T06:35:00Z")

</div>

I agree that it needs fixing, so it is in accordance with the documentation.  
Regarding breaking it for current users- can we add a message in log right before we log all the configs we see, and in a **Breaking changes** sections in the release notes. Should be enough.

---

<div class="post-metadata">

**Author:** ![Adrian\_C](https://avatars.discourse-cdn.com/v4/letter/a/2acd7d/32.png) [@Adrian\_C](https://discuss.elastic.co/u/Adrian_C)\
**Post date:** [December 4, 2019, 2:02pm UTC](https://discuss.elastic.co/t/apm-config-overriding/207854/8 "2019-12-04T14:02:40Z")

</div>

Hi,

Also got caught out by this one. As a product developer, we would like to be able to provide a default config that can be overridden as required. It does not appear that this is possible using classpath mechanisms.

Is there any workaround for this in the interm?

Is the possible fix here for backward comparability to add support for reading an addition config from the classpath with a different name to preserver backwards comparability.

However, in terms of backwards comparability the current behaviour is not documented. Having the elasticapm.properties on the classpath is different to having it in the _AGENT\_HOME_

Anyone who is currently using it on the classpath and is not having issues is not aware of the limitation and I don't believe that backwards comparability will effect them.

All that said I am in favour of fixing this and adding section to breaking changes section.

My 2c...

---

<div class="post-metadata">

**Author:** ![Sylvain\_Juge](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sylvain_juge/32/55521_2.png) [@Sylvain\_Juge](https://discuss.elastic.co/u/Sylvain_Juge)\
**Post date:** [December 5, 2019, 4:56pm UTC](https://discuss.elastic.co/t/apm-config-overriding/207854/9 "2019-12-05T16:56:14Z")

</div>

I have filed an issue to improve both documentation and implementation for classpath configuration. Don't forget to subscribe to it in order to know when this will be fixed.

> <https://github.com/elastic/apm-agent-java/issues/959>
>
> Issue description
> Agent configuration can be provided through an elasticapm.properties file in the application classpath, which is required for applications that use...

---

<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:** [December 26, 2019, 12:56pm UTC](https://discuss.elastic.co/t/apm-config-overriding/207854/10 "2019-12-26T12:56:18Z")

</div>

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