<?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 assign &amp;quot;source&amp;quot; during a search after a conditional statement? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-to-assign-quot-source-quot-during-a-search-after-a/m-p/495187#M84473</link>
    <description>&lt;P&gt;Neither of these worked. Just to test I'm using literal text (instead of tokens) and running it in a search. The time is set for "All Time" and there were not results.&lt;/P&gt;</description>
    <pubDate>Thu, 12 Mar 2020 17:29:00 GMT</pubDate>
    <dc:creator>ricotries</dc:creator>
    <dc:date>2020-03-12T17:29:00Z</dc:date>
    <item>
      <title>How to assign "source" during a search after a conditional statement?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-assign-quot-source-quot-during-a-search-after-a/m-p/495183#M84469</link>
      <description>&lt;P&gt;I am creating a dashboard to show all Linux command line history per user and I would like to create an input where you can type the user and if it matches anything in a case statement, it assigns a value to "source" and runs the search.&lt;/P&gt;

&lt;P&gt;For example, I have two sources: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;source=/root/.bash_history 
source=/opt/splunk/.bash_history
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I have a token $acct$ which holds the user that was typed in the input. &lt;BR /&gt;
I wrote this search:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=linux sourcetype=linux_cli
| eval search_source=case($acct$ == root, "/root/.bash_history", $acct$ == splunk, "/opt/splunk/.bash_history")
| search source=search_source
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But this returns no results. How can I do this assignment during search?&lt;/P&gt;</description>
      <pubDate>Thu, 12 Mar 2020 14:56:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-assign-quot-source-quot-during-a-search-after-a/m-p/495183#M84469</guid>
      <dc:creator>ricotries</dc:creator>
      <dc:date>2020-03-12T14:56:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to assign "source" during a search after a conditional statement?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-assign-quot-source-quot-during-a-search-after-a/m-p/495184#M84470</link>
      <description>&lt;P&gt;@ricotries &lt;/P&gt;

&lt;P&gt;Can you please try this?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=linux sourcetype=linux_cli
| eval act=$acct$
| eval search_source=case(act="root", "/root/.bash_history", act="splunk", "/opt/splunk/.bash_history") 
| where source=search_source
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 12 Mar 2020 15:09:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-assign-quot-source-quot-during-a-search-after-a/m-p/495184#M84470</guid>
      <dc:creator>kamlesh_vaghela</dc:creator>
      <dc:date>2020-03-12T15:09:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to assign "source" during a search after a conditional statement?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-assign-quot-source-quot-during-a-search-after-a/m-p/495185#M84471</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=linux sourcetype=linux_cli
 | eval search_source=case("$acct$" == "root", "/root/.bash_history", "$acct$" == "splunk", "/opt/splunk/.bash_history")
 | where match(source, search_source)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;OR use match:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=linux sourcetype=linux_cli
 | eval search_source=case(match("$acct$", "root"), "/root/.bash_history", match("$acct$", "splunk"), "/opt/splunk/.bash_history")
 | where match(source, search_source)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 12 Mar 2020 15:09:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-assign-quot-source-quot-during-a-search-after-a/m-p/495185#M84471</guid>
      <dc:creator>manjunathmeti</dc:creator>
      <dc:date>2020-03-12T15:09:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to assign "source" during a search after a conditional statement?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-assign-quot-source-quot-during-a-search-after-a/m-p/495186#M84472</link>
      <description>&lt;P&gt;This did not work. It's not throwing any errors, it's just not returning anything.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Mar 2020 17:24:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-assign-quot-source-quot-during-a-search-after-a/m-p/495186#M84472</guid>
      <dc:creator>ricotries</dc:creator>
      <dc:date>2020-03-12T17:24:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to assign "source" during a search after a conditional statement?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-assign-quot-source-quot-during-a-search-after-a/m-p/495187#M84473</link>
      <description>&lt;P&gt;Neither of these worked. Just to test I'm using literal text (instead of tokens) and running it in a search. The time is set for "All Time" and there were not results.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Mar 2020 17:29:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-assign-quot-source-quot-during-a-search-after-a/m-p/495187#M84473</guid>
      <dc:creator>ricotries</dc:creator>
      <dc:date>2020-03-12T17:29:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to assign "source" during a search after a conditional statement?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-assign-quot-source-quot-during-a-search-after-a/m-p/495188#M84474</link>
      <description>&lt;P&gt;Updated answer, check now. If not working post some samples of source from your data. &lt;/P&gt;</description>
      <pubDate>Thu, 12 Mar 2020 17:39:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-assign-quot-source-quot-during-a-search-after-a/m-p/495188#M84474</guid>
      <dc:creator>manjunathmeti</dc:creator>
      <dc:date>2020-03-12T17:39:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to assign "source" during a search after a conditional statement?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-assign-quot-source-quot-during-a-search-after-a/m-p/495189#M84475</link>
      <description>&lt;P&gt;They both work if you place double quotes around the token:&lt;BR /&gt;
"$acct$" == "root"&lt;/P&gt;

&lt;P&gt;Edit your response for any one else who ends up running into this. Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 12 Mar 2020 17:50:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-assign-quot-source-quot-during-a-search-after-a/m-p/495189#M84475</guid>
      <dc:creator>ricotries</dc:creator>
      <dc:date>2020-03-12T17:50:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to assign "source" during a search after a conditional statement?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-assign-quot-source-quot-during-a-search-after-a/m-p/495190#M84476</link>
      <description>&lt;P&gt;That's great! I updated my answer. Thank you.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Mar 2020 17:54:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-assign-quot-source-quot-during-a-search-after-a/m-p/495190#M84476</guid>
      <dc:creator>manjunathmeti</dc:creator>
      <dc:date>2020-03-12T17:54:49Z</dc:date>
    </item>
  </channel>
</rss>

