<?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: Index only first Occurrence of string in events in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Index-only-first-Occurrence-of-string-in-events/m-p/401075#M71422</link>
    <description>&lt;P&gt;You're welcome @ips_mandar. &lt;BR /&gt;
You don't have to unzip your files, then read, then delete. You can simply read them using &lt;CODE&gt;zcat&lt;/CODE&gt;from the script : &lt;BR /&gt;
&lt;A href="https://www.tecmint.com/linux-zcat-command-examples/"&gt;https://www.tecmint.com/linux-zcat-command-examples/&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Let me know if that's what you're looking for &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 19 Jul 2019 09:58:24 GMT</pubDate>
    <dc:creator>DavidHourani</dc:creator>
    <dc:date>2019-07-19T09:58:24Z</dc:date>
    <item>
      <title>Index only first Occurrence of string in events</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Index-only-first-Occurrence-of-string-in-events/m-p/401072#M71419</link>
      <description>&lt;P&gt;I want to know if below things are possible in splunk and if YES then How it can be achieved-&lt;BR /&gt;
1. Below is sample events&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;2019-07-16|21:15:43.370|INFO|This is a statement
2019-07-16|21:16:43.370|INFO|Random statement
2019-07-16|21:17:43.370|INFO|Random statement
2019-07-16|21:18:43.370|INFO|This is a statement
2019-07-16|21:19:43.370|INFO|This is a statement
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I have heavy forwarder where I want to index only first occurrence of "This is a statement" line and do not want other lines which contain "This is a statement" string to be index. Since same line coming multiple time in log file and I want to index only first occurrence of it.&lt;BR /&gt;
2.  Below is another sample events&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;2019-07-16|21:15:43.370|INFO|Temprature-30
2019-07-16|21:16:43.370|INFO|Temprature-30
2019-07-16|21:17:43.370|INFO|Temprature-30
2019-07-16|21:18:43.370|INFO|Temprature-32
2019-07-16|21:19:43.370|INFO|Temprature-32
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Here I want only two lines which has distinct temprature to be index.&lt;BR /&gt;
are these above two strings possible in splunk? I want these to be done before indexing so to reduce indexing volume.&lt;BR /&gt;
Currently I am using nullqueue and indexqueue to parse required data but now I want to index only first occurrence. &lt;BR /&gt;
Appreciate your help.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jul 2019 05:46:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Index-only-first-Occurrence-of-string-in-events/m-p/401072#M71419</guid>
      <dc:creator>ips_mandar</dc:creator>
      <dc:date>2019-07-19T05:46:31Z</dc:date>
    </item>
    <item>
      <title>Re: Index only first Occurrence of string in events</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Index-only-first-Occurrence-of-string-in-events/m-p/401073#M71420</link>
      <description>&lt;P&gt;Hi @ips_mandar,&lt;/P&gt;

&lt;P&gt;This kind of logic is not possible on the HF alone as the indexing pipeline doesn't keep a history of the indexed events. You can see here in more details how that layer works : &lt;BR /&gt;
&lt;A href="https://wiki.splunk.com/Community:HowIndexingWorks"&gt;https://wiki.splunk.com/Community:HowIndexingWorks&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;My advice in your case is to create a scripted input and configure it in the &lt;CODE&gt;inputs.conf&lt;/CODE&gt; to run with run it with an &lt;CODE&gt;interval&lt;/CODE&gt; of 5-10 mins (more or less depending on your needs). Within this scrip you can apply the required logic and then the output which is the non-duplicated events is the only thing that will get indexed. &lt;BR /&gt;
Details here of when to use scripted inputs can be found here : &lt;A href="https://docs.splunk.com/Documentation/Splunk/7.3.0/AdvancedDev/ScriptedInputsIntro#Use_cases_for_scripted_inputs"&gt;https://docs.splunk.com/Documentation/Splunk/7.3.0/AdvancedDev/ScriptedInputsIntro#Use_cases_for_scripted_inputs&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;If you're not comfortable with scripted inputs you can simply &lt;CODE&gt;cron&lt;/CODE&gt; a script to apply cleansing on your file and rewrite them into new files without duplicates. Then you would index those files instead of the main ones.&lt;/P&gt;

