<?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 How can I filter a transaction that contains multiple matches - and force a numeric sort? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-can-I-filter-a-transaction-that-contains-multiple-matches/m-p/322247#M60051</link>
    <description>&lt;P&gt;I have used the 'transaction' command to isolate transactions that are made up of roughly 45 events each.  I have a regex that identifies a TaskName and the TotalMilliseconds for each event, producing 45 matches for each transaction.&lt;/P&gt;

&lt;P&gt;Questions:&lt;/P&gt;

&lt;P&gt;When I try to filter the transaction (TotalMilliseconds&amp;gt;500, for example), the criteria is applied only against the first match.  How can I ensure ALL matches are considered when filtering?&lt;/P&gt;

&lt;P&gt;How can in insert a 'tab' character when formatting a concatenated field value?  TotalMilliseconds."\t".TaskName and its derivatives do not work.&lt;/P&gt;

&lt;P&gt;How can I filter the results to show only matches where TotalMilliseconds&amp;lt;500 (for example)?  Any attempt I've made so far has only applied the filter to the FIRST match in my list of 45 values.&lt;/P&gt;

&lt;P&gt;Is there any way to force a numeric sort on a string field?  &lt;/P&gt;

&lt;P&gt;Thanks for looking!&lt;/P&gt;

&lt;P&gt;Appendix:&lt;/P&gt;

&lt;P&gt;Query:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;base search
|rex "rex to find ClientID"
|rex "long rex that finds TaskName and TotalMilliseconds"
|transaction field1 field2 maxspan=5m unifyends=true startswith="beginning" endswith="ending"
|search [[[or, 'where']]] TotalMilliseconds&amp;gt;500 &amp;lt;--neither meets my needs
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Results:&lt;/P&gt;

&lt;P&gt;ClientID           TimeAndTaskName&lt;BR /&gt;
abc123            1127 (UseCaseA)&lt;BR /&gt;
                         12 (UseCaseB)&lt;BR /&gt;
                         21 (UseCaseY)&lt;/P&gt;

&lt;P&gt;Goal (filtering TotalMilliseconds&amp;gt;20):&lt;/P&gt;

&lt;P&gt;ClientID          TimeAndTaskName&lt;BR /&gt;
abc123           21             UseCaseY&lt;BR /&gt;
                        1127        UseCaseA&lt;/P&gt;</description>
    <pubDate>Fri, 08 Sep 2017 17:48:05 GMT</pubDate>
    <dc:creator>jasongb</dc:creator>
    <dc:date>2017-09-08T17:48:05Z</dc:date>
    <item>
      <title>How can I filter a transaction that contains multiple matches - and force a numeric sort?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-can-I-filter-a-transaction-that-contains-multiple-matches/m-p/322247#M60051</link>
      <description>&lt;P&gt;I have used the 'transaction' command to isolate transactions that are made up of roughly 45 events each.  I have a regex that identifies a TaskName and the TotalMilliseconds for each event, producing 45 matches for each transaction.&lt;/P&gt;

&lt;P&gt;Questions:&lt;/P&gt;

&lt;P&gt;When I try to filter the transaction (TotalMilliseconds&amp;gt;500, for example), the criteria is applied only against the first match.  How can I ensure ALL matches are considered when filtering?&lt;/P&gt;

&lt;P&gt;How can in insert a 'tab' character when formatting a concatenated field value?  TotalMilliseconds."\t".TaskName and its derivatives do not work.&lt;/P&gt;

&lt;P&gt;How can I filter the results to show only matches where TotalMilliseconds&amp;lt;500 (for example)?  Any attempt I've made so far has only applied the filter to the FIRST match in my list of 45 values.&lt;/P&gt;

&lt;P&gt;Is there any way to force a numeric sort on a string field?  &lt;/P&gt;

&lt;P&gt;Thanks for looking!&lt;/P&gt;

&lt;P&gt;Appendix:&lt;/P&gt;

&lt;P&gt;Query:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;base search
|rex "rex to find ClientID"
|rex "long rex that finds TaskName and TotalMilliseconds"
|transaction field1 field2 maxspan=5m unifyends=true startswith="beginning" endswith="ending"
|search [[[or, 'where']]] TotalMilliseconds&amp;gt;500 &amp;lt;--neither meets my needs
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Results:&lt;/P&gt;

&lt;P&gt;ClientID           TimeAndTaskName&lt;BR /&gt;
abc123            1127 (UseCaseA)&lt;BR /&gt;
                         12 (UseCaseB)&lt;BR /&gt;
                         21 (UseCaseY)&lt;/P&gt;

