<?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 search a splunk search result? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-a-splunk-search-result/m-p/591780#M205985</link>
    <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;As a side note - with simple searches, splunk can sometimes optimize the search in some obvious cases. So&lt;/P&gt;&lt;PRE&gt;search | search a=b&lt;/PRE&gt;&lt;P&gt;will get optimized to&lt;/P&gt;&lt;PRE&gt;search a=b&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;But of course I wuldn't rely on it and writing efficient searches is a good practice that should be followed.&lt;/P&gt;</description>
    <pubDate>Thu, 31 Mar 2022 13:41:51 GMT</pubDate>
    <dc:creator>PickleRick</dc:creator>
    <dc:date>2022-03-31T13:41:51Z</dc:date>
    <item>
      <title>How to search a splunk search result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-a-splunk-search-result/m-p/591379#M205867</link>
      <description>&lt;P&gt;I have a macro named X that uses the lookup in the search and produces the results as follows&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;indexes 

index IN ("ABC","DEF")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;where as indexes is column name&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I want to use the macro X result (index IN ("ABC","DEF")) in a separate search as follows&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;my_search | where `X`

which should execute as below 

my_search | where index IN ("ABC","DEF")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now how can I achieve that?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Mar 2022 03:39:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-a-splunk-search-result/m-p/591379#M205867</guid>
      <dc:creator>pavanae</dc:creator>
      <dc:date>2022-03-30T03:39:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to search a splunk search result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-a-splunk-search-result/m-p/591412#M205884</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/79709"&gt;@pavanae&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;let me understand:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;you have a lookup containing a list of indexes,&lt;/LI&gt;&lt;LI&gt;you want to use this list of indexes in a search,&lt;/LI&gt;&lt;LI&gt;you whould use a macro,&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;is it correct?&lt;/P&gt;&lt;P&gt;At first, if you have a macro, you don't need to use a lookup, in your macro, you could insert the list of indexes to search, also because I suppose that they aren't so many, otherwise I hint to re-design your indexes structure!&lt;/P&gt;&lt;P&gt;This is e.g. the approach of Enterprise Security DataModels: in each datamodel there's a macro called "datamodel_name_indexes" and in this macro there a command like your:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index IN (index1, index2)&lt;/LI-CODE&gt;&lt;P&gt;But, anyway, if you would use a lookup, you don't need a macro, you could use a subsearch:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;your_search [ | inputlookup indexes.csv | fields index ]
| ...&lt;/LI-CODE&gt;&lt;P&gt;At least, if you want to use in any case a macro, you could create a macro containing the above subsearch and use the macro in your search.&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Wed, 30 Mar 2022 07:01:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-a-splunk-search-result/m-p/591412#M205884</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2022-03-30T07:01:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to search a splunk search result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-a-splunk-search-result/m-p/591652#M205961</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;&amp;nbsp;for the quick response. Apologies for the confusion. To your question :- No, My macro contains nothing but the lookup and some filtering which produces the results as follows&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;indexes 

index IN ("ABC","DEF")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;Now I wanted to use the macro's results as a subsearch. Now, I cannot use the lookup directly as I have too many indexes. All I wanted to take into account for the subsearch is just as below&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index IN ("ABC","DEF")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but for now as I have a column name as indexes I am getting the subsearch as below which ending up with an error&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;indexes=index IN ("ABC","DEF")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now, is there any way to tweak my subsearch or macro take the below into account which will work?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index IN ("ABC","DEF")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Where as my full search would be something like below after expanding the macro&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;My_Search | where index IN ("ABC","DEF")&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 31 Mar 2022 02:37:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-a-splunk-search-result/m-p/591652#M205961</guid>
      <dc:creator>pavanae</dc:creator>
      <dc:date>2022-03-31T02:37:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to search a splunk search result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-a-splunk-search-result/m-p/591657#M205965</link>
      <description>&lt;P&gt;You have three issues here.&lt;/P&gt;&lt;P&gt;One is a macro. Macro is a relatively simple string substitution. It's being evaluated before running the search so you expand it in search bar with some key combination (ctrl-shift-e?)&lt;/P&gt;&lt;P&gt;Second one is the contents of this macro which can be anything - even something syntactically incorrect - in such case the macro would get expanded but your resulting search would throw an error. It can have a subsearch running a inputlookup and some processing - no problem here.&lt;/P&gt;&lt;P&gt;Third one is the syntax of the subsearch results. By default the subsearch results get formatted in some particular way (an alternative of various returned field combinations). If you want it returned other way, you have to prepare the resulting text and use return to return a raw output as you want it.&lt;/P&gt;&lt;P&gt;And finally I'm not 100% sure you can use a IN (b,c) syntax with where. You can do this with search but I'm not sure about where.&lt;/P&gt;</description>
      <pubDate>Thu, 31 Mar 2022 04:18:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-a-splunk-search-result/m-p/591657#M205965</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2022-03-31T04:18:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to search a splunk search result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-a-splunk-search-result/m-p/591663#M205967</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Does anyone happens to know , how can we&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;restrict&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;users from export data via&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;RestAPI, CLI ?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;would appreciate&amp;nbsp;splunk documentation .&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Mar 2022 04:48:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-a-splunk-search-result/m-p/591663#M205967</guid>
      <dc:creator>human96</dc:creator>
      <dc:date>2022-03-31T04:48:24Z</dc:date>
    </item>
    <item>
      <title>Re: How to search a splunk search result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-a-splunk-search-result/m-p/591750#M205983</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/79709"&gt;@pavanae&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;the last solution isn't a good idea because it's a best practice to putt all the search terme as left as possible and use the search command only if you have somthing to elaborate, if you have a field in the main search is always better to put all the search terms in the main search.&lt;/P&gt;&lt;P&gt;Anyway, if you have many indexes (and I don't like this!) you can put them in a lookup and use a subsearch, as I hinted in my last answer:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;your_search [ | inputlookup indexes.csv | fields index ]
| ...&lt;/LI-CODE&gt;&lt;P&gt;I don't understand why you don't want this solution!|&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Thu, 31 Mar 2022 12:10:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-a-splunk-search-result/m-p/591750#M205983</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2022-03-31T12:10:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to search a splunk search result?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-search-a-splunk-search-result/m-p/591780#M205985</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;As a side note - with simple searches, splunk can sometimes optimize the search in some obvious cases. So&lt;/P&gt;&lt;PRE&gt;search | search a=b&lt;/PRE&gt;&lt;P&gt;will get optimized to&lt;/P&gt;&lt;PRE&gt;search a=b&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;But of course I wuldn't rely on it and writing efficient searches is a good practice that should be followed.&lt;/P&gt;</description>
      <pubDate>Thu, 31 Mar 2022 13:41:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-search-a-splunk-search-result/m-p/591780#M205985</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2022-03-31T13:41:51Z</dc:date>
    </item>
  </channel>
</rss>

