<?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: dropdown and conditional field value based search in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/dropdown-and-conditional-field-value-based-search/m-p/118526#M31652</link>
    <description>&lt;P&gt;Are the source value static (have only 3 possible values as mentioned in the question?&lt;/P&gt;</description>
    <pubDate>Wed, 25 Jun 2014 01:02:02 GMT</pubDate>
    <dc:creator>somesoni2</dc:creator>
    <dc:date>2014-06-25T01:02:02Z</dc:date>
    <item>
      <title>dropdown and conditional field value based search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/dropdown-and-conditional-field-value-based-search/m-p/118523#M31649</link>
      <description>&lt;P&gt;i have view that i want to use to filter hosts by development tier (QA, STAGE, PROD).  &lt;/P&gt;

&lt;P&gt;The drop down is configured as such:&lt;/P&gt;

&lt;P&gt;&lt;INPUT type="dropdown" token="env" /&gt;&lt;BR /&gt;&lt;BR /&gt;
            &lt;CHOICE value="Dept.ProdDC.PROD"&gt;PROD&lt;/CHOICE&gt;&lt;BR /&gt;
            &lt;CHOICE value="Dept.STAGEDC.STAGE"&gt;STAGE&lt;/CHOICE&gt;&lt;BR /&gt;
            &lt;CHOICE value="Dept.DEVDC.DEV"&gt;DEV&lt;/CHOICE&gt;&lt;BR /&gt;
            &lt;DEFAULT&gt;PROD&lt;/DEFAULT&gt;&lt;BR /&gt;
&lt;/P&gt;

&lt;P&gt;The source field has different values based on environment:&lt;/P&gt;

&lt;P&gt;PRD: source= /prd/logname.log&lt;BR /&gt;
STAGE: source= /data/stage/logs/logname.log&lt;BR /&gt;
DEV: source= /home/qa_env_host/logging/logname.log&lt;/P&gt;

&lt;P&gt;I want to display results only for the relevant hosts in each tier ... so i think the right way to go is either via IF or CASE, but i'm not sure how to filter my search based on $env$ and the source field.&lt;/P&gt;

&lt;P&gt;i'm new to more complex searching in splunk and would appreciate guidance on the right way to do this.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 16:55:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/dropdown-and-conditional-field-value-based-search/m-p/118523#M31649</guid>
      <dc:creator>cfbridgewater</dc:creator>
      <dc:date>2020-09-28T16:55:11Z</dc:date>
    </item>
    <item>
      <title>Re: dropdown and conditional field value based search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/dropdown-and-conditional-field-value-based-search/m-p/118524#M31650</link>
      <description>&lt;P&gt;i've tried the following, but this only overwrites my source ... and the processing comes after the actual indexing of the results (right?):&lt;/P&gt;

&lt;P&gt;index="&lt;EM&gt;" sourcetype="delorean-jvmgc" | eval source=case($env$ == "Prod", "/prd/&lt;/EM&gt;", $env$' == "STAGE", "/data/stage/&lt;EM&gt;", $env$ == "DEV", "/home/&lt;/EM&gt;")&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jun 2014 22:36:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/dropdown-and-conditional-field-value-based-search/m-p/118524#M31650</guid>
      <dc:creator>cfbridgewater</dc:creator>
      <dc:date>2014-06-24T22:36:49Z</dc:date>
    </item>
    <item>
      <title>Re: dropdown and conditional field value based search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/dropdown-and-conditional-field-value-based-search/m-p/118525#M31651</link>
      <description>&lt;P&gt;index="" sourcetype="delorean-jvmgc" | eval source=case($env$ == "Prod", "/prd/&lt;EM&gt;", $env$' == "STAGE", "/data/stage/&lt;/EM&gt;", $env$ == "DEV", "/home/*")&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jun 2014 22:38:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/dropdown-and-conditional-field-value-based-search/m-p/118525#M31651</guid>
      <dc:creator>cfbridgewater</dc:creator>
      <dc:date>2014-06-24T22:38:32Z</dc:date>
    </item>
    <item>
      <title>Re: dropdown and conditional field value based search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/dropdown-and-conditional-field-value-based-search/m-p/118526#M31652</link>
      <description>&lt;P&gt;Are the source value static (have only 3 possible values as mentioned in the question?&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jun 2014 01:02:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/dropdown-and-conditional-field-value-based-search/m-p/118526#M31652</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2014-06-25T01:02:02Z</dc:date>
    </item>
    <item>
      <title>Re: dropdown and conditional field value based search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/dropdown-and-conditional-field-value-based-search/m-p/118527#M31653</link>
      <description>&lt;P&gt;Note that you've specified different values for the source field in your question and in your comments. My answer is based on the values you've listed in your second comment; adjust them as needed for the real search.&lt;/P&gt;

&lt;P&gt;If you change the values of the choices to be the values you want for the source field, e.g.:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;choice value="/prd/"&amp;gt;STAGE&amp;lt;/choice&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;then the following search should work:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="" sourcetype="delorean-jvmgc" source="$env$"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Alternately, add the following prefix and suffix to the input:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;  &amp;lt;prefix&amp;gt;source="&amp;lt;/prefix&amp;gt;
  &amp;lt;suffix&amp;gt;"&amp;lt;/suffix&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and simply search for:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="" sourcetype="delorean-jvmgc" $env$
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If you need to retain the original values, you could use a subsearch with your original definition (taking the source values from your second comment):&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="" sourcetype="delorean-jvmgc" [
    | gentimes start=-1
    | eval source=case("$env$" == "Dept.ProdDC.PROD", "/prd/", 
                       "$env$" == "Dept.STAGEDC.STAGE", "/data/stage/",
                       "$env$" == "Dept.DEVDC.DEV", "/home/*")
    | fields source
    ]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 25 Jun 2014 09:06:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/dropdown-and-conditional-field-value-based-search/m-p/118527#M31653</guid>
      <dc:creator>davby</dc:creator>
      <dc:date>2014-06-25T09:06:32Z</dc:date>
    </item>
    <item>
      <title>Re: dropdown and conditional field value based search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/dropdown-and-conditional-field-value-based-search/m-p/118528#M31654</link>
      <description>&lt;P&gt;that worked like a charm.  one slight edit is that index="*".  i'd like to better understand the usage of the | fields source.  is that what pipes the results of the search within the brackets to the field source?&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jun 2014 13:37:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/dropdown-and-conditional-field-value-based-search/m-p/118528#M31654</guid>
      <dc:creator>cfbridgewater</dc:creator>
      <dc:date>2014-06-25T13:37:40Z</dc:date>
    </item>
    <item>
      <title>Re: dropdown and conditional field value based search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/dropdown-and-conditional-field-value-based-search/m-p/118529#M31655</link>
      <description>&lt;P&gt;that worked like a charm.  one slight edit is that index="*".  i'd like to better understand the usage of the | fields source.  is that what pipes the results of the search within the brackets to the field source?&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jun 2014 13:38:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/dropdown-and-conditional-field-value-based-search/m-p/118529#M31655</guid>
      <dc:creator>cfbridgewater</dc:creator>
      <dc:date>2014-06-25T13:38:35Z</dc:date>
    </item>
    <item>
      <title>Re: dropdown and conditional field value based search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/dropdown-and-conditional-field-value-based-search/m-p/118530#M31656</link>
      <description>&lt;P&gt;If you are searching every index, you can drop index="*" entirely.&lt;/P&gt;

&lt;P&gt;Brackets indicate a subsearch. The subsearch generates terms that are inserted into the outer search. You can see exactly what terms by running the subsearch alone (no brackets), and appending "| format" to the end. Look for the "search" column in the results.&lt;/P&gt;

&lt;P&gt;There's more to it than that, of course. Section "Group and Correlate Events" in the search manual has more details.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jun 2014 13:58:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/dropdown-and-conditional-field-value-based-search/m-p/118530#M31656</guid>
      <dc:creator>davby</dc:creator>
      <dc:date>2014-06-25T13:58:35Z</dc:date>
    </item>
    <item>
      <title>Re: dropdown and conditional field value based search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/dropdown-and-conditional-field-value-based-search/m-p/562502#M195627</link>
      <description>&lt;P&gt;I came across this answer with a similar situation to solve.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Situation:&lt;/STRONG&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;I created a dropdown with different deployment environments as values, source code like below:&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;lt;input type="dropdown" token="deploy_env" searchWhenChanged="true"&amp;gt;&lt;BR /&gt;&amp;lt;label&amp;gt;Deployment Environment&amp;lt;/label&amp;gt;&lt;BR /&gt;&amp;lt;choice value="nonprod"&amp;gt;Non Production&amp;lt;/choice&amp;gt;&lt;BR /&gt;&amp;lt;choice value="prod"&amp;gt;Production&amp;lt;/choice&amp;gt;&lt;BR /&gt;&amp;lt;default&amp;gt;nonprod&amp;lt;/default&amp;gt;&lt;BR /&gt;&amp;lt;/input&amp;gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;I need to query below, namely to have &lt;STRONG&gt;space_name&lt;/STRONG&gt; and &lt;STRONG&gt;app_name&lt;/STRONG&gt; value depend on &lt;STRONG&gt;$delpy_env$&lt;/STRONG&gt;:&amp;nbsp; &amp;nbsp;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;index=$deploy_env$ org_name="my_org_name" space_name="spacename_based_on_$deploy_env$" app_name="appname_based_on_$deploy_env$" message_type=OUT | search "Qr Pdf sent to" | stats count&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Based on answers from this topic, I came up with below solution:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;index=$deploy_env$org_name="my_org_name" message_type=OUT&lt;BR /&gt;| &lt;FONT color="#0000FF"&gt;eval&lt;/FONT&gt; space_name=case("$deploy_env$" == "nonprod", "spacename-dev", "$deploy_env$" == "spacename-prod", "prod")&lt;BR /&gt;| &lt;FONT color="#0000FF"&gt;eval&lt;/FONT&gt;&amp;nbsp;app_name=case("$deploy_env$" == "nonprod", "serviceappname-dev", "$deploy_env$" == "prod", "serviceappname-prod")&lt;BR /&gt;| search "Qr Pdf sent to" | stats Count&lt;/P&gt;&lt;P&gt;Could anyone check if the solution is correct please and if there are better ways to solve this issue? Thank you.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 08 Aug 2021 00:07:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/dropdown-and-conditional-field-value-based-search/m-p/562502#M195627</guid>
      <dc:creator>Wendy</dc:creator>
      <dc:date>2021-08-08T00:07:38Z</dc:date>
    </item>
  </channel>
</rss>

