<?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: Drop events before indexing. Complex filter in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Drop-events-before-indexing-Complex-filter/m-p/224269#M43907</link>
    <description>&lt;P&gt;Just for reference, in case someone else makes the same mistake.&lt;BR /&gt;
As pointed out by alemarzu, I had a typo in one of the stanzas.&lt;BR /&gt;
Also, if you are doing this, be aware that the documentation of props.conf is wrong. The last element in the TRANSFORMS-= line is done first, then the next and so on. Not the other way as the documentation says.&lt;BR /&gt;
Took me several tests to confirm.&lt;/P&gt;</description>
    <pubDate>Tue, 10 Jan 2017 14:54:29 GMT</pubDate>
    <dc:creator>hcpr</dc:creator>
    <dc:date>2017-01-10T14:54:29Z</dc:date>
    <item>
      <title>Drop events before indexing. Complex filter</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Drop-events-before-indexing-Complex-filter/m-p/224264#M43902</link>
      <description>&lt;P&gt;Hi, &lt;BR /&gt;
I need to filter out some data before indexing, ands can't quite get it to work.&lt;BR /&gt;
The data is a json format (from Suricata), and looks like this typically:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{"timestamp":"2017-01-09T12:24:38.870864+0100","flow_id":1556450832173294,"in_iface":"sniffer0","event_type":"dns","vlan":935,"src_ip":"192.168.7.52","src_port":53,"dest_ip":"192.168.7.27","dest_port":52670,"proto":"UDP","dns":{"type":"answer","id":27371,"rcode":"NOERROR","rrname":"253.165.168.192.in-addr.arpa","rrtype":"PTR","ttl":11476,"rdata":"pri-f5-indre.proxy.u.dep.no"}}
{"timestamp":"2017-01-09T12:24:38.871589+0100","flow_id":1088479785536677,"in_iface":"sniffer0","event_type":"dns","vlan":190,"src_ip":"192.168.149.30","src_port":35577,"dest_ip":"192.168.7.52","dest_port":53,"proto":"UDP","dns":{"type":"query","id":53493,"rrname":"cdn.els-cdn.com","rrtype":"A","tx_id":0}}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;(that is two long lines)&lt;BR /&gt;
This is the dns log from Suricata written to a json file.&lt;BR /&gt;
What I need to do is first filter so that I only get the traffic to/from a few servere (some dns servers), after that I need to filter out all PTR logs.&lt;BR /&gt;
The first part was easy. Since the machine in question is running a heavy forwarder I added the following to the config:&lt;/P&gt;

&lt;P&gt;In props.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[source::/data/suricata/log/eve-dns.json]
TRANSFORMS-set = setnull,setparsing
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And in transforms.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[setnull]
REGEX = .
DEST_KEY = queue
FORMAT = nullQueue

[setparsing]
REGEX = (?:(?:"vlan":906.*?"dest_ip":"192\.168\.7\.5[2345]","dest_port":53)|(?:"vlan":710.*?"dest_ip":"192\.168\.4\.[45678]","dest_port":53)|(?:"vlan":850.*?"dest_ip":"192\.168\.156\.[234]","dest_port":53)|(?:"vlan":370.*?"dest_ip":"192\.168\.137\.[23]","dest_port":53)|(?:"vlan":311.*?"dest_ip":"192\.168\.252\.[56]","dest_port":53))|(?:(?:"vlan":906.*?"src_ip":"192\.168\.7\.5[2345]","src_port":53)|(?:"vlan":710.*?"src_ip":"192\.168\.4\.[45678]","src_port":53)|(?:"vlan":850.*?"src_ip":"192\.168\.156\.[234]","src_port":53)|(?:"vlan":370.*?"src_ip":"192\.168\.137\.[23]","src_port":53)|(?:"vlan":311.*?"src_ip":"192\.168\.252\.[56]","src_port":53))
DEST_KEY = queue
FORMAT = indexQueue
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But I can't figure out. First I tried adding a third transform to the mix, on the theory that they are run in order, and that the forst one stops. That does not seem to be tha case, as the the following did not fork:&lt;/P&gt;

&lt;P&gt;In props.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[source::/data/suricata/log/eve-dns.json]
TRANSFORMS-set = setnull,setparsing,setfilter
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And adding the following in transforms.conf&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; [setfilter]
REGEX = "rrtype":"PTR"
DST_KEY = queue
FORMAT = nullQueue   
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I've also tried using SEDCMD, which I've had success with in other problems. For instance this (and several variations of the regexp):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;SEDCMD-remove_PTR = s/*."rrtype":"PTR".*//g
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So, any ideas anyone?&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jan 2017 12:15:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Drop-events-before-indexing-Complex-filter/m-p/224264#M43902</guid>
      <dc:creator>hcpr</dc:creator>
      <dc:date>2017-01-09T12:15:54Z</dc:date>
    </item>
    <item>
      <title>Re: Drop events before indexing. Complex filter</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Drop-events-before-indexing-Complex-filter/m-p/224265#M43903</link>
      <description>&lt;P&gt;Hi hcpr,&lt;BR /&gt;
