# Extract specific line from java stack trace

**URL:** <https://discuss.elastic.co/t/extract-specific-line-from-java-stack-trace/273180>\
**Category:** Logstash\
**Created:** [May 17, 2021, 1:44pm UTC](https://discuss.elastic.co/t/extract-specific-line-from-java-stack-trace/273180 "2021-05-17T13:44:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![gerry1](https://avatars.discourse-cdn.com/v4/letter/g/7c8e57/32.png) [@gerry1](https://discuss.elastic.co/u/gerry1)\
**Post date:** [May 17, 2021, 1:44pm UTC](https://discuss.elastic.co/t/extract-specific-line-from-java-stack-trace/273180/1 "2021-05-17T13:44:27Z")

</div>

hi everyone,

what i need to do is to extract from a java stack trace a specific line using the elk stack.  
What i have, as example, is the exception below and in kibana I want to have only the line starting with com.host.financial.plat.system.end.processor\*\*\*\*\*\*\* . At the moment, with the multiline options I'm able to take the whole exception stack trace but only one line is what i need (if it's possible).

`````````auto
* at org.springframework.orm.jpa.vendor.HibernateJpaDialect.convertHibernateAccessException(HibernateJpaDialect.java:299)*
* at org.springframework.orm.jpa.vendor.HibernateJpaDialect.translateExceptionIfPossible(HibernateJpaDialect.java:223)*
* at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:540)*
* at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:746)*
* at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:714)*
* at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:532)*
* at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:304)*
* at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:98)*
* at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185)*
* at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:688)*
* at **com.host.financial.plat.system.end.processor.AnalyticsProcessor$$EnhancerBySpringCGLIB$$d660f5cd.process(<generated>)***
* ... 26 common frames omitted*````````

thank you in advance
Gerardo
`````````

---

<div class="post-metadata">

**Author:** ![Badger](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/badger/32/25190_2.png) [@Badger](https://discuss.elastic.co/u/Badger)\
**Post date:** [May 17, 2021, 11:13pm UTC](https://discuss.elastic.co/t/extract-specific-line-from-java-stack-trace/273180/2 "2021-05-17T23:13:11Z")

</div>

You might be able to do it by combining all the lines of the trace with a multiline codec (I think the documentation has an example involving a Java stack trace), then use mutate+split to turn that into an array of lines, then use mutate+add\_field to extract the last but one entry.

---

<div class="post-metadata">

**Author:** ![gerry1](https://avatars.discourse-cdn.com/v4/letter/g/7c8e57/32.png) [@gerry1](https://discuss.elastic.co/u/gerry1)\
**Post date:** [May 19, 2021, 1:45pm UTC](https://discuss.elastic.co/t/extract-specific-line-from-java-stack-trace/273180/3 "2021-05-19T13:45:31Z")

</div>

thx man, this worked great.

---

<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:** [June 16, 2021, 1:45pm UTC](https://discuss.elastic.co/t/extract-specific-line-from-java-stack-trace/273180/4 "2021-06-16T13:45:36Z")

</div>

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