<?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: Search inside the files based on keywords to do sub search in splunk in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Search-inside-the-files-based-on-keywords-to-do-sub-search-in/m-p/361444#M106745</link>
    <description>&lt;P&gt;Yes files are there in splunk currently. I already tried the way  @cmerriman mentioned as below: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source=*.txt SQLDB |search KEYWORD1 OR KEYWORD2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The problem I am facing here is since we have base search as "SQLDB", it will only shows lines with "SQLDB" in those txt files. &lt;BR /&gt;
But I need to search KEYWORD1 and KEYWORD2 inside the text files having "SQLDB".&lt;/P&gt;</description>
    <pubDate>Thu, 08 Feb 2018 17:18:05 GMT</pubDate>
    <dc:creator>rojit</dc:creator>
    <dc:date>2018-02-08T17:18:05Z</dc:date>
    <item>
      <title>Search inside the files based on keywords to do sub search in splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-inside-the-files-based-on-keywords-to-do-sub-search-in/m-p/361440#M106741</link>
      <description>&lt;P&gt;I have following types of txt files in my source and contents of each files are mentioned below in CAPS:&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;a1.txt:&lt;/STRONG&gt;&lt;BR /&gt;
    KEYWORD1&lt;BR /&gt;
    SQLDB&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;a2.txt:&lt;/STRONG&gt;&lt;BR /&gt;
    KEYWORD1&lt;BR /&gt;
    KEYWORD2    &lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;a3.txt:&lt;/STRONG&gt;&lt;BR /&gt;
    KEYWORD1&lt;BR /&gt;
    KEYWORD2&lt;BR /&gt;
    SQLDB&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;a4.txt:&lt;/STRONG&gt;&lt;BR /&gt;
    KEYWORD1&lt;BR /&gt;
    KEYWORD2&lt;/P&gt;

&lt;P&gt;From the above files, I need to search only txt files contains 'SQLDB' to fetch values 'KEYWORD1' or 'KEYWORD2' inside that file. &lt;BR /&gt;
In above example, it should search only a1.txt and a3.txt files for me to have my further searches. &lt;/P&gt;

&lt;P&gt;So basically, need to identify certain ways similar to Exists.&lt;BR /&gt;
Appreciable, if anyone can help me to achieve this..&lt;/P&gt;</description>
      <pubDate>Thu, 08 Feb 2018 11:32:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-inside-the-files-based-on-keywords-to-do-sub-search-in/m-p/361440#M106741</guid>
      <dc:creator>rojit</dc:creator>
      <dc:date>2018-02-08T11:32:12Z</dc:date>
    </item>
    <item>
      <title>Re: Search inside the files based on keywords to do sub search in splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-inside-the-files-based-on-keywords-to-do-sub-search-in/m-p/361441#M106742</link>
      <description>&lt;P&gt;Are these file in Splunk already?  If so, the "source" field should contain the file name.  Can you confirm this?&lt;/P&gt;

&lt;P&gt;If they are NOT in Splunk, well, that's probably your first step.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Feb 2018 12:31:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-inside-the-files-based-on-keywords-to-do-sub-search-in/m-p/361441#M106742</guid>
      <dc:creator>Richfez</dc:creator>
      <dc:date>2018-02-08T12:31:39Z</dc:date>
    </item>
    <item>
      <title>Re: Search inside the files based on keywords to do sub search in splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-inside-the-files-based-on-keywords-to-do-sub-search-in/m-p/361442#M106743</link>
      <description>&lt;P&gt;as @rich7177 mentions, if the files are in Splunk, and they are listed as &lt;STRONG&gt;sources&lt;/STRONG&gt; you're search could be something like &lt;CODE&gt;source=*.txt SQLDB |search KEYWORD1 OR KEYWORD2&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Feb 2018 12:53:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-inside-the-files-based-on-keywords-to-do-sub-search-in/m-p/361442#M106743</guid>
      <dc:creator>cmerriman</dc:creator>
      <dc:date>2018-02-08T12:53:51Z</dc:date>
    </item>
    <item>
      <title>Re: Search inside the files based on keywords to do sub search in splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-inside-the-files-based-on-keywords-to-do-sub-search-in/m-p/361443#M106744</link>
      <description>&lt;P&gt;Thanks @cmerriman and yes files are there in splunk server. I already tried the above step. &lt;BR /&gt;
The problem I am facing here is since we have base search as "SQLDB", it already will only shows lines with "SQLDB" in those txt files. &lt;BR /&gt;
But I need to search KEYWORD1 and KEYWORD2 inside the text file having "SQLDB".&lt;/P&gt;</description>
      <pubDate>Thu, 08 Feb 2018 17:16:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-inside-the-files-based-on-keywords-to-do-sub-search-in/m-p/361443#M106744</guid>
      <dc:creator>rojit</dc:creator>
      <dc:date>2018-02-08T17:16:17Z</dc:date>
    </item>
    <item>
      <title>Re: Search inside the files based on keywords to do sub search in splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-inside-the-files-based-on-keywords-to-do-sub-search-in/m-p/361444#M106745</link>
      <description>&lt;P&gt;Yes files are there in splunk currently. I already tried the way  @cmerriman mentioned as below: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source=*.txt SQLDB |search KEYWORD1 OR KEYWORD2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The problem I am facing here is since we have base search as "SQLDB", it will only shows lines with "SQLDB" in those txt files. &lt;BR /&gt;
