<?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: Complex Query question in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Complex-Query-question/m-p/84372#M21508</link>
    <description>&lt;P&gt;Care to annotate your search Alex?&lt;/P&gt;</description>
    <pubDate>Sat, 06 Nov 2010 19:31:16 GMT</pubDate>
    <dc:creator>Marinus</dc:creator>
    <dc:date>2010-11-06T19:31:16Z</dc:date>
    <item>
      <title>Complex Query question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Complex-Query-question/m-p/84370#M21506</link>
      <description>&lt;P&gt;I am sending my sonic wall data to splunk via syslog.  I am trying to get a report to show me how many open connections by src ip.  However I am not sure how to do this.&lt;/P&gt;

&lt;P&gt;The 2 event type I need to tie together are &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Nov 4 17:42:38 192.168.150.1 id=firewall sn=xxxxxxxxx time="2010-11-04 17:42:42" fw=192.168.254.5 pri=6 c=1024 m=537 msg="Connection Closed" n=0 src=192.168.150.93:1637:X0 dst=192.168.100.10:4440:X2 proto=tcp/4440 sent=2505 rcvd=677
host=192.168.150.1

Nov 4 17:41:53 192.168.150.1 id=firewall sn=xxxxxxxxx time="2010-11-04 17:41:56" fw=192.168.254.5 pri=6 c=262144 m=98 msg="Connection Opened" n=0 src=192.168.150.93:1637:X0 dst=192.168.100.10:4440:X2 proto=tcp/4440
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So in short I want to know how here &lt;CODE&gt;src=192.168.150.93:1637:X0&lt;/CODE&gt;  has open a connection.  Then it closed the connection.  I want to find out how many have been opened and have yet to be closed.  So current open connection count and sort it by just the src ip so strip of the 1637:XO when grouping.&lt;/P&gt;

&lt;P&gt;Any help would be great&lt;/P&gt;</description>
      <pubDate>Fri, 05 Nov 2010 04:54:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Complex-Query-question/m-p/84370#M21506</guid>
      <dc:creator>rcolby</dc:creator>
      <dc:date>2010-11-05T04:54:12Z</dc:date>
    </item>
    <item>
      <title>Re: Complex Query question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Complex-Query-question/m-p/84371#M21507</link>
      <description>&lt;PRE&gt;&lt;CODE&gt;sourcetype=sonicwall msg="Connection Opened" OR msg="Connection Closed" 
| stats dc(msg) as dc values(msg) as msg by src dst 
| mvexpand msg  
| search dc=1 AND msg="Connection Opened"
| fields src dst
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;EDIT: Carasso wasn't happy with my search because it might miss instances where multiple connections were made.  This search is better:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=sonicwall msg="Connection Opened" OR msg="Connection Closed" 
| stats count(eval(msg="Connection Opened")) as open_count 
  count(eval(msg="Connection Closed")) as closed_count 
  first(msg) as last_msg
  values(msg) as msg by src dst 
| search last_msg="Connection Opened"
| where open_count &amp;gt; closed_count
| fields src dst
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 05 Nov 2010 05:17:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Complex-Query-question/m-p/84371#M21507</guid>
      <dc:creator>araitz</dc:creator>
      <dc:date>2010-11-05T05:17:00Z</dc:date>
    </item>
    <item>
      <title>Re: Complex Query question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Complex-Query-question/m-p/84372#M21508</link>
      <description>&lt;P&gt;Care to annotate your search Alex?&lt;/P&gt;</description>
      <pubDate>Sat, 06 Nov 2010 19:31:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Complex-Query-question/m-p/84372#M21508</guid>
      <dc:creator>Marinus</dc:creator>
      <dc:date>2010-11-06T19:31:16Z</dc:date>
    </item>
    <item>
      <title>Re: Complex Query question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Complex-Query-question/m-p/84373#M21509</link>
      <description>&lt;P&gt;It seems only right to the following blog page, since this question inspired it:&lt;/P&gt;

&lt;P&gt;&lt;A href="http://blogs.splunk.com/2011/01/11/maintaining-state-of-the-union/comment-page-1" rel="nofollow"&gt;http://blogs.splunk.com/2011/01/11/maintaining-state-of-the-union/comment-page-1&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jan 2011 05:37:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Complex-Query-question/m-p/84373#M21509</guid>
      <dc:creator>Lowell</dc:creator>
      <dc:date>2011-01-14T05:37:28Z</dc:date>
    </item>
    <item>
      <title>Re: Complex Query question</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Complex-Query-question/m-p/84374#M21510</link>
      <description>&lt;P&gt;For this type of search dedup is your friend. If you search for all  msg="Connection Opened" OR msg="Connection Closed" events, the most recent for any connection is it's current status. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=sonicwall msg="Connection Opened" OR msg="Connection Closed"
| dedup src_ip dest_ip proto
| where msg="Connection Opened"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;if you regularly run this search, or it takes a long time, it would be worth summary indexing it with&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=sonicwall msg="Connection Opened" OR msg="Connection Closed"
| dedup src_ip dest_ip proto
| sistats count by src_ip dest_ip proto msg
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and to report, use&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=summary search_name=YourSearchName 
|  dedup src_ip dest_ip proto
| where msg="Connection Opened"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;or you could use the blogged method.&lt;/P&gt;</description>
      <pubDate>Fri, 22 Jul 2011 10:50:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Complex-Query-question/m-p/84374#M21510</guid>
      <dc:creator>BobM</dc:creator>
      <dc:date>2011-07-22T10:50:23Z</dc:date>
    </item>
  </channel>
</rss>

