Splunk Search

How to limit X of Java exception from single event

jw44250
New Member

index=myIndex sourcetype=myIndexSource java.lang.Exception

In my log i can see 3 or more java.lang.Exception at per event time but i want to pick only one - currently Splunk highlights them - I have been using rex as well but i think something is not correct .

|rex field=_raw "\s(?(java|javax).\w+.\w+Exception)"

0 Karma

DalJeanis
Legend

1) With that rex, you should only get the first one. (max_match defaults to 1) This is assuming that the rex contains a field name in angle brackets <>. Please mark your code - either with the 101 010 button or the grave accent (to the left of the 1 on a standard US keyboard) before and after it to prevent the interface from obeying or stripping out things that look like HTML formatting commands. For large pieces of code, you can also just make sure there are at least four spaces at the beginning of each line.

|rex field=_raw "\s(?<myExcp>(java|javax).\w+.\w+Exception)"

2) If the sourcetype is set to extract KV, you will get all of them.

0 Karma
Get Updates on the Splunk Community!

Get Operational Insights Quickly with Natural Language on the Splunk Platform

In today’s fast-paced digital world, turning data into actionable insights is essential for success. With ...

Stay Connected: Your Guide to August Tech Talks, Office Hours, and Webinars!

What are Community Office Hours?Community Office Hours is an interactive 60-minute Zoom series where ...

Unleash the Power of Splunk MCP and AI, Meet Us at .Conf 2025, and Find Even More New ...

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...