<?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: loop search? in Security</title>
    <link>https://community.splunk.com/t5/Security/loop-search/m-p/83278#M2750</link>
    <description>&lt;P&gt;Does &lt;CODE&gt;a=1 OR a=2 OR a=3 OR a=4&lt;/CODE&gt; not return the results you need?&lt;/P&gt;</description>
    <pubDate>Mon, 08 Oct 2012 15:18:35 GMT</pubDate>
    <dc:creator>dart</dc:creator>
    <dc:date>2012-10-08T15:18:35Z</dc:date>
    <item>
      <title>loop search?</title>
      <link>https://community.splunk.com/t5/Security/loop-search/m-p/83276#M2748</link>
      <description>&lt;P&gt;A field: a=1,2,3,4..... disordered&lt;BR /&gt;
i need a search like:&lt;BR /&gt;
a=1&lt;BR /&gt;
| append [search a=2]&lt;BR /&gt;
| append [search a=3]&lt;BR /&gt;
| append [search a=4]&lt;BR /&gt;
....&lt;BR /&gt;
where i can not simpley use "sort" ...&lt;BR /&gt;
is there any syntax like "if a&amp;lt;n a++ and search something...." in splunk?&lt;BR /&gt;
by the way, is there better way than " ...| head 88 | tail 1" when i want the 88th event?&lt;BR /&gt;
thank you&lt;/P&gt;

&lt;P&gt;[EDIT]&lt;BR /&gt;
OK! this is what i am after:&lt;BR /&gt;
Puting events in the right order, for example a business procedur&lt;BR /&gt;
acc=crazyeva (1a)&lt;BR /&gt;
id=0001 (1b)&lt;BR /&gt;
tim=20121009 (1c)&lt;BR /&gt;
act=toopooltopurch (1d)&lt;/P&gt;

&lt;P&gt;but "_raw" data is disordered by "_time":&lt;BR /&gt;
# _raw&lt;BR /&gt;
16 11:48 acc=1a&lt;BR /&gt;
15 11:49 id=1b&lt;BR /&gt;
14 11:50 acc=2a&lt;BR /&gt;
13 11:51 tim=1c&lt;BR /&gt;
12 11:52 acc=3a&lt;BR /&gt;
11 11:53 act=1d&lt;BR /&gt;
10 11:54 id=2b&lt;BR /&gt;
9 11:55 id=3b&lt;BR /&gt;
8 11:56 tim=2c&lt;BR /&gt;
7 11:57 acc=4a&lt;BR /&gt;
6 11:58 tim=3c&lt;BR /&gt;
5 11:59 act=2d&lt;BR /&gt;
4 11:60 id=4b&lt;BR /&gt;
3 11:61 act=3d&lt;BR /&gt;
2 11:62 tim=4c&lt;BR /&gt;
1 11:63 act=4d&lt;BR /&gt;
....&lt;BR /&gt;
The only rule is in the time line: &lt;BR /&gt;
1b never comes before 1a, the same manner, 1a &amp;gt;&amp;gt; 1b &amp;gt;&amp;gt; 1c &amp;gt;&amp;gt;1d, 2a &amp;gt;&amp;gt; 2b....; &lt;BR /&gt;
2a never comes before 1a, the same manner, 1a &amp;gt;&amp;gt; 2a &amp;gt;&amp;gt; 3a &amp;gt;&amp;gt;4a, 1b &amp;gt;&amp;gt; 2b....&lt;/P&gt;

&lt;P&gt;this is my solution:&lt;BR /&gt;
 acc | sort _time | head 1 | tail 1 &lt;BR /&gt;
| append [search  id | sort _time | head 1 | tail 1]&lt;BR /&gt;
| append [search  tim | sort _time | head 1 | tail 1]&lt;BR /&gt;
| append [search  act | sort _time | head 1 | tail 1]&lt;BR /&gt;
| append [search  acc | sort _time | head 2 | tail 1]&lt;BR /&gt;
| append [search  id | sort _time | head 2 | tail 1]&lt;BR /&gt;
| append [search  tim | sort _time | head 2 | tail 1]&lt;BR /&gt;
| append [search  act | sort _time | head 2 | tail 1]&lt;BR /&gt;
| append [search  acc | sort _time | head 3 | tail 1]&lt;BR /&gt;
| append [search  id | sort _time | head 3 | tail 1]&lt;BR /&gt;
| append [search  tim | sort _time | head 3 | tail 1]&lt;BR /&gt;
| append [search  act | sort _time | head 3 | tail 1]&lt;BR /&gt;
| append [search  acc | sort _time | head 4 | tail 1]&lt;BR /&gt;
| append [search  id | sort _time | head 4 | tail 1]&lt;BR /&gt;
| append [search  tim | sort _time | head 4 | tail 1]&lt;BR /&gt;
| append [search  act | sort _time | head 4 | tail 1]&lt;BR /&gt;
.........&lt;BR /&gt;
| streamstats count | eval _time=count | sort _time&lt;BR /&gt;
| transaction maxspan=4s&lt;BR /&gt;
two problem:&lt;BR /&gt;
1.I need to do a "loop search" if there are too many events&lt;BR /&gt;
2."transaction" command does not work on written "_time"&lt;/P&gt;