But I need to search KEYWORD1 and KEYWORD2 inside the text files having "SQLDB".&lt;/P&gt;</description>
      <pubDate>Thu, 08 Feb 2018 17:18:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-inside-the-files-based-on-keywords-to-do-sub-search-in/m-p/361444#M106745</guid>
      <dc:creator>rojit</dc:creator>
      <dc:date>2018-02-08T17:18:05Z</dc:date>
    </item>
    <item>
      <title>Re: Search inside the files based on keywords to do sub search in splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-inside-the-files-based-on-keywords-to-do-sub-search-in/m-p/361445#M106746</link>
      <description>&lt;P&gt;What do you mean "search KEYWORD1 and KEYWORD2 inside the text files"?&lt;/P&gt;

&lt;P&gt;The way I'm parsing it right now it seems like you mean this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source=*.txt SQLDB KEYWORD1 KEYWORD2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Which would give you events from any &lt;CODE&gt;.txt&lt;/CODE&gt; file that has the words "SQLDB", "KEYWORD1", and "KEYWORD2" present.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Feb 2018 17:58:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-inside-the-files-based-on-keywords-to-do-sub-search-in/m-p/361445#M106746</guid>
      <dc:creator>micahkemp</dc:creator>
      <dc:date>2018-02-08T17:58:53Z</dc:date>
    </item>
    <item>
      <title>Re: Search inside the files based on keywords to do sub search in splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-inside-the-files-based-on-keywords-to-do-sub-search-in/m-p/361446#M106747</link>
      <description>&lt;P&gt;@micahkemp has another great option of putting all the keywords in the base search. &lt;CODE&gt;source=*.txt SQLDB  (KEYWORD1 OR KEYWORD2)&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Feb 2018 18:49:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-inside-the-files-based-on-keywords-to-do-sub-search-in/m-p/361446#M106747</guid>
      <dc:creator>cmerriman</dc:creator>
      <dc:date>2018-02-08T18:49:28Z</dc:date>
    </item>
    <item>
      <title>Re: Search inside the files based on keywords to do sub search in splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-inside-the-files-based-on-keywords-to-do-sub-search-in/m-p/361447#M106748</link>
      <description>&lt;P&gt;@rojit&lt;/P&gt;

&lt;P&gt;So let's make a different search.  We are going to build it up bit by bit.  I'm doing it this way so you will have explanations and can modify this as needed to make it work for you.&lt;/P&gt;

&lt;P&gt;First task is to build a search that returns the &lt;CODE&gt;source&lt;/CODE&gt; fields of the files that have the SQLDB string in them.  You haven't provided much context, so you'll have to fill in some parts of this.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=X sourcetype=Y SQLDB | dedup source | table source
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;You should run this and confirm it returns, in your case, &lt;CODE&gt;a1.txt&lt;/CODE&gt; and &lt;CODE&gt;a3.txt&lt;/CODE&gt;.  This must be right or else the rest of this answer won't work. &lt;/P&gt;

&lt;P&gt;Now, we'll use that little search above as a &lt;A href="http://docs.splunk.com/Documentation/Splunk/7.0.1/SearchTutorial/Useasubsearch"&gt;subsearch&lt;/A&gt; inside a bigger search.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=X sourcetype=Y (KEYWORD1 OR KEYWORD2) [search index=X sourcetype=Y SQLDB | dedup source | table source]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The only difference on the "inside" search is that we had to add &lt;CODE&gt;search&lt;/CODE&gt; to the front of it.  The way the subsearch works will be to run that little search first, and the list of &lt;CODE&gt;source&lt;/CODE&gt; will get returned to the outside search, where it'll get incorporated like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=X sourcetype=Y KEYWORD1 OR KEYWORD2 (source=a1.txt OR source=a3.txt)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;That's not one you have to type, that happens on the back end.  But that's what ends up being run so it should return anywhere those two keywords show up, but ONLY inside a1.txt or a3.txt.&lt;/P&gt;

&lt;P&gt;Does that help?&lt;/P&gt;

&lt;P&gt;Happy Splunking,&lt;BR /&gt;
Rich&lt;/P&gt;</description>
      <pubDate>Thu, 08 Feb 2018 18:56:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-inside-the-files-based-on-keywords-to-do-sub-search-in/m-p/361447#M106748</guid>
      <dc:creator>Richfez</dc:creator>
      <dc:date>2018-02-08T18:56:05Z</dc:date>
    </item>
    <item>
      <title>Re: Search inside the files based on keywords to do sub search in splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-inside-the-files-based-on-keywords-to-do-sub-search-in/m-p/361448#M106749</link>
      <description>&lt;P&gt;Thanks a lot @rich7177&lt;BR /&gt;
The approach worked for my scenario..Below is the final code I was looking for:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=X sourcetype=Y (SQLDB  OR KEYWORD1 OR KEYWORD2) [search index=X sourcetype=Y SQLDB | dedup source | table source]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 09 Feb 2018 06:41:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-inside-the-files-based-on-keywords-to-do-sub-search-in/m-p/361448#M106749</guid>
      <dc:creator>rojit</dc:creator>
      <dc:date>2018-02-09T06:41:44Z</dc:date>
    </item>
    <item>
      <title>Re: Search inside the files based on keywords to do sub search in splunk</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Search-inside-the-files-based-on-keywords-to-do-sub-search-in/m-p/361449#M106750</link>
      <description>&lt;P&gt;Final approach worked for me as follows:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=X sourcetype=Y (SQLDB  OR KEYWORD1 OR KEYWORD2) [search index=X sourcetype=Y SQLDB | dedup source | table source]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 09 Feb 2018 06:44:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Search-inside-the-files-based-on-keywords-to-do-sub-search-in/m-p/361449#M106750</guid>
      <dc:creator>rojit</dc:creator>
      <dc:date>2018-02-09T06:44:45Z</dc:date>
    </item>
  </channel>
</rss>

