<?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: Use 2 related tokens to create as 2 conditions in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-two-related-tokens-to-create-as-two-conditions/m-p/643254#M222825</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;Thank you very much for all the suggestion.&lt;/P&gt;&lt;P&gt;I find the way to fix my problem.&lt;/P&gt;&lt;P&gt;I can't find the solution without your help, and I am truly grateful.&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
    <pubDate>Fri, 12 May 2023 21:21:24 GMT</pubDate>
    <dc:creator>Jouman</dc:creator>
    <dc:date>2023-05-12T21:21:24Z</dc:date>
    <item>
      <title>How to use two related tokens to create as two conditions?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-two-related-tokens-to-create-as-two-conditions/m-p/642789#M222635</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;I need to provide 2 fitlers, one for item_id and the other one for item_folder_name.&lt;/P&gt;
&lt;P&gt;The user will enter item_folder_name for filter_1 first.&lt;BR /&gt;If the items under item_folder_name aren't suitable to analyze, once the user know it and he will input item_id as well. The 2 filters can restrict the item that I need to analyze.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Currently, I write as below. However, I need to allow the item_id that is not under the filtered item_folder_name. The code can't allow a item_id which is not under the specified item_folder_name.&lt;/P&gt;
&lt;P&gt;Is there any way to allow the filter for item_id seperated from the filter for item_folder_name ?&lt;BR /&gt;I want to allow the user to enter item_id filter, and provide the filter of item_folder_name&amp;nbsp; to search the item_id inside within 6 months as well.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;(item_id=$tkn.item_id$)
[ | search index=my_index sourcetype="md:sv:master" _index_earliest="01/01/2023:00:00:00" _index_latest=now()
   | inputlookup item_table.csv item_id OUTPUT item_folder_name
   | where ($tkn.item_folder_name$)
   | fields + item_id]&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Wed, 10 May 2023 17:02:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-two-related-tokens-to-create-as-two-conditions/m-p/642789#M222635</guid>
      <dc:creator>Jouman</dc:creator>
      <dc:date>2023-05-10T17:02:46Z</dc:date>
    </item>
    <item>
      <title>Re: Use 2 related tokens to create as 2 conditions</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-two-related-tokens-to-create-as-two-conditions/m-p/642797#M222637</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/248164"&gt;@Jouman&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Your search isn't so clear for me: what's the main search?&lt;/P&gt;&lt;P&gt;it seems tha the main search is (item_id=$tkn.item_id$) and the content od the square parenthesis is a subsearch in the main search.&lt;/P&gt;&lt;P&gt;Anyway, you have to create two dropdown list inputs, where the second (&lt;SPAN&gt;item_id)&amp;nbsp;&lt;/SPAN&gt;contains also the token of the first (&lt;SPAN&gt;item_folder_name) so you can filter the second based on the value of the first&lt;/SPAN&gt;,&lt;/P&gt;&lt;P&gt;Then I suppose that you extract the &lt;SPAN&gt;item_folder_name from the search results, in this way, your search is slower but you're sure to have only values with results in the events.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If you're using a Simple XML dashboard, could you share your complete dashboard code?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Ciao.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Giuseppe&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 10 May 2023 10:49:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-two-related-tokens-to-create-as-two-conditions/m-p/642797#M222637</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2023-05-10T10:49:14Z</dc:date>
    </item>
    <item>
      <title>Re: Use 2 related tokens to create as 2 conditions</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-two-related-tokens-to-create-as-two-conditions/m-p/642938#M222686</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;&lt;BR /&gt;Thank you for the suggestion. I rewrite my requests as below with xml code.&lt;BR /&gt;&lt;BR /&gt;Here is the panel contained a filter to select FolderName.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;panel&amp;gt;
      &amp;lt;title&amp;gt;Find Items in one folder&amp;lt;/title&amp;gt;
      &amp;lt;input type="text" token="tkn.foldername$" searchWhenChanged="true"&amp;gt;
        &amp;lt;label&amp;gt;Step 1: Input your folder&amp;lt;/label&amp;gt;
        &amp;lt;prefix&amp;gt;FolderName like "&amp;lt;/prefix&amp;gt;
        &amp;lt;suffix&amp;gt;"&amp;lt;/suffix&amp;gt;
        &amp;lt;default&amp;gt;FOLDER_ONE&amp;lt;/default&amp;gt;
        &amp;lt;initialValue&amp;gt;FOLDER_ONE&amp;lt;/initialValue&amp;gt;
      &amp;lt;/input&amp;gt;
      &amp;lt;table&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt; 
          my search... 
         &amp;lt;/query&amp;gt;
    &amp;lt;/panel&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Here is the panel included included another token to restrict ItemID and the main search.&lt;BR /&gt;I hope to restrict the input ItemID in main search and the source will be (1) input ItemID (2) input&amp;nbsp;FolderName then know what's the ItemID included.&lt;BR /&gt;However, by below code, if the ItemID from user input is not under FolderName, the will be no results.&lt;/P&gt;&lt;P&gt;Is there any way to accept both (1) input ItemID under arbitrary folder , and (2) input&amp;nbsp;FolderName&amp;nbsp; as the input for my main search ?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt; &amp;lt;panel&amp;gt;
      &amp;lt;title&amp;gt;Test_Case_1&amp;lt;/title&amp;gt;
      &amp;lt;input type="text" token="tkn.itemid" searchWhenChanged="true"&amp;gt;
        &amp;lt;label&amp;gt;Step 2: Input the ItemID&amp;lt;/label&amp;gt;
        &amp;lt;default&amp;gt;503&amp;lt;/default&amp;gt;
      &amp;lt;/input&amp;gt;
      &amp;lt;table&amp;gt;
        &amp;lt;title&amp;gt;Test_Case_1_part1&amp;lt;/title&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;(ItemID=$tkn.itemid$) AND (index=my_item_name_index item_name="ABC" OR item_name="XYZ")
    [| search index=my_item_id_index _index_earliest="01/01/2023:00:00:00" _index_latest=now()
    | lookup table.csv.gz ItemID OUTPUT FolderName
    | where ($tkn.foldername$) 
    | fields + ItemID
    ]
