<?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: rex lines after stats list() in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-list-all-the-events-on-same-timestamp-and-capture-only/m-p/654977#M226258</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/253572"&gt;@Thulasinathan_M&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;yes I supposed this, for this reason I hinted to do this!&lt;/P&gt;&lt;P&gt;Could you share some sample of your logs?&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
    <pubDate>Sun, 20 Aug 2023 16:33:06 GMT</pubDate>
    <dc:creator>gcusello</dc:creator>
    <dc:date>2023-08-20T16:33:06Z</dc:date>
    <item>
      <title>How to list all the events on same timestamp and capture only the required line?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-list-all-the-events-on-same-timestamp-and-capture-only/m-p/654972#M226254</link>
      <description>&lt;P&gt;Hi Splunk Experts,&lt;/P&gt;
&lt;P&gt;I'm trying to list all the events on same timestamp and trying to capture only the required lines. But I'm not getting the expected results, seems like there is no "\n" in the aggregated event eventhough it breaks into new lines. Kindly shred some lights. Thanks in advance!!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've events something like below, after aggregating them by _time:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Line1 blablabla
Line2 blablabla
&amp;lt;Interested line1&amp;gt;
&amp;lt;Interested line2&amp;gt;
&amp;lt;Interested line3&amp;gt;
&amp;lt;Ends Here&amp;gt;
Unwanted Line blablabla&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Query Using:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;index=xxx 
| reverse 
| stats list(_raw) as raw by _time
| rex field=raw "(?&amp;lt;Events&amp;gt;(\&amp;lt;Interested.*)((\n.*)?)+\&amp;lt;Ends Here\&amp;gt;)"&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Result for the Above query:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;&amp;lt;Interested line1&amp;gt;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 21 Aug 2023 19:45:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-list-all-the-events-on-same-timestamp-and-capture-only/m-p/654972#M226254</guid>
      <dc:creator>Thulasinathan_M</dc:creator>
      <dc:date>2023-08-21T19:45:48Z</dc:date>
    </item>
    <item>
      <title>Re: rex lines after stats list()</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-list-all-the-events-on-same-timestamp-and-capture-only/m-p/654974#M226255</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/253572"&gt;@Thulasinathan_M&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;did you tried to invert the two commands?&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=xxx 
| bin span=1h _time
| rex "(?&amp;lt;Events&amp;gt;(\&amp;lt;Interested.*)((\n.*)?)+\&amp;lt;Ends Here\&amp;gt;)"
| stats values(Events) AS Events BY _time&lt;/LI-CODE&gt;&lt;P&gt;In addition, when you use _time as grouping key, usa always a bin command to group _time values or use timechart command, otherwise you'll have too many results.&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Sun, 20 Aug 2023 15:12:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-list-all-the-events-on-same-timestamp-and-capture-only/m-p/654974#M226255</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2023-08-20T15:12:13Z</dc:date>
    </item>
    <item>
      <title>Re: rex lines after stats list()</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-list-all-the-events-on-same-timestamp-and-capture-only/m-p/654976#M226257</link>
      <description>&lt;P&gt;Thanks &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;!!&lt;BR /&gt;But those are Single Line Events, so I can't perform REX before stats.&lt;/P&gt;</description>
      <pubDate>Sun, 20 Aug 2023 15:52:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-list-all-the-events-on-same-timestamp-and-capture-only/m-p/654976#M226257</guid>
      <dc:creator>Thulasinathan_M</dc:creator>
      <dc:date>2023-08-20T15:52:13Z</dc:date>
    </item>
    <item>
      <title>Re: rex lines after stats list()</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-list-all-the-events-on-same-timestamp-and-capture-only/m-p/654977#M226258</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/253572"&gt;@Thulasinathan_M&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;yes I supposed this, for this reason I hinted to do this!&lt;/P&gt;&lt;P&gt;Could you share some sample of your logs?&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Sun, 20 Aug 2023 16:33:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-list-all-the-events-on-same-timestamp-and-capture-only/m-p/654977#M226258</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2023-08-20T16:33:06Z</dc:date>
    </item>
    <item>
      <title>Re: rex lines after stats list()</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-list-all-the-events-on-same-timestamp-and-capture-only/m-p/654978#M226259</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;&amp;nbsp;Sure, Here is the sample Events, which are all of single line events.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=xxx
