<?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 to filter out events in Splunk 6.3.1 at index-time, except files containing the string &amp;quot;#!&amp;quot; in the first 5 characters of the file? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-filter-out-events-in-Splunk-6-3-1-at-index-time-except/m-p/225928#M66630</link>
    <description>&lt;P&gt;Out of curiosity are you trying to do all of this on a universal forwarder?  &lt;/P&gt;

&lt;P&gt;If you are, adding these props/transforms to a UF they won't work, you have to add those settings to your indexing tier. &lt;/P&gt;</description>
    <pubDate>Mon, 16 Nov 2015 19:28:42 GMT</pubDate>
    <dc:creator>tmarlette</dc:creator>
    <dc:date>2015-11-16T19:28:42Z</dc:date>
    <item>
      <title>How to filter out events in Splunk 6.3.1 at index-time, except files containing the string "#!" in the first 5 characters of the file?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-filter-out-events-in-Splunk-6-3-1-at-index-time-except/m-p/225923#M66625</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I only want to index files containing the string &lt;CODE&gt;#!&lt;/CODE&gt; in the first 5 characters of the file.&lt;BR /&gt;
Therefore, I created the following inputs.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[monitor:pathname] 
blacklist = (?i:archive|develop|data|backup|\.txt$|\.gz$|\.tar$|\.csv$|\.bck$|\.log$|\.old$|\d{6,})
disabled = false 
host = script 
index = abcindex 
sourcetype = abcscript
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Props.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[abcscript] 
TRANSFORMS-set= setnull,setparsing
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Transforms.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[setnull] 
REGEX = . 
DEST_KEY = queue
FORMAT = nullQueue

