# APM Java Agent Ignore Error

**URL:** <https://discuss.elastic.co/t/apm-java-agent-ignore-error/325563>\
**Category:** APM\
**Tags:** java\
**Created:** [February 15, 2023, 9:01am UTC](https://discuss.elastic.co/t/apm-java-agent-ignore-error/325563 "2023-02-15T09:01:32Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ivan\_Hosea](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ivan_hosea/32/117268_2.png) [@Ivan\_Hosea](https://discuss.elastic.co/u/Ivan_Hosea)\
**Post date:** [February 15, 2023, 9:01am UTC](https://discuss.elastic.co/t/apm-java-agent-ignore-error/325563/1 "2023-02-15T09:01:32Z")

</div>

**APM Agent language and version** :  
1.36

**Description of the problem including expected versus actual behavior. Please include screenshots (if relevant)**:  
I was wondering if there is any way to filter out specific error code and exceptions for java. For Node.js it seems to be possible with this:

> [@How to ignore certain errors in APM?](https://discuss.elastic.co/t/how-to-ignore-certain-errors-in-apm/305880):
>
> I have a nodejs/express REST API service using the Elastic APM client, and the Elastic Cloud backend, and I'm very happy with it so far. My application regularly needs to check S3 for the existence/non-existence of certain keys in certain buckets, using the [AWS S3.HeadObject](https://docs.aws.amazon.com/AmazonS3/latest/API/API_HeadObject.html) method. When those keys don't exist, the S3 API returns a 404 status, which is perfectly normal behavior within my application. But the Elastic APM client reports these as Errors, which clutters up our APM dashboard and ma…

Also, for exceptions I have tried to use ignore\_exceptions on elasticapm.properties based on this:

> **[Core configuration options | APM Java Agent Reference \[1.x\] | Elastic](https://www.elastic.co/guide/en/apm/agent/java/current/config-core.html)**

but it seems to never filter anything unless I fill in ignore\_exceptions=\*. I have tried \*RuntimeException, \*RuntimeException\*, \*java\*, \*elastic\*. None of them worked.  
Can anyone explain how this supposed to work?

---

<div class="post-metadata">

**Author:** ![Jack\_Shirazi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jack_shirazi/32/91641_2.png) [@Jack\_Shirazi](https://discuss.elastic.co/u/Jack_Shirazi)\
**Post date:** [February 15, 2023, 5:19pm UTC](https://discuss.elastic.co/t/apm-java-agent-ignore-error/325563/2 "2023-02-15T17:19:39Z")

</div>

As [detailed](https://www.elastic.co/guide/en/apm/agent/java/current/config-core.html#config-ignore-exceptions), exception inheritance is not supported so \*RuntimeException doesn't mean you get all exceptions that extend from RuntimeException. There are some examples in that link. Try setting it to the fully qualified exception class name

---

<div class="post-metadata">

**Author:** ![Ivan\_Hosea](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ivan_hosea/32/117268_2.png) [@Ivan\_Hosea](https://discuss.elastic.co/u/Ivan_Hosea)\
**Post date:** [February 16, 2023, 3:28am UTC](https://discuss.elastic.co/t/apm-java-agent-ignore-error/325563/3 "2023-02-16T03:28:52Z")

</div>

I tried to use \*java.lang.RuntimeException now, and it still doesn't work, I used elastic's opbeans app for this: [GitHub - elastic/opbeans-java: This is an implementation of the Opbeans Demo app in Java](https://github.com/elastic/opbeans-java), and generating the error by accessing path /is-it-coffee-time

Could you give more specific example to ignore this error perhaps?

---

<div class="post-metadata">

**Author:** ![Jack\_Shirazi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jack_shirazi/32/91641_2.png) [@Jack\_Shirazi](https://discuss.elastic.co/u/Jack_Shirazi)\
**Post date:** [February 16, 2023, 1:04pm UTC](https://discuss.elastic.co/t/apm-java-agent-ignore-error/325563/4 "2023-02-16T13:04:18Z")

</div>

What is the exact error you are seeing?

---

<div class="post-metadata">

**Author:** ![Ivan\_Hosea](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ivan_hosea/32/117268_2.png) [@Ivan\_Hosea](https://discuss.elastic.co/u/Ivan_Hosea)\
**Post date:** [February 17, 2023, 6:34am UTC](https://discuss.elastic.co/t/apm-java-agent-ignore-error/325563/5 "2023-02-17T06:34:08Z")

</div>

Here are the error picture & its error group detail on elastic apm:

 ![runtimeexception1](https://us1.discourse-cdn.com/elastic/original/3X/9/4/94f186b3d22fb8a6a9189ccad06cb67b860ff83d.png)  
 ![errorgroup](https://us1.discourse-cdn.com/elastic/original/3X/8/c/8cee66b16089f67624cc7471d79ec2d2b4abc5e4.png)

---

<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:** [February 20, 2023, 6:57am UTC](https://discuss.elastic.co/t/apm-java-agent-ignore-error/325563/6 "2023-02-20T06:57:43Z")

</div>

The agent prints all external configurations it sees at the top of its log in `INFO` level.  
Please verify that such lines are printed for `ignore_exceptions` and share them.

---

<div class="post-metadata">

**Author:** ![Ivan\_Hosea](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ivan_hosea/32/117268_2.png) [@Ivan\_Hosea](https://discuss.elastic.co/u/Ivan_Hosea)\
**Post date:** [February 20, 2023, 7:21am UTC](https://discuss.elastic.co/t/apm-java-agent-ignore-error/325563/7 "2023-02-20T07:21:31Z")

</div>

Here is the line:

 ![ignore_exception config](https://us1.discourse-cdn.com/elastic/original/3X/6/2/6250fa9e57c17299d44e2d260d4380c63cfe3054.jpeg)

---

<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:** [February 20, 2023, 7:59am UTC](https://discuss.elastic.co/t/apm-java-agent-ignore-error/325563/8 "2023-02-20T07:59:04Z")

</div>

Please try setting `unnest_exceptions=false` and see if it makes a difference, meaning - the exception should still be reported if it is nested, which needs to be fixed, but if it will be reported as the nesting type, it will tell us why we see this.

---

<div class="post-metadata">

**Author:** ![Ivan\_Hosea](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ivan_hosea/32/117268_2.png) [@Ivan\_Hosea](https://discuss.elastic.co/u/Ivan_Hosea)\
**Post date:** [February 20, 2023, 8:30am UTC](https://discuss.elastic.co/t/apm-java-agent-ignore-error/325563/9 "2023-02-20T08:30:43Z")

</div>

So I tried your suggestion above, and the errors become like this at first:

 ![nested exception](https://us1.discourse-cdn.com/elastic/original/3X/3/1/317395ef54c29751fa7cabcef0168a30da17242b.jpeg)

So I also added:

```auto
ignore_exceptions=*org.springframework.web.util.NestedServletException

```

and it actually works this time. However, I can't really differ the error if it was done this way since the other error is also classified as having the same NestedServletException error. Is there any way to differ this?

---

<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:** [February 20, 2023, 8:50am UTC](https://discuss.elastic.co/t/apm-java-agent-ignore-error/325563/10 "2023-02-20T08:50:04Z")

</div>

That was only for identifying the cause of this behavior. Now that we know why this happens, I should be able to easily fix that, so that when you set `ignore_exception`, it will take effect on the actual reported exception (in other words - first unnest if required and then filter).

---

<div class="post-metadata">

**Author:** ![Ivan\_Hosea](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ivan_hosea/32/117268_2.png) [@Ivan\_Hosea](https://discuss.elastic.co/u/Ivan_Hosea)\
**Post date:** [February 20, 2023, 10:05am UTC](https://discuss.elastic.co/t/apm-java-agent-ignore-error/325563/11 "2023-02-20T10:05:24Z")

</div>

Okay, I see, thanks for the information then, I appreciate it

---

<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:** [February 20, 2023, 11:37am UTC](https://discuss.elastic.co/t/apm-java-agent-ignore-error/325563/12 "2023-02-20T11:37:34Z")

</div>

@Ivan_Hosea I opened a [fix](https://github.com/elastic/apm-agent-java/pull/3025).  
Please try it as follows:

1. remove the `unnest_exceptions=false` setting
2. restore your former `ignore_exceptions` setting
3. replace your agent with the fix [snapshot](https://apm-ci.elastic.co/blue/organizations/jenkins/apm-agent-java%2Fapm-agent-java-mbp/detail/PR-3025/1/artifacts)
4. verify that it now works as expected

---

<div class="post-metadata">

**Author:** ![Nekstar](https://avatars.discourse-cdn.com/v4/letter/n/f08c70/32.png) [@Nekstar](https://discuss.elastic.co/u/Nekstar)\
**Post date:** [February 20, 2023, 12:37pm UTC](https://discuss.elastic.co/t/apm-java-agent-ignore-error/325563/13 "2023-02-20T12:37:42Z")

</div>

Hi @Eyal_Koren ,  
I just have the same problem with unnesting and ignoring exceptions and the provided snapshot version solves it for me. Thanks.  
I just have a (at least somehow) related question: Is it intended that the ignored exceptions still count against the 'Failed transaction rate'?

---

<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:** [February 20, 2023, 2:00pm UTC](https://discuss.elastic.co/t/apm-java-agent-ignore-error/325563/14 "2023-02-20T14:00:31Z")

</div>

Hi @Nekstar, welcome to the forum as well 🙂 and thanks for verifying the fix 🙏

The failed transaction rate is calculated based on the number of transaction that end with error. A transaction that ends with error is such where an exception is thrown out of the transaction-related instrumented method. For example, if the agent instruments your `Servlet`'s `doGet()` method to create a transaction and this method exits with an exception, then it will be considered as a failure. Unless this exception is specifically ignored, it will be reported as error **as well**. So, ignoring the exception type means that error events will not be sent for them, but they can still make the transaction considered as failure.

---

<div class="post-metadata">

**Author:** ![Nekstar](https://avatars.discourse-cdn.com/v4/letter/n/f08c70/32.png) [@Nekstar](https://discuss.elastic.co/u/Nekstar)\
**Post date:** [February 21, 2023, 2:55pm UTC](https://discuss.elastic.co/t/apm-java-agent-ignore-error/325563/15 "2023-02-21T14:55:56Z")

</div>

Hi, thanks for your explanation, now I got it 🙂

---

<div class="post-metadata">

**Author:** ![Ivan\_Hosea](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ivan_hosea/32/117268_2.png) [@Ivan\_Hosea](https://discuss.elastic.co/u/Ivan_Hosea)\
**Post date:** [February 22, 2023, 3:57am UTC](https://discuss.elastic.co/t/apm-java-agent-ignore-error/325563/16 "2023-02-22T03:57:16Z")

</div>

Hi @Eyal_Koren , I tried your fix and I can confirm that it works, thank you.

Also, at my first question I also asked about specific http error code filter for java, is this possible to do with the current module?

---

<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:** [February 22, 2023, 9:55am UTC](https://discuss.elastic.co/t/apm-java-agent-ignore-error/325563/17 "2023-02-22T09:55:34Z")

</div>

@Ivan_Hosea Thanks for the confirmation.  
The Java agent doesn't have a filtering concept as the NodeJS has.  
Instead, for such things you can use [ingest pipelines](https://www.elastic.co/guide/en/elasticsearch/reference/current/ingest.html). In this case, I think a [drop processor](https://www.elastic.co/guide/en/elasticsearch/reference/current/drop-processor.html#drop-processor) would be useful.

If the issue you see is related to [404 captured as error when using `HttpUrlConnection`](https://github.com/elastic/apm-agent-java/issues/2976), then look at the end of this issue's thread, it may be resolved with this issue's fix.

---

<div class="post-metadata">

**Author:** ![Ivan\_Hosea](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ivan_hosea/32/117268_2.png) [@Ivan\_Hosea](https://discuss.elastic.co/u/Ivan_Hosea)\
**Post date:** [February 23, 2023, 3:08am UTC](https://discuss.elastic.co/t/apm-java-agent-ignore-error/325563/18 "2023-02-23T03:08:59Z")

</div>

I see @Eyal_Koren , thanks for the confirmation

---

<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 15, 2023, 11:09pm UTC](https://discuss.elastic.co/t/apm-java-agent-ignore-error/325563/19 "2023-03-15T23:09:46Z")

</div>

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