| reverse
| stats list(_raw) as raw by _time
| rex field=raw "(?&amp;lt;Events&amp;gt;(Event Type.*)((\n.*)?)+Event ID:  \d+)"&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;Events:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;2023-08-20 22:10:10.879 Date: 20/08/2023&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;2023-08-20 22:10:10.879 User: DILE\Administrator&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;2023-08-20 22:10:10.879 Event Type: Information&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;2023-08-20 22:10:10.879 Event Source: AdsmClientService&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;2023-08-20 22:10:10.879 Event Category: None&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;2023-08-20 22:10:10.879 Event ID: 4101&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;2023-08-20 22:10:10.879 Computer: MIKEDILE&lt;/LI-CODE&gt;</description>
      <pubDate>Sun, 20 Aug 2023 16:46:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-list-all-the-events-on-same-timestamp-and-capture-only/m-p/654978#M226259</guid>
      <dc:creator>Thulasinathan_M</dc:creator>
      <dc:date>2023-08-20T16:46:53Z</dc:date>
    </item>
    <item>
      <title>Re: rex lines after stats list()</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-list-all-the-events-on-same-timestamp-and-capture-only/m-p/654981#M226260</link>
      <description>&lt;P&gt;It looks like that your intention is to capture raw events with "Event Type" and "Event ID" in them. &amp;nbsp;It would have been so much easier if you just describe the actual goal.&lt;/P&gt;&lt;P&gt;You are correct that when you use list command, the resultant field doesn't have newline "\n" in it. &amp;nbsp;It is simply a multivalued field that Splunk's Statistics tab presents in multiple lines.&lt;/P&gt;&lt;P&gt;I see two different approaches to this problem. &amp;nbsp;But before that, let me comment that you should approach your developer or aggregator, whoever made these logs into multiple events, and beg, harass, or intimidate them to combine these into a single event for Splunk. &amp;nbsp;It will not only be better for Splunk, but also for people who may read the log files manually.&lt;/P&gt;&lt;P&gt;The most straightforward approach will be to not bother with regex or "\n".&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=xxx
| reverse
| stats list(_raw) as raw by _time
| eval Events = mvappend(mvfind(raw, "Event Type:"), mvfind(raw, "Event End:"))&lt;/LI-CODE&gt;&lt;P&gt;Note "Events" here is also multi-valued. &amp;nbsp;In my opinion, multivalued fields are more useful subsequently. &amp;nbsp;But if you really want them to be single valued with newline, just insert newline as exemplified in the next method.&lt;/P&gt;&lt;P&gt;If you really, really must go with "\n", just insert it.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=xxx
| reverse
| stats list(_raw) as raw by _time
| eval raw = mvjoin(raw, "
")
| rex field=raw "(?&amp;lt;Events&amp;gt;(Event Type.*)((\n.*)?)+Event ID:  \d+)"&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 20 Aug 2023 23:22:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-list-all-the-events-on-same-timestamp-and-capture-only/m-p/654981#M226260</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2023-08-20T23:22:25Z</dc:date>
    </item>
    <item>
      <title>Re: rex lines after stats list()</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-list-all-the-events-on-same-timestamp-and-capture-only/m-p/655005#M226270</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/253572"&gt;@Thulasinathan_M&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;as I said, you can extract fields before the stats command and then use the xtracted field (or fields) in addition to the entire raw:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=xxx
| rex "(?&amp;lt;Events&amp;gt;(Event Type.*)((\n.*)?)+Event ID:  \d+)"
| stats list(_raw) AS raw values(Event_Type) AS Event_Type BY _time&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;if you want you can extract also the other fields in the same way, always before the stats command.&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Mon, 21 Aug 2023 09:18:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-list-all-the-events-on-same-timestamp-and-capture-only/m-p/655005#M226270</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2023-08-21T09:18:45Z</dc:date>
    </item>
  </channel>
</rss>