&lt;P&gt;Cheers,&lt;BR /&gt;
David&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jul 2019 09:03:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Index-only-first-Occurrence-of-string-in-events/m-p/401073#M71420</guid>
      <dc:creator>DavidHourani</dc:creator>
      <dc:date>2019-07-19T09:03:00Z</dc:date>
    </item>
    <item>
      <title>Re: Index only first Occurrence of string in events</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Index-only-first-Occurrence-of-string-in-events/m-p/401074#M71421</link>
      <description>&lt;P&gt;Thanks @DavidHourani &lt;BR /&gt;
If I write script to remove duplicates logic and if I run then it will require to store parsed files in another folder and then with monitor stanza I will monitor these parsed files which will require "&lt;STRONG&gt;disk space&lt;/STRONG&gt;" since my all files are zip files.&lt;BR /&gt;
Can it be possible with zip files without storing any parsed log files on separate folder and directly send for indexing? if yes can you please help me with sample script..&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jul 2019 09:21:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Index-only-first-Occurrence-of-string-in-events/m-p/401074#M71421</guid>
      <dc:creator>ips_mandar</dc:creator>
      <dc:date>2019-07-19T09:21:48Z</dc:date>
    </item>
    <item>
      <title>Re: Index only first Occurrence of string in events</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Index-only-first-Occurrence-of-string-in-events/m-p/401075#M71422</link>
      <description>&lt;P&gt;You're welcome @ips_mandar. &lt;BR /&gt;
You don't have to unzip your files, then read, then delete. You can simply read them using &lt;CODE&gt;zcat&lt;/CODE&gt;from the script : &lt;BR /&gt;
&lt;A href="https://www.tecmint.com/linux-zcat-command-examples/"&gt;https://www.tecmint.com/linux-zcat-command-examples/&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Let me know if that's what you're looking for &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jul 2019 09:58:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Index-only-first-Occurrence-of-string-in-events/m-p/401075#M71422</guid>
      <dc:creator>DavidHourani</dc:creator>
      <dc:date>2019-07-19T09:58:24Z</dc:date>
    </item>
    <item>
      <title>Re: Index only first Occurrence of string in events</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Index-only-first-Occurrence-of-string-in-events/m-p/401076#M71423</link>
      <description>&lt;P&gt;sorry I didn't mention that I am on Windows server.&lt;BR /&gt;
I am very new with scripts it will be good if you can share me one script which I can run to remove duplicates from zip files although in duplicates line timestamp will be different. &lt;/P&gt;</description>
      <pubDate>Fri, 19 Jul 2019 10:04:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Index-only-first-Occurrence-of-string-in-events/m-p/401076#M71423</guid>
      <dc:creator>ips_mandar</dc:creator>
      <dc:date>2019-07-19T10:04:25Z</dc:date>
    </item>
    <item>
      <title>Re: Index only first Occurrence of string in events</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Index-only-first-Occurrence-of-string-in-events/m-p/401077#M71424</link>
      <description>&lt;P&gt;The logic should be as follows :&lt;BR /&gt;
1- find unique events&lt;BR /&gt;
2- write into new files&lt;BR /&gt;
For linux you can very easily do that using : &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sort -u your_file &amp;gt; new_file
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You could try finding the equivalent for windows, it surely exists.&lt;/P&gt;

&lt;P&gt;Also you might need to handle the timestamp because that makes all lines different, so you'll also need to exclude that from the "unique" logic.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Jul 2019 13:53:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Index-only-first-Occurrence-of-string-in-events/m-p/401077#M71424</guid>
      <dc:creator>DavidHourani</dc:creator>
      <dc:date>2019-07-19T13:53:08Z</dc:date>
    </item>
  </channel>
</rss>

