<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to parse events before indexing? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-parse-events-before-indexing/m-p/653475#M225818</link>
    <description>&lt;P&gt;Essentially, you want your events to break at a newline followed by a timestamp?&lt;/P&gt;&lt;P&gt;What do you currently have configured?&lt;/P&gt;</description>
    <pubDate>Mon, 07 Aug 2023 21:57:11 GMT</pubDate>
    <dc:creator>ITWhisperer</dc:creator>
    <dc:date>2023-08-07T21:57:11Z</dc:date>
    <item>
      <title>How to parse events before indexing?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-parse-events-before-indexing/m-p/653451#M225810</link>
      <description>&lt;P&gt;Hi Splunk Experts,&lt;BR /&gt;I want to break all lines as a single Line event [\r\n]. But if there are logs with stacktrace I want to consider them as multi-line event.&amp;nbsp;&lt;BR /&gt;I've tested below regex and it works as expected, but I'm not sure on, what are the properties I should apply them for a sourcetype. This is for an application which logs millions of event in a minute. Please assist me with an optimized solution.&lt;/P&gt;
&lt;P&gt;(.*[\n]((.*\)\])?(\s+at.*\)\n))+)&lt;BR /&gt;&lt;BR /&gt;Sample logs:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;[(2023-08-03 10:00:03)] INFO: Request completed successfully.
[(2023-08-03 10:00:03)] ERROR: Request got failed.
[(2023-08-03 10:00:02)] Exception in thread "main" java.lang.NullPointerException
	at com.example.MyClass.method1(MyClass.java:12)
	at com.example.MyClass.method2(MyClass.java:34)
	at com.example.AnotherClass.someMethod(AnotherClass.java:56)
	at com.example.Main.main(Main.java:23)
[(2023-08-03 10:00:03)] INFO: Request Submitted successfully.
[(2023-08-03 10:00:03)] INFO: Request completed successfully.
[(2023-08-03 10:00:03)] WARN: Request failed unsuccessfully.
[(2023-08-03 10:00:02)] java.io.FileNotFoundException: file.txt (No such file or directory)
[(2023-08-03 10:00:02)]	at java.base/java.io.FileInputStream.open0(Native Method)
[(2023-08-03 10:00:02)]	at java.base/java.io.FileInputStream.open(FileInputStream.java:219)
[(2023-08-03 10:00:02)]	at java.base/java.io.FileInputStream.&amp;lt;init&amp;gt;(FileInputStream.java:157)
[(2023-08-03 10:00:02)]	at java.base/java.io.FileInputStream.&amp;lt;init&amp;gt;(FileInputStream.java:112)
[(2023-08-03 10:00:02)]	at com.example.FileDemo.readFromFile(FileDemo.java:55)
[(2023-08-03 10:00:02)]	at com.example.Main.main(Main.java:12)
[(2023-08-03 10:00:03)] INFO: Request completed successfully.
[(2023-08-03 10:00:04)] DEBUG: Processing request: /api/v1/data?id=67890
[(2023-08-03 10:00:03)] WARN: Request failed unsuccessfully. java.lang.IllegalArgumentException: Invalid input: negative value not allowed
[(2023-08-03 10:00:02)]	at com.example.MathUtils.squareRoot(MathUtils.java:42)
[(2023-08-03 10:00:02)]	at com.example.Main.main(Main.java:33)
[(2023-08-03 10:00:02)] ERROR: Failed to fetch data from the database.&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Expected First Multi-Line Event:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;[(2023-08-03 10:00:02)] Exception in thread "main" java.lang.NullPointerException
	at com.example.MyClass.method1(MyClass.java:12)
	at com.example.MyClass.method2(MyClass.java:34)
	at com.example.AnotherClass.someMethod(AnotherClass.java:56)
	at com.example.Main.main(Main.java:23)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Expected Second Multi-Line Event:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;[(2023-08-03 10:00:02)] java.io.FileNotFoundException: file.txt (No such file or directory)
