<?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: condense many line response results to a small table in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/condense-many-line-response-results-to-a-small-table/m-p/337703#M100174</link>
    <description>&lt;P&gt;1) You could use &lt;CODE&gt;min(time&lt;/CODE&gt;) in line 5 and delete line 4.&lt;BR /&gt;&lt;BR /&gt;
2)  line 3 is more likely to be &lt;CODE&gt;| eval rule=if(isnull(subject),rule,null())&lt;/CODE&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 06 Mar 2017 22:30:07 GMT</pubDate>
    <dc:creator>DalJeanis</dc:creator>
    <dc:date>2017-03-06T22:30:07Z</dc:date>
    <item>
      <title>condense many line response results to a small table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/condense-many-line-response-results-to-a-small-table/m-p/337701#M100172</link>
      <description>&lt;P&gt;I'm working with email response data which comes into my index in individual messages.  Each email message can have more than 100 entries in the index.&lt;/P&gt;

&lt;P&gt;I'm trying to build tables to make the data easy to read.&lt;/P&gt;

&lt;P&gt;This is what some simplified and sanitized results from my search look like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[01:00:22.164297] x=ABC mod=mail cmd=msg rule=ruleQ subject="Test 123" size=8583
[01:00:22.136496] x=ABC mod=spam cmd=run rule=notspam 
[01:00:22.106325] x=ABC mod=spam cmd=run policy=outbound
[01:00:22.067675] x=ABC mod=mail cmd=attachment file=text.html size=3347 
[01:00:22.039732] x=ABC mod=mail cmd=attachment file=text.txt size=2093 
[01:00:22.010986] x=ABC mod=session cmd=data rcpt=personA@rec.org
[01:00:22.010986] x=ABC mod=session cmd=data rcpt=personB@rec.org
[01:00:22.000234] x=ABC mod=mail sender=noreply@sender.org
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Tabled to show how data is structured for columns I care about:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;╔═══════════════════╦═════╦══════════╦═══════════╦════════════════════╦═════════════════╦══════╦═════════╗
║        time       ║  x  ║ subject  ║   file    ║       sender       ║      rcpt       ║ size ║  rule   ║
╠═══════════════════╬═════╬══════════╬═══════════╬════════════════════╬═════════════════╬══════╬═════════╣
║ [01:00:22.164297] ║ ABC ║ Test 123 ║           ║                    ║                 ║ 8583 ║ ruleQ   ║
║ [01:00:22.136496] ║ ABC ║          ║           ║                    ║                 ║      ║ notspam ║
║ [01:00:22.106325] ║ ABC ║          ║           ║                    ║                 ║      ║         ║
║ [01:00:22.067675] ║ ABC ║          ║ text.html ║                    ║                 ║ 3347 ║         ║
║ [01:00:22.039732] ║ ABC ║          ║ text.txt  ║                    ║                 ║ 2093 ║         ║
║ [01:00:22.010986] ║ ABC ║          ║           ║                    ║ personA@rec.org ║      ║         ║
║ [01:00:22.010986] ║ ABC ║          ║           ║                    ║ personB@rec.org ║      ║         ║
║ [01:00:22.000234] ║ ABC ║          ║           ║ noreply@sender.org ║                 ║      ║         ║
╚═══════════════════╩═════╩══════════╩═══════════╩════════════════════╩═════════════════╩══════╩═════════╝
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This is what I'd like to get back:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;╔═══════════════════╦═════╦══════════╦═══════════╦════════════════════╦═════════════════╦══════╦═════════╗
║        time       ║  x  ║ subject  ║   file    ║       sender       ║      rcpt       ║ size ║  rule   ║
╠═══════════════════╬═════╬══════════╬═══════════╬════════════════════╬═════════════════╬══════╬═════════╣
║ [01:00:22.164297] ║ ABC ║ Test 123 ║ text.html ║ noreply@sender.org ║ personA@rec.org ║ 3347 ║ notspam ║
║ [01:00:22.164297] ║ ABC ║ Test 123 ║ text.txt  ║ noreply@sender.org ║ personA@rec.org ║ 2093 ║ notspam ║
║ [01:00:22.164297] ║ ABC ║ Test 123 ║ text.html ║ noreply@sender.org ║ personB@rec.org ║ 3347 ║ notspam ║
║ [01:00:22.164297] ║ ABC ║ Test 123 ║ text.txt  ║ noreply@sender.org ║ personB@rec.org ║ 2093 ║ notspam ║
╚═══════════════════╩═════╩══════════╩═══════════╩════════════════════╩═════════════════╩══════╩═════════╝
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;As you can see, the transformations I want for the data include:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;creating a unique row for each person receiving each attachment&lt;/LI&gt;
&lt;LI&gt;the size value is for the attachment, while the size of the whole&lt;BR /&gt;
message is dropped&lt;/LI&gt;
&lt;LI&gt;The time from the entry which contains the subject name is used for each entry&lt;/LI&gt;
&lt;LI&gt;The 'rule' from mod=spam AND rule!=null fills in the rule column for
each entry, and the rule from the line which contains subject is ignored&lt;/LI&gt;
&lt;LI&gt;The subject, sender and rule get copied to every entry&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Mon, 06 Mar 2017 20:18:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/condense-many-line-response-results-to-a-small-table/m-p/337701#M100172</guid>
      <dc:creator>drinkingjimmy</dc:creator>
      <dc:date>2017-03-06T20:18:58Z</dc:date>
    </item>
    <item>
      <title>Re: condense many line response results to a small table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/condense-many-line-response-results-to-a-small-table/m-p/337702#M100173</link>
      <description>&lt;P&gt;Give this a try&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search 