&lt;P&gt;Goal (filtering TotalMilliseconds&amp;gt;20):&lt;/P&gt;

&lt;P&gt;ClientID          TimeAndTaskName&lt;BR /&gt;
abc123           21             UseCaseY&lt;BR /&gt;
                        1127        UseCaseA&lt;/P&gt;</description>
      <pubDate>Fri, 08 Sep 2017 17:48:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-can-I-filter-a-transaction-that-contains-multiple-matches/m-p/322247#M60051</guid>
      <dc:creator>jasongb</dc:creator>
      <dc:date>2017-09-08T17:48:05Z</dc:date>
    </item>
    <item>
      <title>Re: How can I filter a transaction that contains multiple matches - and force a numeric sort?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-can-I-filter-a-transaction-that-contains-multiple-matches/m-p/322248#M60052</link>
      <description>&lt;P&gt;I'm not quite sure what you need, but try like this.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | transaction ... | mvexpand TotalMilliseconds | where match(field1, field2) AND TotalMilliseconds &amp;gt; 500
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 08 Sep 2017 17:59:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-can-I-filter-a-transaction-that-contains-multiple-matches/m-p/322248#M60052</guid>
      <dc:creator>alemarzu</dc:creator>
      <dc:date>2017-09-08T17:59:24Z</dc:date>
    </item>
    <item>
      <title>Re: How can I filter a transaction that contains multiple matches - and force a numeric sort?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-can-I-filter-a-transaction-that-contains-multiple-matches/m-p/322249#M60053</link>
      <description>&lt;P&gt;That depends on what you are trying to achieve.  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| streamstats count as recno
| appendpipe 
     [ 
    | mvexpand TotalMilliseconds
    | stats sum(TotalMilliseconds) as GrandTotalMilliseconds max(TotalMilliseconds) as maxTotalMilliseconds by recno
    | eval deleteme="deleteme"
    ]
| eventstats 
       max(GrandTotalMilliseconds) as GrandTotalMilliseconds 
       max(maxTotalMilliseconds) as maxTotalMilliseconds by recno
 | where isnull(deleteme)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;After those lines run, on each transaction you will have the grand total of all TotalMilliseconds values, and also the largest of all TotalMilliseconds values for that record.  Test those against your requirements and go from there. &lt;/P&gt;

&lt;HR /&gt;

&lt;P&gt;tab value - if you have splunk 6.6, then try printf.  &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eval myfield="firstthing".printf("%c",9)."secondthing"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I can't swear whether having a tab there will do anything useful anyway, because my experience with splunk says the output is pretty basic.&lt;/P&gt;</description>
      <pubDate>Fri, 08 Sep 2017 19:47:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-can-I-filter-a-transaction-that-contains-multiple-matches/m-p/322249#M60053</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-09-08T19:47:36Z</dc:date>
    </item>
    <item>
      <title>Re: How can I filter a transaction that contains multiple matches - and force a numeric sort?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-can-I-filter-a-transaction-that-contains-multiple-matches/m-p/322250#M60054</link>
      <description>&lt;P&gt;Thanks to you both for your patient help; I see now how bad my original post's formatting is.  This makes my question difficult to understand.&lt;/P&gt;

&lt;P&gt;I've done some work and discovered a couple of things:  first, it's difficult to sort numerically and not lexicographical(?) in Splunk.  I've tried several means of doing so, with no success at all.  I'm a little shocked that it has to be that difficult, honestly...  Second, it's difficult to filter multi-value fields like mine.&lt;/P&gt;

&lt;P&gt;I had hoped to filter the results of the multi-value field descending - I've abandoned that.  I did discover that (thanks only to the format of the numbers) I can filter the TotalMilliseconds using a regex that matches only numbers with 4 digits or more.  It's 'good enough'.&lt;/P&gt;

&lt;P&gt;I'm very interested in making DalJeanis' solution work!  I can understand almost all of it, save the 'deleteme' functionality.... but it currently only produces a blank column in my results.  And I'm on the cloud, which means 6.5.12, and no 'tab' functionality.&lt;/P&gt;</description>
      <pubDate>Tue, 12 Sep 2017 03:45:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-can-I-filter-a-transaction-that-contains-multiple-matches/m-p/322250#M60054</guid>
      <dc:creator>jasongb</dc:creator>
      <dc:date>2017-09-12T03:45:40Z</dc:date>
    </item>
  </channel>
</rss>