[(2023-08-03 10:00:02)]	at java.base/java.io.FileInputStream.open0(Native Method)
[(2023-08-03 10:00:02)]	at java.base/java.io.FileInputStream.open(FileInputStream.java:219)
[(2023-08-03 10:00:02)]	at java.base/java.io.FileInputStream.&amp;lt;init&amp;gt;(FileInputStream.java:157)
[(2023-08-03 10:00:02)]	at java.base/java.io.FileInputStream.&amp;lt;init&amp;gt;(FileInputStream.java:112)
[(2023-08-03 10:00:02)]	at com.example.FileDemo.readFromFile(FileDemo.java:55)
[(2023-08-03 10:00:02)]	at com.example.Main.main(Main.java:12)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Expected Third Multi-Line Event:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;[(2023-08-03 10:00:03)] WARN: Request failed unsuccessfully. java.lang.IllegalArgumentException: Invalid input: negative value not allowed
[(2023-08-03 10:00:02)]	at com.example.MathUtils.squareRoot(MathUtils.java:42)
[(2023-08-03 10:00:02)]	at com.example.Main.main(Main.java:33)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Aug 2023 19:30:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-parse-events-before-indexing/m-p/653451#M225810</guid>
      <dc:creator>Thulasinathan_M</dc:creator>
      <dc:date>2023-08-07T19:30:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse events before indexing?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-parse-events-before-indexing/m-p/653475#M225818</link>
      <description>&lt;P&gt;Essentially, you want your events to break at a newline followed by a timestamp?&lt;/P&gt;&lt;P&gt;What do you currently have configured?&lt;/P&gt;</description>
      <pubDate>Mon, 07 Aug 2023 21:57:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-parse-events-before-indexing/m-p/653475#M225818</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2023-08-07T21:57:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse events before indexing?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-parse-events-before-indexing/m-p/653487#M225826</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Currently the configuration is below&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;CHARSET=UTF-8
SHOULD_LINEMERGE=true
disabled=false
LINE_BREAKER=([\r\n]+)
NO_BINARY_CHECK=true&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2023 02:18:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-parse-events-before-indexing/m-p/653487#M225826</guid>
      <dc:creator>Thulasinathan_M</dc:creator>
      <dc:date>2023-08-08T02:18:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse events before indexing?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-parse-events-before-indexing/m-p/653491#M225827</link>
      <description>&lt;P&gt;you have&amp;nbsp; a single file, but you want to do multiple line breaking in that single file... is that right?&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2023 03:50:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-parse-events-before-indexing/m-p/653491#M225827</guid>
      <dc:creator>inventsekar</dc:creator>
      <dc:date>2023-08-08T03:50:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse events before indexing?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-parse-events-before-indexing/m-p/653492#M225828</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/80737"&gt;@inventsekar&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Yes that's correct!! I want to break each &amp;amp; every lines as a single line event, but if there are any logs met above condition mentioned in the post, then I want to wrap those logs as a multi-line event and this should be applicable to all files under my sourcetype.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2023 04:03:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-parse-events-before-indexing/m-p/653492#M225828</guid>
      <dc:creator>Thulasinathan_M</dc:creator>
      <dc:date>2023-08-08T04:03:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse events before indexing?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-parse-events-before-indexing/m-p/653495#M225831</link>
      <description>&lt;P&gt;Pls check this&amp;nbsp;&lt;A href="https://community.splunk.com/t5/Getting-Data-In/Line-break-with-multiple-Linebreaker/m-p/400335" target="_blank"&gt;https://community.splunk.com/t5/Getting-Data-In/Line-break-with-multiple-Linebreaker/m-p/400335&lt;/A&gt;&lt;/P&gt;&lt;P&gt;the values for BREAK_ONLY_BEFORE, MUST_NOT_BREAK_AFTER, MUST_BREAK_AFTER should be updated for your requirement properly..&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;rough one..&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;BREAK_ONLY_BEFORE=^Exception | ^java.io.FileNotFoundException | ^WARN
MUST_NOT_BREAK_AFTER=something here
MUST_BREAK_AFTER=something here&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2023 04:29:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-parse-events-before-indexing/m-p/653495#M225831</guid>
      <dc:creator>inventsekar</dc:creator>
      <dc:date>2023-08-08T04:29:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse events before indexing?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-parse-events-before-indexing/m-p/653507#M225838</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;Based on your example you could try something like this. If/when needed you should add those keywords (into LINE_BREAKER) which are starting a new event here&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[&amp;lt;your sourcetype&amp;gt;]
