<?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: State File Monitoring in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/State-File-Monitoring/m-p/74055#M15151</link>
    <description>&lt;P&gt;Write a scripted input that runs every 5 minutes (off cycle from the file update if possible).&lt;BR /&gt;
In your script, read the file. Emit the value of eventA (or whatever you want), to stdout.&lt;BR /&gt;&lt;BR /&gt;
Don't monitor the file in any other way.  Here is a python script that might do the trick:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;import re
data = open("filePathHere").read()
matchFound = re.search("(?P&amp;lt;matchString&amp;gt;eventA\s*?=\s*?\S+)",data)
if matchFound:
    print matchFound.group('matchString')
else:
    print "EventA not found"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will work best if the file is not too large. It will look for the first occurrence of &lt;CODE&gt;eventA=something&lt;/CODE&gt; and print what it finds. It allows for optional whitespace around the equals sign (that's what &lt;CODE&gt;\s*?&lt;/CODE&gt; does).&lt;/P&gt;

&lt;P&gt;If you set this up as a scripted input in Splunk, you will see only the following added to Splunk every 5 minutes:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eventA=something
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 13 Jun 2012 16:59:08 GMT</pubDate>
    <dc:creator>lguinn2</dc:creator>
    <dc:date>2012-06-13T16:59:08Z</dc:date>
    <item>
      <title>State File Monitoring</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/State-File-Monitoring/m-p/74054#M15150</link>
      <description>&lt;P&gt;i have a state file that writes the same size data file every 5 minutes but the data inside is only sometimes different. An example would be "event A = true" , but on the next write it might be "event A = false"&lt;/P&gt;

&lt;P&gt;I dont want it to reindex everything and spike the usage limit. Is there a way for me to just index the change from true to false?&lt;/P&gt;

&lt;P&gt;Thanks &lt;/P&gt;</description>
      <pubDate>Wed, 13 Jun 2012 14:24:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/State-File-Monitoring/m-p/74054#M15150</guid>
      <dc:creator>splunk_gs</dc:creator>
      <dc:date>2012-06-13T14:24:16Z</dc:date>
    </item>
    <item>
      <title>Re: State File Monitoring</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/State-File-Monitoring/m-p/74055#M15151</link>
      <description>&lt;P&gt;Write a scripted input that runs every 5 minutes (off cycle from the file update if possible).&lt;BR /&gt;
In your script, read the file. Emit the value of eventA (or whatever you want), to stdout.&lt;BR /&gt;&lt;BR /&gt;
Don't monitor the file in any other way.  Here is a python script that might do the trick:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;import re
data = open("filePathHere").read()
matchFound = re.search("(?P&amp;lt;matchString&amp;gt;eventA\s*?=\s*?\S+)",data)
if matchFound:
    print matchFound.group('matchString')
else:
    print "EventA not found"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This will work best if the file is not too large. It will look for the first occurrence of &lt;CODE&gt;eventA=something&lt;/CODE&gt; and print what it finds. It allows for optional whitespace around the equals sign (that's what &lt;CODE&gt;\s*?&lt;/CODE&gt; does).&lt;/P&gt;

&lt;P&gt;If you set this up as a scripted input in Splunk, you will see only the following added to Splunk every 5 minutes:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;eventA=something
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Jun 2012 16:59:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/State-File-Monitoring/m-p/74055#M15151</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2012-06-13T16:59:08Z</dc:date>
    </item>
    <item>
      <title>Re: State File Monitoring</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/State-File-Monitoring/m-p/74056#M15152</link>
      <description>&lt;P&gt;how would the script integrate into splunk? would it just retrieve the latest updates and insert it?&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jun 2012 17:30:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/State-File-Monitoring/m-p/74056#M15152</guid>
      <dc:creator>splunk_gs</dc:creator>
      <dc:date>2012-06-13T17:30:19Z</dc:date>
    </item>
    <item>
      <title>Re: State File Monitoring</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/State-File-Monitoring/m-p/74057#M15153</link>
      <description>&lt;P&gt;When you go into the Splunk Manager,  under Data Inputs &amp;gt;&amp;gt; Scripts, click the New button. Fill in the info, including the stuff under More Options. Notice that your script has to be placed in a particular directory.&lt;/P&gt;

&lt;P&gt;After you complete this setup, Splunk will run the script at the interval you have selected, and will index the output of the script.&lt;/P&gt;

&lt;P&gt;For more info: &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/Data/Setupcustominputs#Add_a_scripted_input_in_Splunk_Web"&gt;http://docs.splunk.com/Documentation/Splunk/latest/Data/Setupcustominputs#Add_a_scripted_input_in_Splunk_Web&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jun 2012 17:39:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/State-File-Monitoring/m-p/74057#M15153</guid>
      <dc:creator>lguinn2</dc:creator>
      <dc:date>2012-06-13T17:39:22Z</dc:date>
    </item>
  </channel>
</rss>