&lt;P&gt;a second way:&lt;BR /&gt;
* | sort _time | stats list(acc)&lt;BR /&gt;
| appendcols [search * | sort _time | stats list(id) ] &lt;BR /&gt;
| appendcols [search * | sort _time | stats list(tim) ] &lt;BR /&gt;
| appendcols [search * | sort _time | stats list(act) ] &lt;BR /&gt;
| table list(acc) list(id) list(tim) list(act)&lt;BR /&gt;
the result seems like a table, but its not a useful table at all&lt;BR /&gt;
Could you help me to put them in order?&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 12:35:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/loop-search/m-p/83276#M2748</guid>
      <dc:creator>crazyeva</dc:creator>
      <dc:date>2020-09-28T12:35:07Z</dc:date>
    </item>
    <item>
      <title>Re: loop search?</title>
      <link>https://community.splunk.com/t5/Security/loop-search/m-p/83277#M2749</link>
      <description>&lt;P&gt;I think you need to state your problem a bit more clearly. I tried to understand what you're after but failed. What do you want to sort, why, how?&lt;/P&gt;</description>
      <pubDate>Mon, 08 Oct 2012 10:28:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/loop-search/m-p/83277#M2749</guid>
      <dc:creator>Ayn</dc:creator>
      <dc:date>2012-10-08T10:28:45Z</dc:date>
    </item>
    <item>
      <title>Re: loop search?</title>
      <link>https://community.splunk.com/t5/Security/loop-search/m-p/83278#M2750</link>
      <description>&lt;P&gt;Does &lt;CODE&gt;a=1 OR a=2 OR a=3 OR a=4&lt;/CODE&gt; not return the results you need?&lt;/P&gt;</description>
      <pubDate>Mon, 08 Oct 2012 15:18:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/loop-search/m-p/83278#M2750</guid>
      <dc:creator>dart</dc:creator>
      <dc:date>2012-10-08T15:18:35Z</dc:date>
    </item>
    <item>
      <title>Re: loop search?</title>
      <link>https://community.splunk.com/t5/Security/loop-search/m-p/83279#M2751</link>
      <description>&lt;P&gt;I have posted my real stanza, It is a "flow" data&lt;/P&gt;</description>
      <pubDate>Tue, 09 Oct 2012 02:49:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/loop-search/m-p/83279#M2751</guid>
      <dc:creator>crazyeva</dc:creator>
      <dc:date>2012-10-09T02:49:44Z</dc:date>
    </item>
    <item>
      <title>Re: loop search?</title>
      <link>https://community.splunk.com/t5/Security/loop-search/m-p/83280#M2752</link>
      <description>&lt;P&gt;Thank you, but my demands is not that simple&lt;/P&gt;</description>
      <pubDate>Tue, 09 Oct 2012 03:01:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/loop-search/m-p/83280#M2752</guid>
      <dc:creator>crazyeva</dc:creator>
      <dc:date>2012-10-09T03:01:00Z</dc:date>
    </item>
    <item>
      <title>Re: loop search?</title>
      <link>https://community.splunk.com/t5/Security/loop-search/m-p/83281#M2753</link>
      <description>&lt;P&gt;I also am baffled as to what you're trying to do.  I suspect that some combination of sort/rex/eval/stats can absolutely sort it the way that you need.  Can you back up and describe the desired sort order more clearly?&lt;/P&gt;</description>
      <pubDate>Tue, 09 Oct 2012 04:24:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/loop-search/m-p/83281#M2753</guid>
      <dc:creator>sideview</dc:creator>
      <dc:date>2012-10-09T04:24:29Z</dc:date>
    </item>
    <item>
      <title>Re: loop search?</title>
      <link>https://community.splunk.com/t5/Security/loop-search/m-p/83282#M2754</link>
      <description>&lt;P&gt;My suggestion is different - create two fields, one for each part of the "id" (1a, 2b, etc) and then sort them like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;yoursearchere
