<?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 Powershell script to extract events from a log file - many dupe events indexed in Splunk in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Powershell-script-to-extract-events-from-a-log-file-many-dupe/m-p/375143#M67961</link>
    <description>&lt;P&gt;Question - is there a CRC equivalent for data indexed from a Powershell function?&lt;/P&gt;

&lt;P&gt;On a server, I have a log file generated everyday.  There are many events in this daily log file, but I only need to index a specific event.&lt;/P&gt;

&lt;P&gt;My approach was to create a powershell script which matches a specified string and returns the lines (the content, not the line number) that contain these events.  Running the script from the Powershell CLE appears to work as expected.&lt;/P&gt;

&lt;P&gt;I then created the following stanza in inputs.conf on the UF of the server:&lt;BR /&gt;
    [powershell://apache_search_test]&lt;BR /&gt;
    script = . "C:&amp;lt;subdirectories&amp;gt;\scanApacheLog_Splunk.ps1"&lt;BR /&gt;
    sourcetype = apache_test&lt;BR /&gt;
    schedule = 60&lt;BR /&gt;
    disabled = 0&lt;/P&gt;

&lt;P&gt;My test condition was to match the string "30/Jun/2017:09:59:17 -0400" - I see that the four events with this timestamp are indexed:&lt;BR /&gt;
xxx.xxx.xxx.xxx - - [30/Jun/2017:09:59:17 -0400] "HEAD /enterprise HTTP/1.0" 302 -&lt;BR /&gt;
xxx.xxx.xxx.xxx - - [30/Jun/2017:09:59:17 -0400] "POST /u/xmlrpc HTTP/1.1" 200 120&lt;BR /&gt;
xxx.xxx.xxx.xxx - - [30/Jun/2017:09:59:17 -0400] "POST /u/xmlrpc HTTP/1.1" 200 120&lt;BR /&gt;
xxx.xxx.xxx.xxx - - [30/Jun/2017:09:59:17 -0400] "POST /u/xmlrpc HTTP/1.1" 200 120&lt;/P&gt;

&lt;P&gt;The problem is these events are &lt;EM&gt;additionally&lt;/EM&gt; indexed each time the schedule of the stanza runs. But I only want the four events indexed (or less if they are not unique).&lt;/P&gt;

&lt;P&gt;Is there something missing in the stanza?  Do I need to add a stanza to props.conf (in that it may not be recognizing the timestamp)?&lt;/P&gt;

&lt;P&gt;Any help is appreciated!&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 14:42:00 GMT</pubDate>
    <dc:creator>a_splunk_user</dc:creator>
    <dc:date>2020-09-29T14:42:00Z</dc:date>
    <item>
      <title>Powershell script to extract events from a log file - many dupe events indexed in Splunk</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Powershell-script-to-extract-events-from-a-log-file-many-dupe/m-p/375143#M67961</link>
      <description>&lt;P&gt;Question - is there a CRC equivalent for data indexed from a Powershell function?&lt;/P&gt;

&lt;P&gt;On a server, I have a log file generated everyday.  There are many events in this daily log file, but I only need to index a specific event.&lt;/P&gt;

&lt;P&gt;My approach was to create a powershell script which matches a specified string and returns the lines (the content, not the line number) that contain these events.  Running the script from the Powershell CLE appears to work as expected.&lt;/P&gt;

&lt;P&gt;I then created the following stanza in inputs.conf on the UF of the server:&lt;BR /&gt;
    [powershell://apache_search_test]&lt;BR /&gt;
    script = . "C:&amp;lt;subdirectories&amp;gt;\scanApacheLog_Splunk.ps1"&lt;BR /&gt;
    sourcetype = apache_test&lt;BR /&gt;
    schedule = 60&lt;BR /&gt;
    disabled = 0&lt;/P&gt;

&lt;P&gt;My test condition was to match the string "30/Jun/2017:09:59:17 -0400" - I see that the four events with this timestamp are indexed:&lt;BR /&gt;
xxx.xxx.xxx.xxx - - [30/Jun/2017:09:59:17 -0400] "HEAD /enterprise HTTP/1.0" 302 -&lt;BR /&gt;
xxx.xxx.xxx.xxx - - [30/Jun/2017:09:59:17 -0400] "POST /u/xmlrpc HTTP/1.1" 200 120&lt;BR /&gt;
xxx.xxx.xxx.xxx - - [30/Jun/2017:09:59:17 -0400] "POST /u/xmlrpc HTTP/1.1" 200 120&lt;BR /&gt;
xxx.xxx.xxx.xxx - - [30/Jun/2017:09:59:17 -0400] "POST /u/xmlrpc HTTP/1.1" 200 120&lt;/P&gt;

&lt;P&gt;The problem is these events are &lt;EM&gt;additionally&lt;/EM&gt; indexed each time the schedule of the stanza runs. But I only want the four events indexed (or less if they are not unique).&lt;/P&gt;

&lt;P&gt;Is there something missing in the stanza?  Do I need to add a stanza to props.conf (in that it may not be recognizing the timestamp)?&lt;/P&gt;

&lt;P&gt;Any help is appreciated!&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 14:42:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Powershell-script-to-extract-events-from-a-log-file-many-dupe/m-p/375143#M67961</guid>
      <dc:creator>a_splunk_user</dc:creator>
      <dc:date>2020-09-29T14:42:00Z</dc:date>
    </item>
    <item>
      <title>Re: Powershell script to extract events from a log file - many dupe events indexed in Splunk</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Powershell-script-to-extract-events-from-a-log-file-many-dupe/m-p/375144#M67962</link>
      <description>&lt;P&gt;If I understand correctly the best way to diagnose, i'm thinking of few options&lt;BR /&gt;
1. use your powershell script to write into a FILE.  and let Splunk read the file. This way you can understand if the script creates duplicate events or NOT. &lt;BR /&gt;
2. Write a unique ID in your messages  (i.e session id or process id ), that way you are sure if they are same messages or not.&lt;BR /&gt;
3. output timestamp to much precise values  with milliseconds and timezone &lt;BR /&gt;
4. Tackle at Splunk level by putting props for duplicate events (not preferred)&lt;/P&gt;</description>
      <pubDate>Sat, 01 Jul 2017 09:17:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Powershell-script-to-extract-events-from-a-log-file-many-dupe/m-p/375144#M67962</guid>
      <dc:creator>koshyk</dc:creator>
      <dc:date>2017-07-01T09:17:37Z</dc:date>
    </item>
  </channel>
</rss>

