<?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: How do I do a cidr match/not match in a tstats search? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-do-a-cidr-match-not-match-in-a-tstats-search/m-p/278096#M83933</link>
    <description>&lt;P&gt;You shouldn't this is the only correct answer at the moment. Tstats is not CIDR aware for WHERE clauses.&lt;/P&gt;</description>
    <pubDate>Wed, 21 Dec 2016 15:46:13 GMT</pubDate>
    <dc:creator>dshpritz</dc:creator>
    <dc:date>2016-12-21T15:46:13Z</dc:date>
    <item>
      <title>How do I do a cidr match/not match in a tstats search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-do-a-cidr-match-not-match-in-a-tstats-search/m-p/278093#M83930</link>
      <description>&lt;P&gt;I am trying to get a list of the most common sources and destinations of blocked traffic from the previous day with some exclusions (like not sourced fromauthorized vulnerability scanners).  So far I have come up with &lt;/P&gt;

&lt;P&gt;Sources:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;|tstats summariesonly=t count FROM datamodel=Network_Traffic &lt;BR /&gt;
WHERE All_Traffic.action!="allowed" All_Traffic.src_ip!=64.39.96.0/20 earliest=-1d@d latest=@d &lt;BR /&gt;
BY All_Traffic.src_ip &lt;BR /&gt;
| sort limit=10 -count&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;But when I do the above, I get results that include an IP address that is in 64.39.96.0/20&lt;/P&gt;

