<?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: search in foreach subquery in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/search-in-foreach-subquery/m-p/569952#M198657</link>
    <description>&lt;P&gt;This&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index="visited" | eval cat_item = category."/".item  | timechart dc(cat_item) &lt;/LI-CODE&gt;&lt;P&gt;does not give you a column for each cat_item as you seem to be suggesting - it gives you a count of distinct cat_items for each time period.&lt;/P&gt;</description>
    <pubDate>Wed, 06 Oct 2021 20:33:31 GMT</pubDate>
    <dc:creator>ITWhisperer</dc:creator>
    <dc:date>2021-10-06T20:33:31Z</dc:date>
    <item>
      <title>search in foreach subquery</title>
      <link>https://community.splunk.com/t5/Splunk-Search/search-in-foreach-subquery/m-p/569949#M198655</link>
      <description>&lt;P&gt;I have items visit log index with fields: category, item each event is a visit&lt;/P&gt;&lt;P&gt;In addition, I have an index with all items in the system in form category, items_count&lt;/P&gt;&lt;P&gt;I want to create a timechart of categories: &amp;lt;category&amp;gt; -&amp;gt; &amp;lt;visited items&amp;gt;/&amp;lt;all items&amp;gt; other time&lt;/P&gt;&lt;P&gt;What I did:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index="visited" | eval cat_item = category."/".item  | timechart dc(cat_item) by category  | foreach * [ search index="cat" category="&amp;lt;&amp;lt;FIELD? &amp;gt;&amp;gt;"  | eval &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;= '&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'/items_count ]&lt;/LI-CODE&gt;&lt;P&gt;But this does not work&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;timechart here creates a table with categories as columns and, each row contains the count of visited items&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Now the problem is how I get column name, and value in the subquery. In the examples, the &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt; is used for the column name and column value alike.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Please help&lt;/SPAN&gt;&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;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Oct 2021 20:55:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/search-in-foreach-subquery/m-p/569949#M198655</guid>
      <dc:creator>dmitrymi</dc:creator>
      <dc:date>2021-10-06T20:55:32Z</dc:date>
    </item>
    <item>
      <title>Re: search in foreach subquery</title>
      <link>https://community.splunk.com/t5/Splunk-Search/search-in-foreach-subquery/m-p/569951#M198656</link>
      <description>&lt;P&gt;Are you sure your problem is with fieldnames? I'd say it's with the subsearch itself.&lt;/P&gt;&lt;P&gt;As per the docs, foreach runs a streaming subsearch for each field. But your subsearch starts with the search command which is a generating one.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Oct 2021 20:28:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/search-in-foreach-subquery/m-p/569951#M198656</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2021-10-06T20:28:45Z</dc:date>
    </item>
    <item>
      <title>Re: search in foreach subquery</title>
      <link>https://community.splunk.com/t5/Splunk-Search/search-in-foreach-subquery/m-p/569952#M198657</link>
      <description>&lt;P&gt;This&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index="visited" | eval cat_item = category."/".item  | timechart dc(cat_item) &lt;/LI-CODE&gt;&lt;P&gt;does not give you a column for each cat_item as you seem to be suggesting - it gives you a count of distinct cat_items for each time period.&lt;/P&gt;</description>
      <pubDate>Wed, 06 Oct 2021 20:33:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/search-in-foreach-subquery/m-p/569952#M198657</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-10-06T20:33:31Z</dc:date>
    </item>
    <item>
      <title>Re: search in foreach subquery</title>
      <link>https://community.splunk.com/t5/Splunk-Search/search-in-foreach-subquery/m-p/569954#M198658</link>
      <description>&lt;P&gt;I'm not sure, what is the right way to do it? How to select a value for each column using the column name,&amp;nbsp; and update cell value using this&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Oct 2021 20:35:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/search-in-foreach-subquery/m-p/569954#M198658</guid>
      <dc:creator>dmitrymi</dc:creator>
      <dc:date>2021-10-06T20:35:34Z</dc:date>
    </item>
    <item>
      <title>Re: search in foreach subquery</title>
      <link>https://community.splunk.com/t5/Splunk-Search/search-in-foreach-subquery/m-p/569956#M198660</link>
      <description>&lt;P&gt;Sorry my mistake this is actually:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index="visited" | eval cat_item = category."/".item  | timechart dc(cat_item) by category&lt;/LI-CODE&gt;&lt;P&gt;but still not working.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Without foreach the query returns number of items visited by category over time&lt;/P&gt;</description>
      <pubDate>Wed, 06 Oct 2021 20:49:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/search-in-foreach-subquery/m-p/569956#M198660</guid>
      <dc:creator>dmitrymi</dc:creator>
      <dc:date>2021-10-06T20:49:15Z</dc:date>
    </item>
    <item>
      <title>Re: search in foreach subquery</title>
      <link>https://community.splunk.com/t5/Splunk-Search/search-in-foreach-subquery/m-p/570025#M198684</link>
      <description>&lt;P&gt;If you really need a dynamicaly constructed search, try the map command. But I'd rather do a groupped stat (i.e. count by)&lt;/P&gt;</description>
      <pubDate>Thu, 07 Oct 2021 10:25:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/search-in-foreach-subquery/m-p/570025#M198684</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2021-10-07T10:25:25Z</dc:date>
    </item>
  </channel>
</rss>

