# Is it possible to configure the Java APM agent to collect metrics but not traces?

**URL:** https://discuss.elastic.co/t/is-it-possible-to-configure-the-java-apm-agent-to-collect-metrics-but-not-traces/266405
**Category:** APM
**Tags:** java
**Created:** [March 5, 2021, 6:47pm UTC](https://discuss.elastic.co/t/is-it-possible-to-configure-the-java-apm-agent-to-collect-metrics-but-not-traces/266405 "2021-03-05T18:47:20Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![bplies](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bplies/32/81481_2.png) [@bplies](https://discuss.elastic.co/u/bplies)
#### Post date: [March 5, 2021, 6:47pm UTC](https://discuss.elastic.co/t/is-it-possible-to-configure-the-java-apm-agent-to-collect-metrics-but-not-traces/266405/1 "2021-03-05T18:47:20Z")

</div>

We have an edge service that will receive maybe a billion requests per day where it isn't feasible to have much of any transaction sample rate. It is implemented with Spring WebFlux running on Netty which aren't [officially supported](https://www.elastic.co/guide/en/apm/agent/java/current/supported-technologies-details.html#supported-web-frameworks) by APM. The application does, however, use the Micrometer metrics library (which **is** [supported](https://www.elastic.co/guide/en/apm/agent/java/current/supported-technologies-details.html#supported-metrics)) to define a number of Gauges, Counters, and Timers which we want APM to send them along to Elasticsearch.

My questions are:

- Can APM be [configured](https://www.elastic.co/guide/en/apm/agent/java/current/config-reference-properties-file.html) to collect and ship metrics but no traces? `recording`, `enabled`, and `instrument` config options do not seem to control this and indeed all seem somewhat similar.

- Can `transaction_sample_rate` simply be set to zero? Is the agent still incurring transaction overhead?

> We still record overall time and the result for unsampled transactions

- What will happen with APM in WebFlux & Netty? What are "transactions" in this case?

---

<div class="post-metadata">

### Author: ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)
#### Post date: [March 5, 2021, 7:38pm UTC](https://discuss.elastic.co/t/is-it-possible-to-configure-the-java-apm-agent-to-collect-metrics-but-not-traces/266405/2 "2021-03-05T19:38:21Z")

</div>

Hi @bplies

Interesting use case... It will be interesting to see if the APM team chimes in.

Are you looking for just your Micrometer metrics or are you also looking for JVM metrics etc.

I ask because if you are just looking for the micrometer metrics they may be another path besides the APM Agents, though that does seem like a good fit.

Since your framework technologies are not supported yet I don't think you would get much auto instrumentation anyways but you might get the default HTTP capture of transactions.

My first thought if you did not want to capture transactions (and yes even if you don't sample we capture summary transaction which you can interpret as a HTTP POST / PUT / GET etc)

Is just to set to [transaction\_ignore\_urls](https://www.elastic.co/guide/en/apm/agent/java/current/config-http.html#config-transaction-ignore-urls) all the routes so you don't generate / capture any transactions.

If you are JUST looking for your micrometer metrics you could publish them to the prometheus endpoint and then use metricbeat to listen to that and publish to elasticsearch. I would probably not use the micrometer -\> elasticsearch direct integration as I think it is may not be up to date but I could be wrong.

So curious what you are looking for...

---

<div class="post-metadata">

### Author: ![bplies](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bplies/32/81481_2.png) [@bplies](https://discuss.elastic.co/u/bplies)
#### Post date: [March 5, 2021, 7:46pm UTC](https://discuss.elastic.co/t/is-it-possible-to-configure-the-java-apm-agent-to-collect-metrics-but-not-traces/266405/3 "2021-03-05T19:46:39Z")

</div>

> Are you looking for just your Micrometer metrics or are you also looking for JVM metrics etc

Yes also the [standard System/JVM metrics](https://www.elastic.co/guide/en/apm/agent/java/current/metrics.html) that APM can collect.

> I would probably not use the micrometer -\> elasticsearch direct integration as I think it is may not be up to date but I could be wrong.

Indeed Micrometer's built-in exporter for Elasticsearch [doesn't format the metrics very well](https://github.com/micrometer-metrics/micrometer/issues/2049).

---

<div class="post-metadata">

### Author: ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)
#### Post date: [March 5, 2021, 7:59pm UTC](https://discuss.elastic.co/t/is-it-possible-to-configure-the-java-apm-agent-to-collect-metrics-but-not-traces/266405/4 "2021-03-05T19:59:27Z")

</div>

Good... Cool...

So if you have a test / dev area I would config with the agent first see what you actually collect.

@bplies  
If I get a chance I will check instrument... but I think that will shut off the JVM metrics.  
UPDATE : Huh looks like **instrument = false** still sends JVM metrics so that may work!

You will need to test the micrometer see if it still works too.

Back up Choices....

Then I would try the [transaction\_ignore\_urls](https://www.elastic.co/guide/en/apm/agent/java/current/config-http.html#config-transaction-ignore-urls)

I might also try [disable-instrumentations](https://www.elastic.co/guide/en/apm/agent/java/current/config-core.html#config-disable-instrumentations) that might even be better but can be a bit tricky to identify what to turn off 🙂

---

<div class="post-metadata">

### Author: ![bplies](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bplies/32/81481_2.png) [@bplies](https://discuss.elastic.co/u/bplies)
#### Post date: [March 5, 2021, 11:38pm UTC](https://discuss.elastic.co/t/is-it-possible-to-configure-the-java-apm-agent-to-collect-metrics-but-not-traces/266405/5 "2021-03-05T23:38:48Z")

</div>

> [@stephenb](#):
>
> Huh looks like **instrument = false** still sends JVM metrics so that may work!

Yes indeed. I also tried `instrument=false` and am receiving the JVM + custom metrics into Elasticsearch. No traces. So this does look like it achieves what we wanted.

Elastic may wish to clarify the [description](https://www.elastic.co/guide/en/apm/agent/java/current/config-core.html#config-instrument) of `instrument`

> A boolean specifying if the agent should instrument the application to collect performance metrics for the app. When set to false, Elastic APM will not affect your application at all.

"... collect performance metrics...for the app" apparently does not mean to exclude metrics from Micrometer.

---

<div class="post-metadata">

### Author: ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)
#### Post date: [March 6, 2021, 12:09am UTC](https://discuss.elastic.co/t/is-it-possible-to-configure-the-java-apm-agent-to-collect-metrics-but-not-traces/266405/6 "2021-03-06T00:09:33Z")

</div>

Very good indeed , I will pass on the documentation comments because it seems it more people are using tools like micrometer and drop wizard.

---

<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: [March 10, 2021, 11:03am UTC](https://discuss.elastic.co/t/is-it-possible-to-configure-the-java-apm-agent-to-collect-metrics-but-not-traces/266405/7 "2021-03-10T11:03:01Z")

</div>

Thanks for raising those @bplies and @stephenb. I added a word about it to [the metrics page](https://www.elastic.co/guide/en/apm/agent/java/master/metrics.html#metrics-only-mode), which references to the `instrument` config, where I also added the relevant clarification.  
Please let me know if you think an additional clarification is required.

---

<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 31, 2021, 7:03am UTC](https://discuss.elastic.co/t/is-it-possible-to-configure-the-java-apm-agent-to-collect-metrics-but-not-traces/266405/8 "2021-03-31T07:03:34Z")

</div>

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