# Unable to disable Java APM agent in 1.9.0

**URL:** <https://discuss.elastic.co/t/unable-to-disable-java-apm-agent-in-1-9-0/197669>\
**Category:** APM\
**Tags:** java\
**Created:** [September 2, 2019, 10:28am UTC](https://discuss.elastic.co/t/unable-to-disable-java-apm-agent-in-1-9-0/197669 "2019-09-02T10:28:59Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![jaks](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jaks/32/38097_2.png) [@jaks](https://discuss.elastic.co/u/jaks)\
**Post date:** [September 2, 2019, 10:28am UTC](https://discuss.elastic.co/t/unable-to-disable-java-apm-agent-in-1-9-0/197669/1 "2019-09-02T10:28:59Z")

</div>

We are using the APM agent 1.9.0 in production & pre-prod. For dev services, we want to disable the APM, for this we are trying to set via Environment variables. Disabling of APM worked in 1.7.0, but it is not working in 1.8.0 & 1.9.0.

Here are the kubernetes pod details,

> Environment:  
> PROFILE: dev  
> ELASTIC\_APM\_ACTIVE: false  
> ELASTIC\_APM\_INSTRUMENT: false

elasticapm.properties:

> service\_name=task-service  
> application\_packages=com.jay  
> disable\_instrumentations=none  
> transaction\_sample\_rate=0.1

With the above configuration still the agent is active. Here are the trace logs,

> 2019-09-02 10:01:34.093 [main] DEBUG co.elastic.apm.agent.impl.payload.SystemInfo - Found Kubernetes pod UID: a2c41c12-cd68-11e9-bcdf-02daf193ac9c  
> 2019-09-02 10:01:34.094 [main] DEBUG co.elastic.apm.agent.impl.payload.SystemInfo - container ID is ee74a43ea8010aa6719fca3a712e0e443bc677e4a37743dfd6ecf7eb30074506  
> 2019-09-02 10:01:34.112 [main] INFO co.elastic.apm.agent.configuration.StartupInfo - Starting Elastic APM 1.9.0 as task-service on Java 1.8.0\_212 (Oracle Corporation) Linux 4.9.0-9-amd64  
> 2019-09-02 10:01:34.117 [main] DEBUG co.elastic.apm.agent.configuration.StartupInfo - active: 'false' (source: Environment Variables)  
> 2019-09-02 10:01:34.117 [main] DEBUG co.elastic.apm.agent.configuration.StartupInfo - instrument: 'false' (source: Environment Variables)  
> 2019-09-02 10:01:34.117 [main] DEBUG co.elastic.apm.agent.configuration.StartupInfo - transaction\_sample\_rate: '0.1' (source: [//elasticapm.properties](https://elasticapm.properties))  
> 2019-09-02 10:01:34.117 [main] DEBUG co.elastic.apm.agent.configuration.StartupInfo - disable\_instrumentations: 'none' (source: [//elasticapm.properties](https://elasticapm.properties))  
> 2019-09-02 10:01:34.117 [main] DEBUG co.elastic.apm.agent.configuration.StartupInfo - application\_packages: 'com.jay' (source: [//elasticapm.properties](https://elasticapm.properties))  
> 2019-09-02 10:01:34.118 [main] DEBUG co.elastic.apm.agent.configuration.StartupInfo - log\_level: 'TRACE' (source: Environment Variables)  
> 2019-09-02 10:01:34.196 [apm-remote-config-poller] DEBUG co.elastic.apm.agent.configuration.ApmServerConfigurationSource - Reloading configuration from APM Server [http://localhost:8200/config/v1/agents](http://localhost:8200/config/v1/agents)  
> 2019-09-02 10:01:34.196 [apm-server-healthcheck] DEBUG co.elastic.apm.agent.report.ApmServerHealthChecker - Starting healthcheck to [http://localhost:8200/](http://localhost:8200/)  
> 2019-09-02 10:01:34.200 [apm-remote-config-poller] DEBUG co.elastic.apm.agent.report.ApmServerClient - Exception while interacting with APM Server, trying next one.  
> 2019-09-02 10:01:34.200 [apm-remote-config-poller] ERROR co.elastic.apm.agent.configuration.ApmServerConfigurationSource - Connection refused (Connection refused)  
> 2019-09-02 10:01:34.200 [apm-server-healthcheck] WARN co.elastic.apm.agent.report.ApmServerHealthChecker - Elastic APM server [http://localhost:8200/](http://localhost:8200/) is not available (Connection refused (Connection refused))  
> 2019-09-02 10:01:34.200 [apm-remote-config-poller] DEBUG co.elastic.apm.agent.configuration.ApmServerConfigurationSource - Scheduling next remote configuration reload in 300s  
> 2019-09-02 10:01:34.219 [main] DEBUG co.elastic.apm.agent.bci.ElasticApmAgent - Applying instrumentation co.elastic.apm.agent.plugin.api.ElasticApmApiInstrumentation$StartTransactionInstrumentation  
> 2019-09-02 10:01:34.224 [main] DEBUG co.elastic.apm.agent.bci.ElasticApmAgent - Applying instrumentation co.elastic.apm.agent.plugin.api.ElasticApmApiInstrumentation$StartTransactionWithRemoteParentInstrumentation  
> ...  
> 2019-09-02 10:01:34.233 [main] DEBUG co.elastic.apm.agent.bci.ElasticApmAgent - Applying instrumentation co.elastic.apm.agent.opentracing.impl.ElasticApmTracerInstrumentation  
> 2019-09-02 10:01:34.233 [main] DEBUG co.elastic.apm.agent.bci.ElasticApmAgent - Applied 53 advices
> 
> 2019-09-02 10:06:34.201 [apm-remote-config-poller] DEBUG co.elastic.apm.agent.configuration.ApmServerConfigurationSource - Reloading configuration from APM Server [http://localhost:8200/config/v1/agents](http://localhost:8200/config/v1/agents)  
> 2019-09-02 10:06:34.201 [apm-remote-config-poller] DEBUG co.elastic.apm.agent.report.ApmServerClient - Exception while interacting with APM Server, trying next one.  
> 2019-09-02 10:06:34.201 [apm-remote-config-poller] ERROR co.elastic.apm.agent.configuration.ApmServerConfigurationSource - Connection refused (Connection refused)  
> 2019-09-02 10:06:34.201 [apm-remote-config-poller] DEBUG co.elastic.apm.agent.configuration.ApmServerConfigurationSource - Scheduling next remote configuration reload in 300s

How to disable the agent? The [config](https://www.elastic.co/guide/en/apm/agent/java/current/config-core.html) says these are the options, but still these are not working.

---

<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:** [September 3, 2019, 7:50am UTC](https://discuss.elastic.co/t/unable-to-disable-java-apm-agent-in-1-9-0/197669/2 "2019-09-03T07:50:10Z")

</div>

Hi and thanks for the question.

I agree it is not as straightforward as it may be to understand what these options entirely do, so I will try to make some sense of it.

Firstly, the [`active`](https://www.elastic.co/guide/en/apm/agent/java/current/config-core.html#config-active) config option doesn't entirely make the agent 100% noop. The reason is that this config option is a dynamic one, which means we want to make it reversible, so it still needs to do some minimal stuff. Specifically, in 1.8.0 we added our end of [the remote agent configuration feature](https://www.elastic.co/guide/en/kibana/7.3/agent-configuration.html). At the moment, it only supports the `transaction_sample_rate` config, but it is going to control other dynamic configuration options, very likely that one of the upcoming ones will be the `active` config 🙂 . Therefore, the agent still needs to maintain minimal communication with the server, which is why you see the healthcheck messages and the 5 min scheduling. If you don't want the agent to do even that, try setting the [`server_urls` config option](https://www.elastic.co/guide/en/apm/agent/java/current/config-reporter.html#config-server-urls) to an empty string.

The [`instrument`](https://www.elastic.co/guide/en/apm/agent/java/current/config-core.html#config-instrument) config option means that no auto-tracing will take place. Still, you can use the [API](https://www.elastic.co/guide/en/apm/agent/java/current/public-api.html) and the [OpenTracing bridge](https://www.elastic.co/guide/en/apm/agent/java/current/opentracing-bridge.html) when this option is set to `false`, which is why you see we apply `co.elastic.apm.agent.plugin.api` and `co.elastic.apm.agent.opentracing` advices.

In terms of functionality, the agent has minimal-to-no effects on your application with the configurations you use. You can clean the logs if that is a problem by setting the log level to `ERROR`, as it currently seem to be set to `TRACE`.

I hope this makes sense.  
Eyal.

---

<div class="post-metadata">

**Author:** ![jaks](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jaks/32/38097_2.png) [@jaks](https://discuss.elastic.co/u/jaks)\
**Post date:** [September 3, 2019, 9:47am UTC](https://discuss.elastic.co/t/unable-to-disable-java-apm-agent-in-1-9-0/197669/3 "2019-09-03T09:47:48Z")

</div>

Now after making server\_url as empty string and sample rate to 0, getting following logs,

> 2019-09-03 09:18:44.135 [main] DEBUG co.elastic.apm.agent.configuration.StartupInfo - active: 'false' (source: Environment Variables)  
> 2019-09-03 09:18:44.135 [apm-remote-config-poller] ERROR co.elastic.apm.agent.configuration.ApmServerConfigurationSource - Expected previousException not to be null  
> 2019-09-03 09:18:44.135 [main] DEBUG co.elastic.apm.agent.configuration.StartupInfo - instrument: 'false' (source: Environment Variables)  
> 2019-09-03 09:18:44.135 [apm-remote-config-poller] DEBUG co.elastic.apm.agent.configuration.ApmServerConfigurationSource - Scheduling next remote configuration reload in 300s  
> 2019-09-03 09:18:44.135 [main] DEBUG co.elastic.apm.agent.configuration.StartupInfo - transaction\_sample\_rate: '0.0' (source: Environment Variables)  
> 2019-09-03 09:18:44.135 [main] DEBUG co.elastic.apm.agent.configuration.StartupInfo - disable\_instrumentations: 'none' (source: [//elasticapm.properties](https://elasticapm.properties))  
> 2019-09-03 09:18:44.136 [main] DEBUG co.elastic.apm.agent.configuration.StartupInfo - server\_urls: '' (source: Environment Variables)
> 
> 2019-09-03 09:23:44.135 [apm-remote-config-poller] ERROR co.elastic.apm.agent.configuration.ApmServerConfigurationSource - Expected previousException not to be null  
> 2019-09-03 09:23:44.136 [apm-remote-config-poller] DEBUG co.elastic.apm.agent.configuration.ApmServerConfigurationSource - Scheduling next remote configuration reload in 300s  
> 2019-09-03 09:28:44.136 [apm-remote-config-poller] ERROR co.elastic.apm.agent.configuration.ApmServerConfigurationSource - Expected previousException not to be null  
> 2019-09-03 09:28:44.136 [apm-remote-config-poller] DEBUG co.elastic.apm.agent.configuration.ApmServerConfigurationSource - Scheduling next remote configuration reload in 300s

Is there anyway to configure it to be a noop.

---

<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:** [September 3, 2019, 12:05pm UTC](https://discuss.elastic.co/t/unable-to-disable-java-apm-agent-in-1-9-0/197669/4 "2019-09-03T12:05:14Z")

</div>

You can also set [the `central_config` option](https://www.elastic.co/guide/en/apm/agent/java/current/config-core.html#config-central-config) to false.

---

<div class="post-metadata">

**Author:** ![jaks](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jaks/32/38097_2.png) [@jaks](https://discuss.elastic.co/u/jaks)\
**Post date:** [September 3, 2019, 1:29pm UTC](https://discuss.elastic.co/t/unable-to-disable-java-apm-agent-in-1-9-0/197669/5 "2019-09-03T13:29:21Z")

</div>

Thanks. After setting central\_config to false, getting only DEBUG logs.

---

<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:** [September 3, 2019, 2:39pm UTC](https://discuss.elastic.co/t/unable-to-disable-java-apm-agent-in-1-9-0/197669/6 "2019-09-03T14:39:13Z")

</div>

Thanks for confirming.  
I did [a small fix](https://github.com/elastic/apm-agent-java/pull/830) so that we do not print this error when `server_urls` list is empty.

---

<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:** [September 24, 2019, 10:43am UTC](https://discuss.elastic.co/t/unable-to-disable-java-apm-agent-in-1-9-0/197669/7 "2019-09-24T10:43:36Z")

</div>

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