elastic / ecs-logging-java

https://www.elastic.co/guide/en/ecs-logging/java/current/intro.html
Apache License 2.0
141 stars 75 forks source link

Include a stack hash as error.id #166

Closed brushmate closed 2 years ago

brushmate commented 2 years ago

The Logstash Logback Encoder can calculate stable hashes for individual exceptions. This is very helpful as it let's you detect several occurrences of the same exception.

Is it currently possible to include a stack hash with ECS logging? And if not, is it a feature that could be added?

felixbarny commented 2 years ago

Thanks for the issue. Sounds like a very useful feature. We already have something similar in Elastic APM: the Java agent captures ERROR logs and sends them to APM Server. The server then creates an error group based on the stack trace. To make the hash more consistent across different versions of the application, it strips the line numbers which are expected to change more frequently than method names. See https://www.elastic.co/guide/en/kibana/current/errors.html for more info.

The advantages of doing it server-side is that it takes fewer resources in your application and that it's consistent across languages. For a similar functionality, you could also look at the fingerprint Elasticsearch ingest processor.

eyalkoren commented 2 years ago

@brushmate Thanks for the input! Since this can be done through the ingestion pipeline, we decided not to prioritize and close the issue at this time.

If you (or someone else) want to contribute this functionality in a way that will be robust and performant enough, please reopen the issue once you create the PR and we will try and assist.