<?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 Can you search for two strings in chronological order (in different log statements)? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Can-you-search-for-two-strings-in-chronological-order-in/m-p/369145#M108773</link>
    <description>&lt;P&gt;In every log statement, we write the user's session ID delimited by hyphens as follows: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; -S:ybiSmNiQxF-
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I want to get a count of session IDs that contain two specific message strings (in separate log statements) in a specific order. I don't care if there are intervening log statements.&lt;/P&gt;

&lt;P&gt;Example: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;2017-08-11 12:51:57,918 INFO - whatever-S:ybiBmNiQxF-whatever STATEMENT1 whatever 
2017-08-11 12:51:57,921 INFO - whatever-S:ybiBmNiQxF-whatever STATEMENT2 whatever 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Is there a way to do this in a Splunk query?&lt;/P&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
Jonathan&lt;/P&gt;</description>
    <pubDate>Mon, 14 Aug 2017 20:14:04 GMT</pubDate>
    <dc:creator>jbrenner</dc:creator>
    <dc:date>2017-08-14T20:14:04Z</dc:date>
    <item>
      <title>Can you search for two strings in chronological order (in different log statements)?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-search-for-two-strings-in-chronological-order-in/m-p/369145#M108773</link>
      <description>&lt;P&gt;In every log statement, we write the user's session ID delimited by hyphens as follows: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; -S:ybiSmNiQxF-
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I want to get a count of session IDs that contain two specific message strings (in separate log statements) in a specific order. I don't care if there are intervening log statements.&lt;/P&gt;

&lt;P&gt;Example: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;2017-08-11 12:51:57,918 INFO - whatever-S:ybiBmNiQxF-whatever STATEMENT1 whatever 
2017-08-11 12:51:57,921 INFO - whatever-S:ybiBmNiQxF-whatever STATEMENT2 whatever 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Is there a way to do this in a Splunk query?&lt;/P&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
Jonathan&lt;/P&gt;</description>
      <pubDate>Mon, 14 Aug 2017 20:14:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-search-for-two-strings-in-chronological-order-in/m-p/369145#M108773</guid>
      <dc:creator>jbrenner</dc:creator>
      <dc:date>2017-08-14T20:14:04Z</dc:date>
    </item>
    <item>
      <title>Re: Can you search for two strings in chronological order (in different log statements)?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-search-for-two-strings-in-chronological-order-in/m-p/369146#M108774</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Is the sessionID already extracted into a field?&lt;/STRONG&gt; If so, then you can use the &lt;CODE&gt;transaction&lt;/CODE&gt; command to combine the sets of transactions (same sessionID) together and perform functions on those, whether it be counts, check for completed transactions, etc.&lt;/P&gt;

&lt;P&gt;If it is not already extracted, then you will have to do a field extraction (either automatic or inline) to use the &lt;CODE&gt;transaction&lt;/CODE&gt; command. For that you &lt;STRONG&gt;may&lt;/STRONG&gt; have to provide more complete example data in order to allow us to help with the field extraction. &lt;/P&gt;</description>
      <pubDate>Mon, 14 Aug 2017 20:28:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-search-for-two-strings-in-chronological-order-in/m-p/369146#M108774</guid>
      <dc:creator>cpetterborg</dc:creator>
      <dc:date>2017-08-14T20:28:56Z</dc:date>
    </item>
    <item>
      <title>Re: Can you search for two strings in chronological order (in different log statements)?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-search-for-two-strings-in-chronological-order-in/m-p/369147#M108775</link>
      <description>&lt;P&gt;Give this a try (assuming no field extraction was done, if it has, remove the rex commands)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your base search for selecting only STATEMENT1 and STATEMENT2 type of events
| rex "S:(?&amp;lt;sessionID&amp;gt;[^\-]+)\S+\s+(?&amp;lt;Statement&amp;gt;\S+)"
| stats list(Statement) as Statements by sessionID 
| where mvindex(Statements,0)="STATEMENT1" AND mvindex(Statements,1)="STATEMENT2" | stats count
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 14 Aug 2017 20:52:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-search-for-two-strings-in-chronological-order-in/m-p/369147#M108775</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2017-08-14T20:52:12Z</dc:date>
    </item>
    <item>
      <title>Re: Can you search for two strings in chronological order (in different log statements)?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Can-you-search-for-two-strings-in-chronological-order-in/m-p/369148#M108776</link>
      <description>&lt;P&gt;Thanks for pointing me in the right direction. SInce there did not turn out to be any intervening events, I was able to use maxevents=2 with the TRANSACTION command:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=my_index
            | rex field=_raw "-S:(?&amp;lt;SESSION_ID&amp;gt;\w+)-" | transaction SESSION_ID startswith="STATEMENT1" endswith="STATEMENT2" maxevents=2
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 23 Aug 2017 15:02:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Can-you-search-for-two-strings-in-chronological-order-in/m-p/369148#M108776</guid>
      <dc:creator>jbrenner</dc:creator>
      <dc:date>2017-08-23T15:02:32Z</dc:date>
    </item>
  </channel>
</rss>