| rex "=(?&amp;lt;sortField1&amp;gt;\d+)(?&amp;lt;sortField2&amp;gt;\S+)"
| sort sortField1 sortField2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and perhaps even&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;yoursearchere
| rex "=(?&amp;lt;sortField1&amp;gt;\d+)(?&amp;lt;sortField2&amp;gt;\S+)"
| sort sortField1 sortField2
| transaction sortField1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But if none of our answers are getting close, I suggest that you post a sample the actual raw data, and just change some names. If you are changing the format of the events in your examples, then the answers given are probably not going to be very useful.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Oct 2012 05:12:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/loop-search/m-p/83282#M2754</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2012-10-09T05:12:14Z</dc:date>
    </item>
    <item>
      <title>Re: loop search?</title>
      <link>https://community.splunk.com/t5/Security/loop-search/m-p/83283#M2755</link>
      <description>&lt;P&gt;Sorry I am not good at describing&lt;BR /&gt;
There is same of the raw data:&lt;/P&gt;

&lt;P&gt;11:48 acc=1a&lt;BR /&gt;
11:49 id=1b&lt;BR /&gt;
11:50 acc=2a&lt;BR /&gt;
11:51 tim=1c&lt;BR /&gt;
11:52 acc=3a&lt;BR /&gt;
11:53 act=1d&lt;BR /&gt;
11:54 id=2b&lt;BR /&gt;
11:55 id=3b&lt;BR /&gt;
11:56 tim=2c&lt;BR /&gt;
11:57 acc=4a&lt;BR /&gt;
11:58 tim=3c&lt;BR /&gt;
11:59 act=2d&lt;BR /&gt;
12:00 id=4b&lt;BR /&gt;
12:01 act=3d&lt;BR /&gt;
12:02 tim=4c&lt;BR /&gt;
12:03 act=4d&lt;BR /&gt;
.....&lt;/P&gt;

&lt;P&gt;I want results like:&lt;BR /&gt;
11:48 acc=1a&lt;BR /&gt;
11:49 id=1b&lt;BR /&gt;
11:51 tim=1c&lt;/P&gt;

&lt;H2&gt;11:53 act=1d&lt;/H2&gt;

&lt;P&gt;11:50 acc=2a&lt;BR /&gt;
11:54 id=2b&lt;BR /&gt;
11:56 tim=2c&lt;/P&gt;

&lt;H2&gt;11:59 act=2d&lt;/H2&gt;

&lt;P&gt;11:52 acc=3a&lt;BR /&gt;
11:55 id=3b&lt;BR /&gt;
11:58 tim=3c&lt;/P&gt;

&lt;H2&gt;12:01 act=3d&lt;/H2&gt;

&lt;P&gt;11:57 acc=4a&lt;BR /&gt;
12:00 id=4b&lt;BR /&gt;
12:02 tim=4c&lt;/P&gt;

&lt;H2&gt;10:03 act=4d&lt;/H2&gt;

&lt;P&gt;......&lt;/P&gt;

&lt;P&gt;OR:&lt;BR /&gt;
acc id  tim act&lt;BR /&gt;
1a  1b  1c  1d&lt;BR /&gt;
2a  2b  2c  2d&lt;BR /&gt;
3a  3b  3c  3d&lt;BR /&gt;
4a  4b  4c  4d&lt;BR /&gt;
......&lt;/P&gt;</description>
      <pubDate>Tue, 09 Oct 2012 11:07:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/loop-search/m-p/83283#M2755</guid>
      <dc:creator>crazyeva</dc:creator>
      <dc:date>2012-10-09T11:07:16Z</dc:date>
    </item>
    <item>
      <title>Re: loop search?</title>
      <link>https://community.splunk.com/t5/Security/loop-search/m-p/83284#M2756</link>
      <description>&lt;P&gt;1a, 2b, such fields after "=" may be any content&lt;BR /&gt;
do not try sort them by 1,2,3,4 or a,b,c,d...&lt;/P&gt;

&lt;P&gt;11:48 acc=nice&lt;BR /&gt;
11:49 id=to&lt;BR /&gt;
11:50 acc=i&lt;BR /&gt;
11:51 tim=meet&lt;BR /&gt;
11:52 acc=thank&lt;BR /&gt;
11:53 act=you&lt;BR /&gt;
11:54 id=tried&lt;BR /&gt;
11:55 id=you&lt;BR /&gt;
11:56 tim=my&lt;BR /&gt;
11:57 acc=what&lt;BR /&gt;
11:58 tim=very&lt;BR /&gt;
11:59 act=best&lt;BR /&gt;
12:00 id=a&lt;BR /&gt;
12:01 act=much&lt;BR /&gt;
12:02 tim=nice&lt;BR /&gt;
12:03 act=day&lt;BR /&gt;
\&lt;/P&gt;

