<?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: Add column values based on subsearch in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-column-values-based-on-subsearch/m-p/634435#M220414</link>
    <description>&lt;P&gt;Your guess is wrong. Macro is expanded before spawning the search. So you can either use subsearch (but the other way around - run this search as a subsearch to generate set of conditions) or use the map command.&lt;/P&gt;</description>
    <pubDate>Tue, 14 Mar 2023 16:24:34 GMT</pubDate>
    <dc:creator>PickleRick</dc:creator>
    <dc:date>2023-03-14T16:24:34Z</dc:date>
    <item>
      <title>How to add column values based on subsearch?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-column-values-based-on-subsearch/m-p/634434#M220413</link>
      <description>&lt;P&gt;Hi everyone&lt;/P&gt;
&lt;P&gt;I got the following sample search that yields the table below.&lt;/P&gt;
&lt;P&gt;index=server&lt;BR /&gt;| stats avg(response_time) by server_name&lt;BR /&gt;| sort + avg(response_time)&lt;BR /&gt;| streamstats count as rank&lt;BR /&gt;| head 3&lt;/P&gt;
&lt;TABLE border="1" width="100.00064440941908%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="25%"&gt;rank&lt;/TD&gt;
&lt;TD width="25%"&gt;server_name&lt;/TD&gt;
&lt;TD width="12.5%"&gt;avg(response_time)&lt;/TD&gt;
&lt;TD width="12.5%"&gt;new_performance_metric&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%"&gt;1&lt;/TD&gt;
&lt;TD width="25%"&gt;best.server&lt;/TD&gt;
&lt;TD width="12.5%"&gt;300&lt;/TD&gt;
&lt;TD width="12.5%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%"&gt;2&lt;/TD&gt;
&lt;TD width="25%"&gt;second.best.server&lt;/TD&gt;
&lt;TD width="12.5%"&gt;350&lt;/TD&gt;
&lt;TD width="12.5%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%"&gt;3&lt;/TD&gt;
&lt;TD width="25%"&gt;third.best.server&lt;/TD&gt;
&lt;TD width="12.5%"&gt;400&lt;/TD&gt;
&lt;TD width="12.5%"&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Once I know the top servers, I want to calculate additional new_performance_metric for each of the three servers. Does anyone know how this can be done?&lt;BR /&gt;&lt;BR /&gt;Note:&lt;BR /&gt;- I can't use foreach since the metric I want to calculate involves streaming commands. Foreach does not support that.&lt;BR /&gt;- I think I can't use a subsearch since it is executed first where the top servers are not known yet.&lt;BR /&gt;- I can't precompute the new_performance_metric for all servers and then use something like a lookup since this is computationally too expensive.&lt;BR /&gt;&lt;BR /&gt;My guess is that the solution involves a macro but I couldn't figure it out yet. Many thanks in advance.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Mar 2023 16:26:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-column-values-based-on-subsearch/m-p/634434#M220413</guid>
      <dc:creator>Gabriel</dc:creator>
      <dc:date>2023-03-15T16:26:46Z</dc:date>
    </item>
    <item>
      <title>Re: Add column values based on subsearch</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-column-values-based-on-subsearch/m-p/634435#M220414</link>
      <description>&lt;P&gt;Your guess is wrong. Macro is expanded before spawning the search. So you can either use subsearch (but the other way around - run this search as a subsearch to generate set of conditions) or use the map command.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Mar 2023 16:24:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-column-values-based-on-subsearch/m-p/634435#M220414</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2023-03-14T16:24:34Z</dc:date>
    </item>
    <item>
      <title>Re: Add column values based on subsearch</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-column-values-based-on-subsearch/m-p/634452#M220423</link>
      <description>&lt;P&gt;I just tried the mapping command. It did precisely what I needed. Thanks a lot, you saved me heaps of time!&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":flexed_biceps:"&gt;💪&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Mar 2023 18:46:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-column-values-based-on-subsearch/m-p/634452#M220423</guid>
      <dc:creator>Gabriel</dc:creator>
      <dc:date>2023-03-14T18:46:14Z</dc:date>
    </item>
    <item>
      <title>Re: Add column values based on subsearch</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-column-values-based-on-subsearch/m-p/634453#M220424</link>
      <description>&lt;P&gt;Just remember that map spawns subsearches which have its own limits (in terms of returned results and execution time). It is also considered a "risky command" and as such might be restricted.&lt;/P&gt;</description>
      <pubDate>Tue, 14 Mar 2023 18:49:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-column-values-based-on-subsearch/m-p/634453#M220424</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2023-03-14T18:49:04Z</dc:date>
    </item>
    <item>
      <title>Re: Add column values based on subsearch</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-add-column-values-based-on-subsearch/m-p/634722#M220510</link>
      <description>&lt;P&gt;I testet it yesterday and it turns out our&amp;nbsp;production environment suppresses dashboards and reports that make use of the mapping command. I had to use subsearches after all. Thanks again for pointing me in the right direction, I am sure the mapping command will come in handy, at some point, even if I can't use it this time&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":nerd_face:"&gt;🤓&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 16 Mar 2023 06:55:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-add-column-values-based-on-subsearch/m-p/634722#M220510</guid>
      <dc:creator>Gabriel</dc:creator>
      <dc:date>2023-03-16T06:55:14Z</dc:date>
    </item>
  </channel>
</rss>

