<?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: foreach variable and search in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/foreach-variable-and-search/m-p/509607#M142441</link>
    <description>&lt;P&gt;Please forgive me.. I am green as green can be..&lt;/P&gt;&lt;P&gt;do you mean...&lt;/P&gt;&lt;P&gt;index=main&amp;nbsp;&lt;BR /&gt;[| makeresults&lt;BR /&gt;| eval customer = "OPT, ANT"&lt;BR /&gt;| eval customer = split(customer, ",")&lt;BR /&gt;| search customer]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i tried replacing the "search customer"&amp;nbsp; with just "format" neither worked.&lt;/P&gt;</description>
    <pubDate>Thu, 16 Jul 2020 20:57:24 GMT</pubDate>
    <dc:creator>raychamber</dc:creator>
    <dc:date>2020-07-16T20:57:24Z</dc:date>
    <item>
      <title>foreach variable and search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/foreach-variable-and-search/m-p/509569#M142425</link>
      <description>&lt;P&gt;I have variables that I am trying to use to get in a search with a foreach loop...&lt;/P&gt;&lt;P&gt;for example..&amp;nbsp; I have customers: a, b, c, d, e&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;---&lt;/P&gt;&lt;P&gt;|makeresults | eval customer=a,b,c,d,e |&lt;/P&gt;&lt;P&gt;foreach customer&lt;/P&gt;&lt;P&gt;&amp;nbsp; search index=main customer&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jul 2020 18:37:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/foreach-variable-and-search/m-p/509569#M142425</guid>
      <dc:creator>raychamber</dc:creator>
      <dc:date>2020-07-16T18:37:31Z</dc:date>
    </item>
    <item>
      <title>Re: foreach variable and search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/foreach-variable-and-search/m-p/509587#M142430</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;How about this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="java"&gt;index=main 
[| makeresults
 | eval customer = "a, b, c, d"
 | eval customer = split(customer, ",")
 | format]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jul 2020 20:00:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/foreach-variable-and-search/m-p/509587#M142430</guid>
      <dc:creator>isoutamo</dc:creator>
      <dc:date>2020-07-16T20:00:37Z</dc:date>
    </item>
    <item>
      <title>Re: foreach variable and search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/foreach-variable-and-search/m-p/509592#M142433</link>
      <description>&lt;P&gt;What is your question? Are you saying that query doesn't work for you? If so, what results do you get and what results are you expecting?&lt;/P&gt;&lt;P&gt;Try this alternative query.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=main [ |makeresults | eval customer=a,b,c,d,e | fields customer | format ]&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 16 Jul 2020 20:14:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/foreach-variable-and-search/m-p/509592#M142433</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-07-16T20:14:47Z</dc:date>
    </item>
    <item>
      <title>Re: foreach variable and search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/foreach-variable-and-search/m-p/509601#M142437</link>
      <description>&lt;P&gt;I get an error in the "eval" command for "customer=a,b,c"&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jul 2020 20:45:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/foreach-variable-and-search/m-p/509601#M142437</guid>
      <dc:creator>raychamber</dc:creator>
      <dc:date>2020-07-16T20:45:02Z</dc:date>
    </item>
    <item>
      <title>Re: foreach variable and search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/foreach-variable-and-search/m-p/509605#M142439</link>
      <description>&lt;P&gt;This is working, but it isn't running the search.&lt;/P&gt;&lt;P&gt;index=main [| makeresults&lt;BR /&gt;| eval customer = "OPT, ANT"&lt;BR /&gt;| eval customer = split(customer, ",")&lt;BR /&gt;| format]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but the search isn't running. I can search for OPT alone&amp;nbsp;&lt;/P&gt;&lt;P&gt;--&lt;/P&gt;&lt;P&gt;index=main OPT&lt;/P&gt;&lt;P&gt;--&lt;/P&gt;&lt;P&gt;and get results, same for ANT, but this way.. i don't get anything back.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jul 2020 20:49:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/foreach-variable-and-search/m-p/509605#M142439</guid>
      <dc:creator>raychamber</dc:creator>
      <dc:date>2020-07-16T20:49:16Z</dc:date>
    </item>
    <item>
      <title>Re: foreach variable and search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/foreach-variable-and-search/m-p/509606#M142440</link>
      <description>&lt;P&gt;You should try:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;...&lt;BR /&gt;| eval customer = "a, b, c, d"