| eval stage=case(item_name="ABC", "stage_1", item_name="XYZ", "stage_2", true(), NULL)
| eval stage_index=case(isnotnull(stage), item_index)
| eval start_index=if(match(stage,"stage_1"), item_index, NULL) 
| sort 0 + ItemID item_index 
| streamstats reset_before="("stage=\"stage_1\"")" first(start_index) as session_index by ItemID 
| eval Session_ID = ItemID+"-"+session_index 

| chart limit=0 sep=_ list(item_index) as Stage_Index, first(_time) as Stage_Time over Session_ID by stage &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much.&lt;/P&gt;</description>
      <pubDate>Thu, 11 May 2023 02:54:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-two-related-tokens-to-create-as-two-conditions/m-p/642938#M222686</guid>
      <dc:creator>Jouman</dc:creator>
      <dc:date>2023-05-11T02:54:16Z</dc:date>
    </item>
    <item>
      <title>Re: Use 2 related tokens to create as 2 conditions</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-two-related-tokens-to-create-as-two-conditions/m-p/642970#M222706</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/248164"&gt;@Jouman&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;in other words, you wouyld add the first token to the second code, if this is your requirement, you could try:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt; &amp;lt;panel&amp;gt;
      &amp;lt;title&amp;gt;Test_Case_1&amp;lt;/title&amp;gt;
      &amp;lt;input type="dropdown" token="tkn_foldername" searchWhenChanged="true"&amp;gt;
        &amp;lt;label&amp;gt;Step 1: Input your folder&amp;lt;/label&amp;gt;
        &amp;lt;prefix&amp;gt;FolderName="&amp;lt;/prefix&amp;gt;
        &amp;lt;suffix&amp;gt;"&amp;lt;/suffix&amp;gt;
        &amp;lt;fieldForLabel&amp;gt;FolderName&amp;lt;/fieldForLabel&amp;gt;
        &amp;lt;fieldForValue&amp;gt;FolderName&amp;lt;/fieldForValue&amp;gt;
        &amp;lt;default&amp;gt;FOLDER_ONE&amp;lt;/default&amp;gt;
        &amp;lt;initialValue&amp;gt;FOLDER_ONE&amp;lt;/initialValue&amp;gt;
        &amp;lt;search&amp;gt;
           &amp;lt;query&amp;gt;
              | inputlookup table.csv.gz 
              | fields FolderName
              | sort FolderName
              | table FolderName
           &amp;lt;/query&amp;gt;
        &amp;lt;/search&amp;gt;
      &amp;lt;/input&amp;gt;
      &amp;lt;input type="dropdown" token="tkn_itemid" searchWhenChanged="true"&amp;gt;
        &amp;lt;label&amp;gt;Step 2: Input the ItemID&amp;lt;/label&amp;gt;
        &amp;lt;default&amp;gt;503&amp;lt;/default&amp;gt;
        &amp;lt;prefix&amp;gt;itemId="&amp;lt;/prefix&amp;gt;
        &amp;lt;suffix&amp;gt;"&amp;lt;/suffix&amp;gt;
        &amp;lt;fieldForLabel&amp;gt;ItemID&amp;lt;/fieldForLabel&amp;gt;
        &amp;lt;fieldForValue&amp;gt;ItemID&amp;lt;/fieldForValue&amp;gt;
        &amp;lt;search&amp;gt;
           &amp;lt;query&amp;gt;
              | inputlookup table.csv.gz WHERE $tkn_foldername$
              | fields ItemID
              | sort ItemID
              | table ItemID
           &amp;lt;/query&amp;gt;
        &amp;lt;/search&amp;gt;
      &amp;lt;/input&amp;gt;
      &amp;lt;table&amp;gt;
        &amp;lt;title&amp;gt;Test_Case_1_part1&amp;lt;/title&amp;gt;
        &amp;lt;search&amp;gt;
          &amp;lt;query&amp;gt;
             (ItemID=$tkn_itemid$) (index=my_item_name_index item_name="ABC" OR item_name="XYZ")
             [| search index=my_item_id_index _index_earliest="01/01/2023:00:00:00" _index_latest=now()
             | lookup table.csv.gz ItemID OUTPUT FolderName
             | search ($tkn_foldername$) 
             | fields ItemID ]
             | eval stage=case(item_name="ABC", "stage_1", item_name="XYZ", "stage_2", true(), NULL)
             | eval stage_index=case(isnotnull(stage), item_index)
             | eval start_index=if(match(stage,"stage_1"), item_index, NULL) 
             | sort 0 + ItemID item_index 
             | streamstats reset_before="("stage=\"stage_1\"")" first(start_index) as session_index by ItemID 
             | eval Session_ID = ItemID+"-"+session_index 
             | chart limit=0 sep=_ list(item_index) as Stage_Index, first(_time) as Stage_Time over Session_ID by stage&lt;/LI-CODE&gt;&lt;P&gt;But in your search there are some thing not correct:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;in the folder input the like you used it isn't correct,&lt;/LI&gt;&lt;LI&gt;you could take values from the lookup instead using a text box,&lt;/LI&gt;&lt;LI&gt;you cannot put "$" in the token name,&lt;/LI&gt;&lt;LI&gt;you don't need to use AND operator in the main search,&lt;/LI&gt;&lt;LI&gt;in the tokens, don't use dot, but underscore,&lt;/LI&gt;&lt;LI&gt;at least I don't enter in the search logic, but using a so large time period in a subsearch ("always"!), probably you'll have more than 50,000, but this is the limit for subsearches, so probably you'll have a partial result and surely you'll not have a performant search;&lt;/LI&gt;&lt;LI&gt;when you have to compare results from a search with the always results (or a very large time period), it's better to create a scheduled search that every night saves the results of your search in a summary index, so you can use this summary index to compare your results with all time.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;In conclusion, review your search, before approach the input phase.&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Thu, 11 May 2023 07:10:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-two-related-tokens-to-create-as-two-conditions/m-p/642970#M222706</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2023-05-11T07:10:54Z</dc:date>
    </item>
    <item>
      <title>Re: Use 2 related tokens to create as 2 conditions</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-two-related-tokens-to-create-as-two-conditions/m-p/643154#M222797</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Thanks for the several correction.&lt;/P&gt;&lt;P&gt;I didn't know it is bad to use dot in the token, thanks for the comments.&lt;/P&gt;&lt;P&gt;I really appreciate the solution you provided and I have one question about it.&lt;/P&gt;&lt;P&gt;The ItemID from the filter may not be located under the FolderName from the other filter.&lt;/P&gt;&lt;P&gt;Is there any way to allow the ItemID from arbitrary folder and the ItemID included under the specified folder name as well in the main search ?&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;           &amp;lt;query&amp;gt;
              | inputlookup table.csv.gz WHERE $tkn_foldername$
              | fields ItemID
              | sort ItemID
              | table ItemID
           &amp;lt;/query&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for all the advice.&lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2023 07:00:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-two-related-tokens-to-create-as-two-conditions/m-p/643154#M222797</guid>
      <dc:creator>Jouman</dc:creator>
      <dc:date>2023-05-12T07:00:57Z</dc:date>
    </item>
    <item>
      <title>Re: Use 2 related tokens to create as 2 conditions</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-two-related-tokens-to-create-as-two-conditions/m-p/643158#M222799</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/248164"&gt;@Jouman&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;inert in the choices of the folder dropdown also the static option "All" (*) so you'll list the itemIDs of all the folders.&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2023 07:20:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-two-related-tokens-to-create-as-two-conditions/m-p/643158#M222799</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2023-05-12T07:20:10Z</dc:date>
    </item>
    <item>
      <title>Re: Use 2 related tokens to create as 2 conditions</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-use-two-related-tokens-to-create-as-two-conditions/m-p/643254#M222825</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;Thank you very much for all the suggestion.&lt;/P&gt;&lt;P&gt;I find the way to fix my problem.&lt;/P&gt;&lt;P&gt;I can't find the solution without your help, and I am truly grateful.&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Fri, 12 May 2023 21:21:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-use-two-related-tokens-to-create-as-two-conditions/m-p/643254#M222825</guid>
      <dc:creator>Jouman</dc:creator>
      <dc:date>2023-05-12T21:21:24Z</dc:date>
    </item>
  </channel>
</rss>

