<?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 How can I use a source folder as a input token? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-use-a-source-folder-as-a-input-token/m-p/270227#M81330</link>
    <description>&lt;P&gt;Hi guys! &lt;BR /&gt;
I have a bunch of test data in JSON files as my sources and they're structured in the following way: &lt;BR /&gt;
"/MyFolder/ProjectName/RunID/jsonFile" such as for example "/MyFolder/test1/47/ErrorMessages.json". &lt;BR /&gt;
I want to populate two drop down menus in my dashboards with ProjectName and RunID. &lt;BR /&gt;
So that the first drop down get populated with Project names that the user can select. I then use this selection as a token in the second drop down menu and populate it with all the runs for that project. I now have two tokens that I can use for searching. &lt;BR /&gt;
How can I best go about this? If there's a search I can do directly in Splunk to table all the project names and RunIDs this would of course be the easiest and most ideal. Otherwise I guess I'd have to start looking into creating a regEx or a lookup, but I'm not very proficient at those =p &lt;BR /&gt;
Any help is greatly appreciated! &lt;BR /&gt;
Thanks you!  &lt;/P&gt;</description>
    <pubDate>Thu, 08 Sep 2016 11:51:20 GMT</pubDate>
    <dc:creator>external_alien_</dc:creator>
    <dc:date>2016-09-08T11:51:20Z</dc:date>
    <item>
      <title>How can I use a source folder as a input token?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-use-a-source-folder-as-a-input-token/m-p/270227#M81330</link>
      <description>&lt;P&gt;Hi guys! &lt;BR /&gt;
I have a bunch of test data in JSON files as my sources and they're structured in the following way: &lt;BR /&gt;
"/MyFolder/ProjectName/RunID/jsonFile" such as for example "/MyFolder/test1/47/ErrorMessages.json". &lt;BR /&gt;
I want to populate two drop down menus in my dashboards with ProjectName and RunID. &lt;BR /&gt;
So that the first drop down get populated with Project names that the user can select. I then use this selection as a token in the second drop down menu and populate it with all the runs for that project. I now have two tokens that I can use for searching. &lt;BR /&gt;
How can I best go about this? If there's a search I can do directly in Splunk to table all the project names and RunIDs this would of course be the easiest and most ideal. Otherwise I guess I'd have to start looking into creating a regEx or a lookup, but I'm not very proficient at those =p &lt;BR /&gt;
Any help is greatly appreciated! &lt;BR /&gt;
Thanks you!  &lt;/P&gt;</description>
      <pubDate>Thu, 08 Sep 2016 11:51:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-use-a-source-folder-as-a-input-token/m-p/270227#M81330</guid>
      <dc:creator>external_alien_</dc:creator>
      <dc:date>2016-09-08T11:51:20Z</dc:date>
    </item>
    <item>
      <title>Re: How can I use a source folder as a input token?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-use-a-source-folder-as-a-input-token/m-p/270228#M81331</link>
      <description>&lt;P&gt;Since the ProjectName and RunID as part of the source/file path is something custom to your requirement, there will not be any readily available table to get you that.&lt;/P&gt;

&lt;P&gt;Once this you can try is to run a metadata/tstats search to get list of all sources (for your index/sourcetype of course) and use field extraction to get those values listed/made available for dashboard dropdowns. Following search can give you list of ProjectName adn RunID from the source:- &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| tstats count WHRE index=PutYourIndex sourcetype=PutYourSourceType by source | rex field=source "^\/[^\/]+\/(?&amp;lt;ProjectName&amp;gt;[^\/]+)\/(?&amp;lt;RunID&amp;gt;[^\/]+)" | stats count by ProjectName RunID | table ProjectName RunID
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now you can either use the search directly for the dropdown OR setup a scheduled search to write this data into a lookup file and then use the lookup file for the dropdown.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Sep 2016 18:23:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-use-a-source-folder-as-a-input-token/m-p/270228#M81331</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-09-08T18:23:26Z</dc:date>
    </item>
    <item>
      <title>Re: How can I use a source folder as a input token?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-use-a-source-folder-as-a-input-token/m-p/270229#M81332</link>
      <description>&lt;P&gt;do you want something like this?&lt;BR /&gt;
| rex field=source "\/(?P[^\/]+)\/(?P[^\/]+)\/(?P[^\/]+)"&lt;/P&gt;</description>
      <pubDate>Fri, 09 Sep 2016 07:31:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-use-a-source-folder-as-a-input-token/m-p/270229#M81332</guid>
      <dc:creator>astalv</dc:creator>
      <dc:date>2016-09-09T07:31:07Z</dc:date>
    </item>
    <item>
      <title>Re: How can I use a source folder as a input token?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-use-a-source-folder-as-a-input-token/m-p/270230#M81333</link>
      <description>&lt;P&gt;Beautiful, worked perfectly! Exactly what I needed!&lt;BR /&gt;&lt;BR /&gt;
Thank you! &lt;span class="lia-unicode-emoji" title=":grinning_face_with_big_eyes:"&gt;😃&lt;/span&gt; &lt;/P&gt;</description>
      <pubDate>Fri, 09 Sep 2016 13:37:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-use-a-source-folder-as-a-input-token/m-p/270230#M81333</guid>
      <dc:creator>external_alien_</dc:creator>
      <dc:date>2016-09-09T13:37:13Z</dc:date>
    </item>
  </channel>
</rss>