&lt;H2&gt;acc id  tim act&lt;/H2&gt;

&lt;P&gt;nice    to  meet    you&lt;BR /&gt;
i   tried   my  best&lt;BR /&gt;
thank   you very    much&lt;BR /&gt;
what    a   nice    day&lt;/P&gt;

&lt;P&gt;Thank you~&lt;/P&gt;</description>
      <pubDate>Tue, 09 Oct 2012 11:13:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/loop-search/m-p/83284#M2756</guid>
      <dc:creator>crazyeva</dc:creator>
      <dc:date>2012-10-09T11:13:40Z</dc:date>
    </item>
    <item>
      <title>Re: loop search?</title>
      <link>https://community.splunk.com/t5/Security/loop-search/m-p/83285#M2757</link>
      <description>&lt;P&gt;Sorry to make you baffled&lt;BR /&gt;
I have posted below some raw data, and the results i expected&lt;/P&gt;</description>
      <pubDate>Tue, 09 Oct 2012 11:16:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/loop-search/m-p/83285#M2757</guid>
      <dc:creator>crazyeva</dc:creator>
      <dc:date>2012-10-09T11:16:51Z</dc:date>
    </item>
    <item>
      <title>Re: loop search?</title>
      <link>https://community.splunk.com/t5/Security/loop-search/m-p/83286#M2758</link>
      <description>&lt;P&gt;You need to show what the raw data look like in splunk, not how it was logged.&lt;/P&gt;

&lt;P&gt;Its a simple matter of extracting the fields, sorting on the 1a/1b/2a/2b field and including the time.&lt;/P&gt;

&lt;P&gt;i.e. if your raw data looks like :&lt;/P&gt;

&lt;P&gt;10 Oct 2012 host=wibble;tim=1a&lt;/P&gt;

&lt;P&gt;You set up an extract like this :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;search&amp;gt; 
| rex ";(?&amp;lt;type&amp;gt;.*?)=(?&amp;lt;number&amp;gt;[0-9]+)(?&amp;lt;letter&amp;gt;[a-z]+)"
| sort number letter
| eval precedence=number.letter
| table _time type precedence
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 09 Oct 2012 16:07:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/loop-search/m-p/83286#M2758</guid>
      <dc:creator>jonuwz</dc:creator>
      <dc:date>2012-10-09T16:07:32Z</dc:date>
    </item>
    <item>
      <title>Re: loop search?</title>
      <link>https://community.splunk.com/t5/Security/loop-search/m-p/83287#M2759</link>
      <description>&lt;P&gt;This may work, but I am not sure that it will work in all cases. Try it with a few different time ranges...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;yoursearchhere&amp;gt; 
| rex "\s(?&amp;lt;fieldname&amp;gt;\S+?)="
| streamstats count as IdNum by fieldname
| transaction IdNum startswith=eval(fieldname="acc") endswith=eval(fieldname="act") keepevicted=true
| sort _time
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You might want to remove &lt;CODE&gt;keepevicted=true&lt;/CODE&gt; if you don't want partial transactions. And this may not work if you have a large number of transactions. But try it.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Oct 2012 22:36:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/loop-search/m-p/83287#M2759</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2012-10-09T22:36:43Z</dc:date>
    </item>
    <item>
      <title>Re: loop search?</title>
      <link>https://community.splunk.com/t5/Security/loop-search/m-p/83288#M2760</link>
      <description>&lt;P&gt;Thank you&lt;BR /&gt;
I think this is much better an answer&lt;/P&gt;</description>
      <pubDate>Wed, 10 Oct 2012 14:09:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/loop-search/m-p/83288#M2760</guid>
      <dc:creator>crazyeva</dc:creator>
      <dc:date>2012-10-10T14:09:47Z</dc:date>
    </item>
    <item>
      <title>Re: loop search?</title>
      <link>https://community.splunk.com/t5/Security/loop-search/m-p/83289#M2761</link>
      <description>&lt;P&gt;Thank you&lt;BR /&gt;
but i mean there is not any fixed form in the right part of "=".  1a,2b...are just examples. they could be any content.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Oct 2012 14:14:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Security/loop-search/m-p/83289#M2761</guid>
      <dc:creator>crazyeva</dc:creator>
      <dc:date>2012-10-10T14:14:21Z</dc:date>
    </item>
  </channel>
</rss>

