# Incorrect Error Grouping

**URL:** <https://discuss.elastic.co/t/incorrect-error-grouping/215939>\
**Category:** APM\
**Tags:** nodejs, server\
**Created:** [January 21, 2020, 6:43pm UTC](https://discuss.elastic.co/t/incorrect-error-grouping/215939 "2020-01-21T18:43:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matthew\_Petrie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/matthew_petrie/32/59145_2.png) [@Matthew\_Petrie](https://discuss.elastic.co/u/Matthew_Petrie)\
**Post date:** [January 21, 2020, 6:43pm UTC](https://discuss.elastic.co/t/incorrect-error-grouping/215939/1 "2020-01-21T18:43:50Z")

</div>

**Kibana version** : 7.5.1  
**Elasticsearch version** : 7.5.1  
**APM Server version** : 7.5.1  
**APM Agent language and version** : Node.JS 3.3.0  
**Original install method** : Elastic Cloud

Some of our errors being incorrectly grouped together. It seems the errors that get grouped together have the same error class (standard Node.JS `Error`) and the same stacktrace (**[1]** i.e. an external service may produce multiple different errors which we then turn into an `Error` class which would have the same stacktrace). The error messages are completely different. This is a large problem as we are not being correctly notified about error groups through Watcher & we have to manually go into Discover to view the error log messages to work out the correct error grouping.

Some of the errors are being grouped correctly (different stacktraces) even when the error message has an id that varies (i.e. `my product had a problem (id: "f37i87"`) which is great.

My Go isn't too great but it looks like a fair amount of the grouping relies on the stacktrace and error class: [https://github.com/elastic/apm-server/blob/master/model/error/event.go#L331](https://github.com/elastic/apm-server/blob/master/model/error/event.go#L331)

I can provide an example of some of the incorrectly grouped errors if required but would only be able to do this privately.

Is there a better way to handle **[1]** (above) to enable correct error grouping?

Many thanks, Matthew

---

<div class="post-metadata">

**Author:** ![simitt](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/simitt/32/106406_2.png) [@simitt](https://discuss.elastic.co/u/simitt)\
**Post date:** [January 23, 2020, 11:14am UTC](https://discuss.elastic.co/t/incorrect-error-grouping/215939/2 "2020-01-23T11:14:21Z")

</div>

Hi @Matthew_Petrie,  
the APM Server generally supports sending an `error.exception.cause` which should point to the original error. If this information was sent up, the grouping keys would differ based on different `causes`. Unfortunately the nodejs agent does not yet support sending causes.

You were mentioning that error messages differ. If any other information is given, then such messages are not considered in the grouping key logic, to avoid creating unique keys per IDs or names. Since in your case the errors provide a stacktrace the messages are ignored.  
Looking at the [nodejs agent's API](https://www.elastic.co/guide/en/apm/agent/nodejs/2.x/agent-api.html#parameterized-message-object) I was wondering if it were an option for you to send the error `message` as `parameterized message` which would be considered in the grouping key logic.

---

<div class="post-metadata">

**Author:** ![Matthew\_Petrie](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/matthew_petrie/32/59145_2.png) [@Matthew\_Petrie](https://discuss.elastic.co/u/Matthew_Petrie)\
**Post date:** [January 23, 2020, 11:40am UTC](https://discuss.elastic.co/t/incorrect-error-grouping/215939/3 "2020-01-23T11:40:50Z")

</div>

> [@simitt](#):
>
> send the error `message` as `parameterized message` which would be considered in the grouping key logic.

Yes this should work - thanks, appreciated! 🙂

---

<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:** [February 13, 2020, 7:40am UTC](https://discuss.elastic.co/t/incorrect-error-grouping/215939/4 "2020-02-13T07:40:54Z")

</div>

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