| eval filesize=if(isnotnull(file), file."#".size,null())
| eval rule=if(mod="spam" AND isnotnull(rule),rule,null())
| eval time=if(isnotnull(subject),time,null())
| stats values(filesize) as filesize values(subject) as subject values(sender) as sender values(rcpt) as rcpt values(rule) as rule values(time) as time by x
| mvexpand rcpt | mvexpand filesize
| rex field=filesize "(?&amp;lt;file&amp;gt;[^#]+)#(?&amp;lt;size&amp;gt;.+)" 
| table time x subject file sender rcpt size rule
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 06 Mar 2017 22:09:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/condense-many-line-response-results-to-a-small-table/m-p/337702#M100173</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-03-06T22:09:50Z</dc:date>
    </item>
    <item>
      <title>Re: condense many line response results to a small table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/condense-many-line-response-results-to-a-small-table/m-p/337703#M100174</link>
      <description>&lt;P&gt;1) You could use &lt;CODE&gt;min(time&lt;/CODE&gt;) in line 5 and delete line 4.&lt;BR /&gt;&lt;BR /&gt;
2)  line 3 is more likely to be &lt;CODE&gt;| eval rule=if(isnull(subject),rule,null())&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Mar 2017 22:30:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/condense-many-line-response-results-to-a-small-table/m-p/337703#M100174</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-03-06T22:30:07Z</dc:date>
    </item>
    <item>
      <title>Re: condense many line response results to a small table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/condense-many-line-response-results-to-a-small-table/m-p/337704#M100175</link>
      <description>&lt;P&gt;This is much better than the direction I was going!&lt;/P&gt;

&lt;P&gt;I was trying to use transaction, but couldn't match up the file sizes with the names after the fact.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Mar 2017 22:49:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/condense-many-line-response-results-to-a-small-table/m-p/337704#M100175</guid>
      <dc:creator>drinkingjimmy</dc:creator>
      <dc:date>2017-03-06T22:49:16Z</dc:date>
    </item>
    <item>
      <title>Re: condense many line response results to a small table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/condense-many-line-response-results-to-a-small-table/m-p/337705#M100176</link>
      <description>&lt;P&gt;I asked the same question on &lt;A href="http://stackoverflow.com/questions/42634785/splunk-condense-results-to-small-table"&gt;StackOverflow&lt;/A&gt; if you want to double dip on the points &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Mar 2017 22:52:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/condense-many-line-response-results-to-a-small-table/m-p/337705#M100176</guid>
      <dc:creator>drinkingjimmy</dc:creator>
      <dc:date>2017-03-06T22:52:24Z</dc:date>
    </item>
    <item>
      <title>Re: condense many line response results to a small table</title>
      <link>https://community.splunk.com/t5/Splunk-Search/condense-many-line-response-results-to-a-small-table/m-p/337706#M100177</link>
      <description>&lt;P&gt;Too much, too late, but this works:&lt;/P&gt;