[setparsing] 
REGEX = (.{0,5}(#!))
DEST_KEY = queue
FORMAT = indexQueue
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Based on &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.3.1/Forwarding/Routeandfilterdatad"&gt;http://docs.splunk.com/Documentation/Splunk/6.3.1/Forwarding/Routeandfilterdatad&lt;/A&gt; &lt;BR /&gt;
Unfortunately, everything is indexed in the index "abcindex" at the moment, and not only files starting with &lt;CODE&gt;#!&lt;/CODE&gt;&lt;BR /&gt;
I also tried it with a dummy string in a dummy file, but again, everything is indexed.&lt;BR /&gt;
Rebooted Splunk after changing config files.&lt;/P&gt;

&lt;P&gt;Any idea what goes wrong here?&lt;BR /&gt;
Using Splunk 6.3.1 at the moment.&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2015 11:52:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-filter-out-events-in-Splunk-6-3-1-at-index-time-except/m-p/225923#M66625</guid>
      <dc:creator>stanvv</dc:creator>
      <dc:date>2015-11-12T11:52:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter out events in Splunk 6.3.1 at index-time, except files containing the string "#!" in the first 5 characters of the file?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-filter-out-events-in-Splunk-6-3-1-at-index-time-except/m-p/225924#M66626</link>
      <description>&lt;P&gt;Your RegEx is wrong; try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;REGEX = ^(.{0,3}(#!))
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This needs to be deployed to all your indexers and the splunk instances running there need to be restarted.  After this is done, incoming events will be properly filtered but events indexed before the restart will not be effected.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2015 14:25:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-filter-out-events-in-Splunk-6-3-1-at-index-time-except/m-p/225924#M66626</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-11-12T14:25:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter out events in Splunk 6.3.1 at index-time, except files containing the string "#!" in the first 5 characters of the file?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-filter-out-events-in-Splunk-6-3-1-at-index-time-except/m-p/225925#M66627</link>
      <description>&lt;P&gt;Thanks for you answer. I tried the above (changed regex, rebooted and tried it with dummy files: one starting with #! and the other didn't) but still files not starting with #! were indexed.&lt;BR /&gt;
I'm testing it on a local Splunk enterprise at the moment.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2015 14:41:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-filter-out-events-in-Splunk-6-3-1-at-index-time-except/m-p/225925#M66627</guid>
      <dc:creator>stanvv</dc:creator>
      <dc:date>2015-11-12T14:41:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter out events in Splunk 6.3.1 at index-time, except files containing the string "#!" in the first 5 characters of the file?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-filter-out-events-in-Splunk-6-3-1-at-index-time-except/m-p/225926#M66628</link>
      <description>&lt;P&gt;The RegEx applies to each event, not to the entire file.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Nov 2015 17:35:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-filter-out-events-in-Splunk-6-3-1-at-index-time-except/m-p/225926#M66628</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-11-12T17:35:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter out events in Splunk 6.3.1 at index-time, except files containing the string "#!" in the first 5 characters of the file?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-filter-out-events-in-Splunk-6-3-1-at-index-time-except/m-p/225927#M66629</link>
      <description>&lt;P&gt;The files I'm monitoring are scripts (sometimes with an undefined filetype). So if the file content itself starts with #! I want it to be indexed. If it doesn't, it should go to the nullQueue.&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Example&lt;/STRONG&gt;&lt;BR /&gt;
&lt;EM&gt;File 1 (needs to be indexed)&lt;/EM&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;#!
########
# Intro 123
########
#Scriptinfo
ABC = 123
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;EM&gt;File 2 (send to nullQueue)&lt;/EM&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;########
# Intro 234
########
#Scriptinfo
DEF = 567
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Do props.conf and transforms.conf also work for non log/txt files? Any ideas what's the best solution?&lt;/P&gt;</description>
      <pubDate>Fri, 13 Nov 2015 11:46:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-filter-out-events-in-Splunk-6-3-1-at-index-time-except/m-p/225927#M66629</guid>
      <dc:creator>stanvv</dc:creator>
      <dc:date>2015-11-13T11:46:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter out events in Splunk 6.3.1 at index-time, except files containing the string "#!" in the first 5 characters of the file?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-filter-out-events-in-Splunk-6-3-1-at-index-time-except/m-p/225928#M66630</link>
      <description>&lt;P&gt;Out of curiosity are you trying to do all of this on a universal forwarder?  &lt;/P&gt;

&lt;P&gt;If you are, adding these props/transforms to a UF they won't work, you have to add those settings to your indexing tier. &lt;/P&gt;</description>
      <pubDate>Mon, 16 Nov 2015 19:28:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-filter-out-events-in-Splunk-6-3-1-at-index-time-except/m-p/225928#M66630</guid>
      <dc:creator>tmarlette</dc:creator>
      <dc:date>2015-11-16T19:28:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter out events in Splunk 6.3.1 at index-time, except files containing the string "#!" in the first 5 characters of the file?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-filter-out-events-in-Splunk-6-3-1-at-index-time-except/m-p/225929#M66631</link>
      <description>&lt;P&gt;I'm testing it on a local Splunk enterprise at the moment.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Nov 2015 10:29:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-filter-out-events-in-Splunk-6-3-1-at-index-time-except/m-p/225929#M66631</guid>
      <dc:creator>stanvv</dc:creator>
      <dc:date>2015-11-18T10:29:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to filter out events in Splunk 6.3.1 at index-time, except files containing the string "#!" in the first 5 characters of the file?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-filter-out-events-in-Splunk-6-3-1-at-index-time-except/m-p/225930#M66632</link>
      <description>&lt;P&gt;Make sure you set this for your sourcetype in &lt;CODE&gt;props.conf&lt;/CODE&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[YourSourcetypeHere]
LINE_BREAKER=(\Z)
TRUNCATE=500000
SHOULD_LINEMERGE = 1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will treat the entire file as a single event and then it should work as you expect.  Deploy this to the Indexers (or Heavy Forwarders) and restart all splunk instances there.  This will apply ONLY TO FUTURE EVENTS (the scripts that are already there have already been processed) so you will have to create new files in order to test this.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Nov 2015 23:05:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-filter-out-events-in-Splunk-6-3-1-at-index-time-except/m-p/225930#M66632</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2015-11-18T23:05:41Z</dc:date>
    </item>
  </channel>
</rss>

