<?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 find index names from Splunk saved searches in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/how-to-find-index-names-from-Splunk-saved-searches/m-p/489826#M194097</link>
    <description>&lt;P&gt;tried doing the rex for index name but seems it needs more fine tuning&lt;BR /&gt;
| rex field=qualifiedSearch  "index=(?.\w+)" &lt;/P&gt;</description>
    <pubDate>Tue, 10 Mar 2020 14:41:21 GMT</pubDate>
    <dc:creator>arrangineni</dc:creator>
    <dc:date>2020-03-10T14:41:21Z</dc:date>
    <item>
      <title>how to find index names from Splunk saved searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-find-index-names-from-Splunk-saved-searches/m-p/489822#M194093</link>
      <description>&lt;P&gt;How to find the indexes that the saved searches are running against? Few of my searches are not using index names within saved searches.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Mar 2020 20:11:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-find-index-names-from-Splunk-saved-searches/m-p/489822#M194093</guid>
      <dc:creator>arrangineni</dc:creator>
      <dc:date>2020-03-09T20:11:28Z</dc:date>
    </item>
    <item>
      <title>Re: how to find index names from Splunk saved searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-find-index-names-from-Splunk-saved-searches/m-p/489823#M194094</link>
      <description>&lt;P&gt;It is EXTREMELY poor practice to search without specifying index values.   When you do, the same search will behave differently for different users and also for the same users across time (whenever your Splunk admin decides to modify &lt;CODE&gt;roles&lt;/CODE&gt;).  You can see what  &lt;EM&gt;your&lt;/EM&gt; user is searching &lt;EM&gt;now&lt;/EM&gt; like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| tstats count WHERE earliest=0 BY index
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 09 Mar 2020 22:01:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-find-index-names-from-Splunk-saved-searches/m-p/489823#M194094</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2020-03-09T22:01:02Z</dc:date>
    </item>
    <item>
      <title>Re: how to find index names from Splunk saved searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-find-index-names-from-Splunk-saved-searches/m-p/489824#M194095</link>
      <description>&lt;P&gt;Thanks for the response &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/1406"&gt;@woodcock&lt;/a&gt; what I am also looking for is to identify index names defined in the search queries of saved searches. I am using below rest call to get the qualifiedSearch field from the saved searches using REST API and trying to extract index names out of it&lt;/P&gt;

&lt;P&gt;| rest /servicesNS/-/-/saved/searches &lt;BR /&gt;
| table title, eai:acl.owner, description, eai:acl.app, qualifiedSearch, next_scheduled_time&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 04:32:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-find-index-names-from-Splunk-saved-searches/m-p/489824#M194095</guid>
      <dc:creator>arrangineni</dc:creator>
      <dc:date>2020-09-30T04:32:17Z</dc:date>
    </item>
    <item>
      <title>Re: how to find index names from Splunk saved searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-find-index-names-from-Splunk-saved-searches/m-p/489825#M194096</link>
      <description>&lt;P&gt;this is WAY harder than it seems. I believe that @cmerriman did some work on this.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Mar 2020 14:18:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-find-index-names-from-Splunk-saved-searches/m-p/489825#M194096</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2020-03-10T14:18:11Z</dc:date>
    </item>
    <item>
      <title>Re: how to find index names from Splunk saved searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-find-index-names-from-Splunk-saved-searches/m-p/489826#M194097</link>
      <description>&lt;P&gt;tried doing the rex for index name but seems it needs more fine tuning&lt;BR /&gt;
| rex field=qualifiedSearch  "index=(?.\w+)" &lt;/P&gt;</description>
      <pubDate>Tue, 10 Mar 2020 14:41:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-find-index-names-from-Splunk-saved-searches/m-p/489826#M194097</guid>
      <dc:creator>arrangineni</dc:creator>
      <dc:date>2020-03-10T14:41:21Z</dc:date>
    </item>
    <item>
      <title>Re: how to find index names from Splunk saved searches</title>
      <link>https://community.splunk.com/t5/Splunk-Search/how-to-find-index-names-from-Splunk-saved-searches/m-p/489827#M194098</link>
      <description>&lt;P&gt;Thanks @woodcock&lt;/P&gt;

&lt;P&gt;try this query: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| rest splunk_server=* /servicesNS/-/-/saved/searches f=title f=eai:acl* f=description f=qualifiedSearch f=next_scheduled_time search="eai:acl.app!=splunk_archiver" search="eai:acl.app!=splunk_app_windows_infrastructure" search="eai:acl.app!=splunk_app_aws" search="eai:acl.app!=nmon"
| table splunk_server title, eai:acl.owner, description, eai:acl.app, qualifiedSearch, next_scheduled_time | search next_scheduled_time!="" qualifiedSearch!="*index IN*"
| regex qualifiedSearch!=".*index\s*(!?)=\s*([^*]|\*\S+)" 
| regex qualifiedSearch="^\s*search "
| regex qualifiedSearch!="^\s*search\s*\[\s*\|\s*inputlookup"
| rex field=qualifiedSearch "^(?P&amp;lt;exampleQueryToDetermineIndexes&amp;gt;[^\|]+)"
|rex field=exampleQueryToDetermineIndexes max_match=0 "eventtype=(?&amp;lt;eventtype&amp;gt;[^\s]+)"
|join eventtype splunk_server type=left [|rest /services/admin/eventtypes splunk_server=* f=search f=title|table splunk_server title search|rename title as eventtype search as eventtype_def]
|eval eventtype="eventtype=".eventtype|eval exampleQueryToDetermineIndexes=if(like(exampleQueryToDetermineIndexes,"%eventtype%"),replace(exampleQueryToDetermineIndexes,eventtype,eventtype_def),exampleQueryToDetermineIndexes)
|replace *eventtype* with *eventtype_def* in exampleQueryToDetermineIndexes
| regex exampleQueryToDetermineIndexes!="\`"
| regex exampleQueryToDetermineIndexes!=".*index\s*(!?)=\s*([^*]|\*\S+)" | regex exampleQueryToDetermineIndexes!=".*tag\s*(!?)=\s*([^*]|\*\S+)" 
|where isnotnull(exampleQueryToDetermineIndexes)
|fields - eventtype eventtype_def
| rename eai:acl.owner AS owner, eai:acl.app AS Application
|stats values(*) as * by Application title
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It actually comes from &lt;A href="https://splunkbase.splunk.com/app/3796/"&gt;https://splunkbase.splunk.com/app/3796/&lt;/A&gt; , if I recall correctly - we adjusted it slightly in our environment, but I think this is the original search.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Mar 2020 18:00:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/how-to-find-index-names-from-Splunk-saved-searches/m-p/489827#M194098</guid>
      <dc:creator>cmerriman</dc:creator>
      <dc:date>2020-03-10T18:00:27Z</dc:date>
    </item>
  </channel>
</rss>