&lt;P&gt;Spoof data:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| makeresults 
| eval raw="[01:00:22.164297] x=ABC mod=mail cmd=msg rule=ruleQ subject=\"Test 123\" size=8583::[01:00:22.136496] x=ABC mod=spam cmd=run rule=notspam::[01:00:22.106325] x=ABC mod=spam cmd=run policy=outbound::[01:00:22.067675] x=ABC mod=mail cmd=attachment file=text.html size=3347::[01:00:22.039732] x=ABC mod=mail cmd=attachment file=text.txt size=2093::[01:00:22.010986] x=ABC mod=session cmd=data rcpt=personA@rec.org::[01:00:22.010986] x=ABC mod=session cmd=data rcpt=personB@rec.org::[01:00:22.000234] x=ABC mod=mail sender=noreply@sender.org" 
| makemv delim="::" raw 
| mvexpand raw 
| rename raw AS _raw 
| rex "\[(?&amp;lt;time&amp;gt;[^\]]+)\]\s+x=(?&amp;lt;x&amp;gt;\w+)\s+mod=(?&amp;lt;mod&amp;gt;\w+)\s+cmd=(?&amp;lt;cmd&amp;gt;\w+)\s+rule=(?&amp;lt;rule&amp;gt;\w+)(?:\s+subject=\"(?&amp;lt;subject&amp;gt;[^\"]+)\"\s+size=(?&amp;lt;size&amp;gt;\d+))?" 
| rex "\[(?&amp;lt;time&amp;gt;[^\]]+)\]\s+x=(?&amp;lt;x&amp;gt;\w+)\s+mod=(?&amp;lt;mod&amp;gt;\w+)\s+cmd=(?&amp;lt;cmd&amp;gt;\w+)\s+policy=(?&amp;lt;policy&amp;gt;\w+)" 
| rex "\[(?&amp;lt;time&amp;gt;[^\]]+)\]\s+x=(?&amp;lt;x&amp;gt;\w+)\s+mod=(?&amp;lt;mod&amp;gt;\w+)\s+cmd=(?&amp;lt;cmd&amp;gt;\w+)\s+file=(?&amp;lt;file&amp;gt;.*)\s+size=(?&amp;lt;size&amp;gt;\d+)" 
| rex "\[(?&amp;lt;time&amp;gt;[^\]]+)\]\s+x=(?&amp;lt;x&amp;gt;\w+)\s+mod=(?&amp;lt;mod&amp;gt;\w+)\s+cmd=(?&amp;lt;cmd&amp;gt;\w+)\s+rcpt=(?&amp;lt;rcpt&amp;gt;.*)" 
| rex "\[(?&amp;lt;time&amp;gt;[^\]]+)\]\s+x=(?&amp;lt;x&amp;gt;\w+)\s+mod=(?&amp;lt;mod&amp;gt;\w+)\s+sender=(?&amp;lt;sender&amp;gt;.*)" 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now the solution:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval spam_rule=if(mod="spam", rule, null()) 
| eventstats values(spam_rule) AS spam_rule by x 
| eval file_detail = time . ":-:" . file . ":-:" . size . ":-:" . spam_rule 
| fields - _raw _time time cmd mod policy file size rule spam_rule
| eventstats values(file_detail) AS file_detail BY x
| stats values(*) AS * BY file_detail rcpt x
| rex field=file_detail "^(?&amp;lt;time&amp;gt;.*):-:(?&amp;lt;file&amp;gt;.*):-:(?&amp;lt;size&amp;gt;.*):-:(?&amp;lt;rule&amp;gt;.*)$"
| table time x subject file sender rcpt size rule
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Note that my solution preserves the time that the spam rule was executed on the file (which was not in the original ask, I know).&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2017 15:25:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/condense-many-line-response-results-to-a-small-table/m-p/337706#M100177</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2017-03-07T15:25:57Z</dc:date>
    </item>
  </channel>
</rss>