setnull must be always the first, but did you try to change the order between setparsing and setfilter?&lt;BR /&gt;
Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Mon, 09 Jan 2017 13:16:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Drop-events-before-indexing-Complex-filter/m-p/224265#M43903</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2017-01-09T13:16:24Z</dc:date>
    </item>
    <item>
      <title>Re: Drop events before indexing. Complex filter</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Drop-events-before-indexing-Complex-filter/m-p/224266#M43904</link>
      <description>&lt;P&gt;Yes, I've tried that. Same result though. &lt;/P&gt;</description>
      <pubDate>Mon, 09 Jan 2017 13:24:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Drop-events-before-indexing-Complex-filter/m-p/224266#M43904</guid>
      <dc:creator>hcpr</dc:creator>
      <dc:date>2017-01-09T13:24:09Z</dc:date>
    </item>
    <item>
      <title>Re: Drop events before indexing. Complex filter</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Drop-events-before-indexing-Complex-filter/m-p/224267#M43905</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/680"&gt;@hcpr&lt;/a&gt;&lt;/P&gt;

&lt;P&gt;You have a typo on your &lt;STRONG&gt;setfilter&lt;/STRONG&gt; stanza, its DEST_KEY not DST_KEY. Also, you should be scaping doble quotes on your regexes.&lt;/P&gt;

&lt;P&gt;Hope it helps.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 12:20:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Drop-events-before-indexing-Complex-filter/m-p/224267#M43905</guid>
      <dc:creator>alemarzu</dc:creator>
      <dc:date>2020-09-29T12:20:17Z</dc:date>
    </item>
    <item>
      <title>Re: Drop events before indexing. Complex filter</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Drop-events-before-indexing-Complex-filter/m-p/224268#M43906</link>
      <description>&lt;P&gt;You are absolutely right. DST_KEY was one of the problems.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jan 2017 14:51:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Drop-events-before-indexing-Complex-filter/m-p/224268#M43906</guid>
      <dc:creator>hcpr</dc:creator>
      <dc:date>2017-01-10T14:51:34Z</dc:date>
    </item>
    <item>
      <title>Re: Drop events before indexing. Complex filter</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Drop-events-before-indexing-Complex-filter/m-p/224269#M43907</link>
      <description>&lt;P&gt;Just for reference, in case someone else makes the same mistake.&lt;BR /&gt;
As pointed out by alemarzu, I had a typo in one of the stanzas.&lt;BR /&gt;
Also, if you are doing this, be aware that the documentation of props.conf is wrong. The last element in the TRANSFORMS-= line is done first, then the next and so on. Not the other way as the documentation says.&lt;BR /&gt;
Took me several tests to confirm.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jan 2017 14:54:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Drop-events-before-indexing-Complex-filter/m-p/224269#M43907</guid>
      <dc:creator>hcpr</dc:creator>
      <dc:date>2017-01-10T14:54:29Z</dc:date>
    </item>
    <item>
      <title>Re: Drop events before indexing. Complex filter</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Drop-events-before-indexing-Complex-filter/m-p/224270#M43908</link>
      <description>&lt;P&gt;Actually, this was relevant but hidden by the typo I had in one of the transforms stanzas.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jan 2017 14:55:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Drop-events-before-indexing-Complex-filter/m-p/224270#M43908</guid>
      <dc:creator>hcpr</dc:creator>
      <dc:date>2017-01-10T14:55:21Z</dc:date>
    </item>
    <item>
      <title>Re: Drop events before indexing. Complex filter</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Drop-events-before-indexing-Complex-filter/m-p/224271#M43909</link>
      <description>&lt;P&gt;I would not say the documentation is wrong but may be incomplete. The event routing (transforms with DEST_KEY=queue) are special type of transform and  the order of the transforms in props.conf matters. The null queue transform must come first; if it comes later, it will invalidate the previous transform and route all events to the null queue. See more details here:&lt;BR /&gt;
&lt;A href="http://docs.splunk.com/Documentation/SplunkCloud/6.5.1/Forwarding/Routeandfilterdatad#Keep_specific_events_and_discard_the_rest" target="_blank"&gt;http://docs.splunk.com/Documentation/SplunkCloud/6.5.1/Forwarding/Routeandfilterdatad#Keep_specific_events_and_discard_the_rest&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 12:20:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Drop-events-before-indexing-Complex-filter/m-p/224271#M43909</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2020-09-29T12:20:50Z</dc:date>
    </item>
    <item>
      <title>Re: Drop events before indexing. Complex filter</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Drop-events-before-indexing-Complex-filter/m-p/224272#M43910</link>
      <description>&lt;P&gt;Glad it worked out, happy splunking!&lt;/P&gt;</description>
      <pubDate>Wed, 11 Jan 2017 14:56:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Drop-events-before-indexing-Complex-filter/m-p/224272#M43910</guid>
      <dc:creator>alemarzu</dc:creator>
      <dc:date>2017-01-11T14:56:18Z</dc:date>
    </item>
  </channel>
</rss>