&lt;P&gt;I have learned that I can search my results to get rid of the extra source:&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;|tstats summariesonly=t count FROM datamodel=Network_Traffic &lt;BR /&gt;
WHERE All_Traffic.action!="allowed" All_Traffic.src_ip!=64.39.96.0/20  earliest=-1d@d latest=@d &lt;BR /&gt;
BY All_Traffic.src_ip &lt;BR /&gt;
| search All_Traffic.src_ip!=64.39.96.0/20 &lt;BR /&gt;
| sort limit=10 -count&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;but this feels inefficient (query something that I don't need and remove it later).&lt;BR /&gt;&lt;BR /&gt;
Also, it does not address my next use case: top destination IPs where the source does not include 64.39.96.0/20&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;|tstats summariesonly=t count FROM datamodel=Network_Traffic.All_Traffic&lt;BR /&gt;
WHERE All_Traffic.action!="allowed"  All_Traffic.src_ip!=64.39.96.0/20 earliest=-1d@d latest=@d &lt;BR /&gt;
BY All_Traffic.dest_ip &lt;BR /&gt;
|  sort limit=10 -count&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;is there a way to exclude 64.39.96.0/20 directly in the where clause?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 11:34:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-do-a-cidr-match-not-match-in-a-tstats-search/m-p/278093#M83930</guid>
      <dc:creator>MonkeyK</dc:creator>
      <dc:date>2020-09-29T11:34:55Z</dc:date>
    </item>
    <item>
      <title>Re: How do I do a cidr match/not match in a tstats search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-do-a-cidr-match-not-match-in-a-tstats-search/m-p/278094#M83931</link>
      <description>&lt;P&gt;I think that I have a way to do the filtering. &lt;BR /&gt;
By counting on both source and destination, I can then search my results to remove the cidr range, and follow up with a sum on the destinations before sorting them for my top 10&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;|tstats summariesonly=t count FROM datamodel=Network_Traffic.All_Traffic &lt;BR /&gt;
WHERE All_Traffic.action!="allowed"  earliest=-1d@d latest=@d&lt;BR /&gt;&lt;BR /&gt;
BY All_Traffic.src_ip All_Traffic.dest_ip &lt;BR /&gt;
| search All_Traffic.src_ip!=64.39.96.0/20 &lt;BR /&gt;
| chart sum(count) as Count over All_Traffic.dest_ip&lt;BR /&gt;
| sort limit=10 -Count&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;Still seems inefficient (although faster than without tstats). Maybe Splunk could do something about that.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 11:39:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-do-a-cidr-match-not-match-in-a-tstats-search/m-p/278094#M83931</guid>
      <dc:creator>MonkeyK</dc:creator>
      <dc:date>2020-09-29T11:39:25Z</dc:date>
    </item>
    <item>
      <title>Re: How do I do a cidr match/not match in a tstats search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-do-a-cidr-match-not-match-in-a-tstats-search/m-p/278095#M83932</link>
      <description>&lt;P&gt;I feel a little cheesy accepting my own answer, but I don't think that something better is coming along.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Nov 2016 18:19:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-do-a-cidr-match-not-match-in-a-tstats-search/m-p/278095#M83932</guid>
      <dc:creator>MonkeyK</dc:creator>
      <dc:date>2016-11-07T18:19:46Z</dc:date>
    </item>
    <item>
      <title>Re: How do I do a cidr match/not match in a tstats search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-do-a-cidr-match-not-match-in-a-tstats-search/m-p/278096#M83933</link>
      <description>&lt;P&gt;You shouldn't this is the only correct answer at the moment. Tstats is not CIDR aware for WHERE clauses.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Dec 2016 15:46:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-do-a-cidr-match-not-match-in-a-tstats-search/m-p/278096#M83933</guid>
      <dc:creator>dshpritz</dc:creator>
      <dc:date>2016-12-21T15:46:13Z</dc:date>
    </item>
    <item>
      <title>Re: How do I do a cidr match/not match in a tstats search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-do-a-cidr-match-not-match-in-a-tstats-search/m-p/278097#M83934</link>
      <description>&lt;P&gt;I just ran into your answer since I had the same issue, to slightly improve performance (I think - didn't measure) I did a pre-filter on the &lt;CODE&gt;tstat&lt;/CODE&gt; using wildcards so I give less results to &lt;CODE&gt;search&lt;/CODE&gt;, then narrow the results with &lt;CODE&gt;search&lt;/CODE&gt; (in my case I needed to filter all private IPs) as you suggested&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| tstats summariesonly=T 
    count 
    from datamodel=Network_Traffic.All_Traffic 
    where 
        (
            All_Traffic.dest=10.*
            OR All_Traffic.dest=192.168.*
            OR All_Traffic.dest=172.* 
        ) 
        AND All_Traffic.action="allowed" 
        AND 
        (
            All_Traffic.transport="tcp"
            OR All_Traffic.transport="udp"
        ) 
    by All_Traffic.dest
| search All_Traffic.dest=10.0.0.0/8
    OR All_Traffic.dest=192.168.0.0/16
    OR All_Traffic.dest=172.16.0.0/12
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;In my case the wildcards we almost enough since it works well for /16 and /8, but I still needed to use a CIDR search for 172.16.0.0/12.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Feb 2018 12:20:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-do-a-cidr-match-not-match-in-a-tstats-search/m-p/278097#M83934</guid>
      <dc:creator>isabel_ycourbe</dc:creator>
      <dc:date>2018-02-13T12:20:00Z</dc:date>
    </item>
    <item>
      <title>Re: How do I do a cidr match/not match in a tstats search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-do-a-cidr-match-not-match-in-a-tstats-search/m-p/278098#M83935</link>
      <description>&lt;P&gt;Good suggestion!&lt;/P&gt;</description>
      <pubDate>Tue, 13 Feb 2018 21:50:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-do-a-cidr-match-not-match-in-a-tstats-search/m-p/278098#M83935</guid>
      <dc:creator>MonkeyK</dc:creator>
      <dc:date>2018-02-13T21:50:58Z</dc:date>
    </item>
    <item>
      <title>Re: How do I do a cidr match/not match in a tstats search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-do-a-cidr-match-not-match-in-a-tstats-search/m-p/278099#M83936</link>
      <description>&lt;P&gt;Actually, natural CIDR filters work in &lt;CODE&gt;tstats&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| tstats count FROM datamodel=Network_Traffic WHERE index=* AND All_Traffic.src="10.0.0.0/8"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| tstats count WHERE index=* AND host="10.0.0.0/8"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This has been in Splunk for a long time, but maybe not always.  It works in all versions of 7.*&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jun 2019 17:38:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-do-a-cidr-match-not-match-in-a-tstats-search/m-p/278099#M83936</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-06-25T17:38:03Z</dc:date>
    </item>
    <item>
      <title>Re: How do I do a cidr match/not match in a tstats search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-do-a-cidr-match-not-match-in-a-tstats-search/m-p/278100#M83937</link>
      <description>&lt;P&gt;Just a note that 7.3 adds the ability to have negated CIDR in tstats.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jun 2019 17:40:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-do-a-cidr-match-not-match-in-a-tstats-search/m-p/278100#M83937</guid>
      <dc:creator>dshpritz</dc:creator>
      <dc:date>2019-06-25T17:40:25Z</dc:date>
    </item>
    <item>
      <title>Re: How do I do a cidr match/not match in a tstats search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-do-a-cidr-match-not-match-in-a-tstats-search/m-p/278101#M83938</link>
      <description>&lt;P&gt;I &lt;EM&gt;knew&lt;/EM&gt; that there was something new in 7.something.  Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jun 2019 18:48:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-do-a-cidr-match-not-match-in-a-tstats-search/m-p/278101#M83938</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-06-25T18:48:08Z</dc:date>
    </item>
    <item>
      <title>Re: How do I do a cidr match/not match in a tstats search?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-do-a-cidr-match-not-match-in-a-tstats-search/m-p/555353#M157643</link>
      <description>&lt;P&gt;We've observed that the cidr match functionality in tstats (as described in answer by woodcock -- thanks!) is working for IPv4 addresses ... but not for IPv6 addresses.&amp;nbsp; Any info on support for cidr match in tstats for IPv6 addresses?&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jun 2021 17:32:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-do-a-cidr-match-not-match-in-a-tstats-search/m-p/555353#M157643</guid>
      <dc:creator>wryanthomas</dc:creator>
      <dc:date>2021-06-10T17:32:39Z</dc:date>
    </item>
  </channel>
</rss>