| eval customer = split(customer, ",")&lt;BR /&gt;...&lt;/PRE&gt;</description>
      <pubDate>Thu, 16 Jul 2020 20:49:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/foreach-variable-and-search/m-p/509606#M142440</guid>
      <dc:creator>isoutamo</dc:creator>
      <dc:date>2020-07-16T20:49:51Z</dc:date>
    </item>
    <item>
      <title>Re: foreach variable and search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/foreach-variable-and-search/m-p/509607#M142441</link>
      <description>&lt;P&gt;Please forgive me.. I am green as green can be..&lt;/P&gt;&lt;P&gt;do you mean...&lt;/P&gt;&lt;P&gt;index=main&amp;nbsp;&lt;BR /&gt;[| makeresults&lt;BR /&gt;| eval customer = "OPT, ANT"&lt;BR /&gt;| eval customer = split(customer, ",")&lt;BR /&gt;| search customer]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i tried replacing the "search customer"&amp;nbsp; with just "format" neither worked.&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jul 2020 20:57:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/foreach-variable-and-search/m-p/509607#M142441</guid>
      <dc:creator>raychamber</dc:creator>
      <dc:date>2020-07-16T20:57:24Z</dc:date>
    </item>
    <item>
      <title>Re: foreach variable and search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/foreach-variable-and-search/m-p/509610#M142443</link>
      <description>&lt;P&gt;I used the same syntax as in the original question, assuming you knew how to make it work.&amp;nbsp; My mistake.&lt;/P&gt;&lt;P&gt;Try this, which builds on the suggestions made by others.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=main [ |makeresults 
  | eval customer="a,b,c,d,e" 
  | eval customer=split(customer, ",") 
  | mvexpand customer 
  | fields customer 
  | format ]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jul 2020 00:48:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/foreach-variable-and-search/m-p/509610#M142443</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-07-17T00:48:14Z</dc:date>
    </item>
    <item>
      <title>Re: foreach variable and search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/foreach-variable-and-search/m-p/509611#M142444</link>
      <description>&lt;P&gt;index=main [| makeresults&lt;BR /&gt;| eval customer = "a, b"&lt;BR /&gt;| eval customer = split(customer, ",")&lt;BR /&gt;|fields customer |format ]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;this doesn't give results...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;having the entry&amp;nbsp;&lt;/P&gt;&lt;P&gt;|eval customer = "a", "b", "c"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;gives an error&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Error in 'eval' command: Failed to parse the provided arguments. Usage: eval dest_key = expression.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I assume it can't be formatted that way.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jul 2020 21:06:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/foreach-variable-and-search/m-p/509611#M142444</guid>
      <dc:creator>raychamber</dc:creator>
      <dc:date>2020-07-16T21:06:21Z</dc:date>
    </item>
    <item>
      <title>Re: foreach variable and search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/foreach-variable-and-search/m-p/509631#M142453</link>
      <description>Yup. I got carried away with my quotation marks. Try the updated query.</description>
      <pubDate>Fri, 17 Jul 2020 00:48:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/foreach-variable-and-search/m-p/509631#M142453</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2020-07-17T00:48:39Z</dc:date>
    </item>
    <item>
      <title>Re: foreach variable and search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/foreach-variable-and-search/m-p/509791#M142489</link>
      <description>&lt;P&gt;No luck. I still get no result found, but can run a search and find them individually.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jul 2020 20:28:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/foreach-variable-and-search/m-p/509791#M142489</guid>
      <dc:creator>raychamber</dc:creator>
      <dc:date>2020-07-17T20:28:53Z</dc:date>
    </item>
    <item>
      <title>Re: foreach variable and search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/foreach-variable-and-search/m-p/509794#M142496</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;at least this was working with _internal&lt;/P&gt;&lt;LI-CODE lang="java"&gt;index=_internal 
    [| makeresults 
    | eval component = "Metrics, cached, module, startup" 
    | eval component = trim(split(component,",")) 
    | format]&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 17 Jul 2020 20:38:42 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/foreach-variable-and-search/m-p/509794#M142496</guid>
      <dc:creator>isoutamo</dc:creator>
      <dc:date>2020-07-17T20:38:42Z</dc:date>
    </item>
    <item>
      <title>Re: foreach variable and search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/foreach-variable-and-search/m-p/509800#M142503</link>
      <description>&lt;P&gt;Right.. but this breaks it for some reason..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;index=_internal&lt;BR /&gt;[| makeresults&lt;BR /&gt;| eval component = "thru, cached, module, startup"&lt;BR /&gt;| eval component = trim(split(component,","))&lt;BR /&gt;| format]&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jul 2020 21:19:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/foreach-variable-and-search/m-p/509800#M142503</guid>
      <dc:creator>raychamber</dc:creator>
      <dc:date>2020-07-17T21:19:09Z</dc:date>
    </item>
    <item>
      <title>Re: foreach variable and search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/foreach-variable-and-search/m-p/509801#M142504</link>
      <description>&lt;P&gt;For me it's still working. Of course different amount of different events, but still it's working.&lt;/P&gt;&lt;P&gt;Just tested on Darwin with 8.0.5 version.&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jul 2020 21:32:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/foreach-variable-and-search/m-p/509801#M142504</guid>
      <dc:creator>isoutamo</dc:creator>
      <dc:date>2020-07-17T21:32:13Z</dc:date>
    </item>
  </channel>
</rss>