SHOULD_LINEMERGE=true
LINE_BREAKER=([\r\n]+)\[\(\d{4}-\d\d-\d\d \d\d:\d\d:\d\d\)\]\s([\w\.]+:|Exception)
NO_BINARY_CHECK=true
TIME_FORMAT=%F %T
TIME_PREFIX=^\[\(
MAX_TIMESTAMP_LOOKAHEAD=20&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Usually it's better if you could avoid those BREAK_ONLY_BEFORE, UST_NOT_BREAK_AFTER and MUST_BREAK_AFTER. Those are working, but those use more resources than using only LINE_BREAKER definition.&lt;/P&gt;&lt;P&gt;r. Ismo&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2023 06:50:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-parse-events-before-indexing/m-p/653507#M225838</guid>
      <dc:creator>isoutamo</dc:creator>
      <dc:date>2023-08-08T06:50:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse events before indexing?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-parse-events-before-indexing/m-p/653514#M225840</link>
      <description>&lt;P&gt;Thanks for the pointers,&amp;nbsp;I've come-up with below config, but still it's not working and it looks bit messy. What I've done is:&lt;BR /&gt;Line_Breaker: Broken down events based on the Timestamp/ Previous line of first matching line with 'at'/ Last matching line with 'at'&lt;BR /&gt;BREAK_ONLY_BEFORE:&amp;nbsp;Timestamp/&amp;nbsp;Previous line of first matching line with 'at'&lt;BR /&gt;MUST_NOT_BREAK_AFTER:&amp;nbsp;Previous line of first matching line with 'at'&lt;BR /&gt;MUST_BREAK_AFTER:&amp;nbsp;Last matching line with 'at'&lt;BR /&gt;Any suggestion on what I've done wrong please.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;SHOULD_LINEMERGE=false
LINE_BREAKER=([\r\n]+)(?:(\[\(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\)\])|(\[\(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\)\]\s+(?!at).*)\n(?:\[\(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\)\]\s+(?=at).*)|(\[\(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\)\]\s+(?=at).*)\n(?:\[\(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\)\]\s+(?!at).*)
NO_BINARY_CHECK=true
MUST_NOT_BREAK_AFTER=^(\[\(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\)\]\s+(?!at).*)\n(?:\[\(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\)\]\s+(?=at).*)
BREAK_ONLY_BEFORE=^(\[\(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\)\])|^(\[\(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\)\]\s+(?!at).*)\n(?:\[\(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\)\]\s+(?=at).*)
MUST_BREAK_AFTER=^(\[\(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\)\]\s+(?=at).*)\n(?:\[\(\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\)\]\s+(?!at).*)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2023 06:55:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-parse-events-before-indexing/m-p/653514#M225840</guid>
      <dc:creator>Thulasinathan_M</dc:creator>
      <dc:date>2023-08-08T06:55:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse events before indexing?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-parse-events-before-indexing/m-p/653516#M225841</link>
      <description>Have you try my example? Based on your example events, it works on my test env.</description>
      <pubDate>Tue, 08 Aug 2023 06:58:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-parse-events-before-indexing/m-p/653516#M225841</guid>
      <dc:creator>isoutamo</dc:creator>
      <dc:date>2023-08-08T06:58:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse events before indexing?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-parse-events-before-indexing/m-p/653518#M225842</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/214410"&gt;@isoutamo&lt;/a&gt;. It's Working as expected with sample inputs. But I can't rely on below pattern because it could be anything. Only thing I could make sure is 'at' followed by path to the file(Stacktraces).&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;([\w\.]+:|Exception)&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 08 Aug 2023 07:07:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-parse-events-before-indexing/m-p/653518#M225842</guid>
      <dc:creator>Thulasinathan_M</dc:creator>
      <dc:date>2023-08-08T07:07:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to parse events before indexing?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-parse-events-before-indexing/m-p/653535#M225844</link>
      <description>&lt;P&gt;Ok. I just look that your log events contains &amp;lt;Log level&amp;gt;: or &amp;lt;java class&amp;gt;: or that Exception key words which are defining &amp;nbsp;a start of new individual event.&lt;/P&gt;&lt;P&gt;You could try to get correct regex to match this on Splunk Slack #regex channel&amp;nbsp;&lt;A href="https://splunk-usergroups.slack.com/archives/C3WFE5V5G" target="_blank"&gt;https://splunk-usergroups.slack.com/archives/C3WFE5V5G&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 08 Aug 2023 07:38:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-parse-events-before-indexing/m-p/653535#M225844</guid>
      <dc:creator>isoutamo</dc:creator>
      <dc:date>2023-08-08T07:38:23Z</dc:date>
    </item>
  </channel>
</rss>

