<?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 the results of subsearch to rename those results with other name in new search in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Use-the-results-of-subsearch-to-rename-those-results-with-other/m-p/603117#M209892</link>
    <description>&lt;LI-CODE lang="markup"&gt;&amp;lt;search index 1&amp;gt;
| table input active idle
| untable input state TEST
| append
    [search &amp;lt;index 2&amp;gt;
    | table input TEST pwr]
| stats values(state) as state values(pwr) as pwr by input TEST
| fields - TEST
| rename state as TEST&lt;/LI-CODE&gt;</description>
    <pubDate>Fri, 24 Jun 2022 06:53:54 GMT</pubDate>
    <dc:creator>ITWhisperer</dc:creator>
    <dc:date>2022-06-24T06:53:54Z</dc:date>
    <item>
      <title>Use the results of subsearch to rename those results with other name in new search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Use-the-results-of-subsearch-to-rename-those-results-with-other/m-p/603104#M209889</link>
      <description>&lt;P&gt;Hi&amp;nbsp; All,&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I have this data in index 1&amp;nbsp;&lt;/P&gt;&lt;TABLE width="192"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="64"&gt;input&lt;/TD&gt;&lt;TD width="64"&gt;active&amp;nbsp;&lt;/TD&gt;&lt;TD width="64"&gt;Idle&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;a&lt;/TD&gt;&lt;TD&gt;d&lt;/TD&gt;&lt;TD&gt;g&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;b&lt;/TD&gt;&lt;TD&gt;e&lt;/TD&gt;&lt;TD&gt;h&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;c&lt;/TD&gt;&lt;TD&gt;f&lt;/TD&gt;&lt;TD&gt;i&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&lt;BR /&gt;I have this&amp;nbsp; data in index 2&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;TABLE border="0" width="192" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="64" height="20"&gt;input&lt;/TD&gt;&lt;TD width="64"&gt;TEST&lt;/TD&gt;&lt;TD width="64"&gt;pwr&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="20"&gt;a&lt;/TD&gt;&lt;TD&gt;d&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="20"&gt;b&lt;/TD&gt;&lt;TD&gt;e&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="20"&gt;c&lt;/TD&gt;&lt;TD&gt;f&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="20"&gt;a&lt;/TD&gt;&lt;TD&gt;g&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="20"&gt;b&lt;/TD&gt;&lt;TD&gt;h&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="20"&gt;c&lt;/TD&gt;&lt;TD&gt;i&lt;/TD&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now&amp;nbsp; i want to change these d , e, f&amp;nbsp; &amp;nbsp;to active&amp;nbsp; and&amp;nbsp; g, h, i&amp;nbsp; to idle&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;so my data in index looks like this&lt;/P&gt;&lt;TABLE border="0" width="192" cellspacing="0" cellpadding="0"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD width="64" height="20"&gt;input&lt;/TD&gt;&lt;TD width="64"&gt;TEST&lt;/TD&gt;&lt;TD width="64"&gt;pwr&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="20"&gt;a&lt;/TD&gt;&lt;TD&gt;active&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="20"&gt;b&lt;/TD&gt;&lt;TD&gt;active&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="20"&gt;c&lt;/TD&gt;&lt;TD&gt;active&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="20"&gt;a&lt;/TD&gt;&lt;TD&gt;idle&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="20"&gt;b&lt;/TD&gt;&lt;TD&gt;idle&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD height="20"&gt;c&lt;/TD&gt;&lt;TD&gt;idle&lt;/TD&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and then i want to run my final search.&lt;BR /&gt;I tried sub searches and all, but&amp;nbsp; unable to do this.&lt;BR /&gt;&lt;BR /&gt;I have given&amp;nbsp; small example&amp;nbsp; there are 100s of active and idle entries&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jun 2022 05:33:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Use-the-results-of-subsearch-to-rename-those-results-with-other/m-p/603104#M209889</guid>
      <dc:creator>paritoshs24</dc:creator>
      <dc:date>2022-06-24T05:33:41Z</dc:date>
    </item>
    <item>
      <title>Re: Use the results of subsearch to rename those results with other name in new search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Use-the-results-of-subsearch-to-rename-those-results-with-other/m-p/603117#M209892</link>
      <description>&lt;LI-CODE lang="markup"&gt;&amp;lt;search index 1&amp;gt;
| table input active idle
| untable input state TEST
| append
    [search &amp;lt;index 2&amp;gt;
    | table input TEST pwr]
| stats values(state) as state values(pwr) as pwr by input TEST
| fields - TEST
| rename state as TEST&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 24 Jun 2022 06:53:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Use-the-results-of-subsearch-to-rename-those-results-with-other/m-p/603117#M209892</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-06-24T06:53:54Z</dc:date>
    </item>
    <item>
      <title>Re: Use the results of subsearch to rename those results with other name in new search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Use-the-results-of-subsearch-to-rename-those-results-with-other/m-p/603119#M209894</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/242604"&gt;@paritoshs24&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;if the results of the first query is fixed or doesn't change frequently, you could save them in a lookup and use the lookup command to change the values of the second query, this is the best and easiest solution.&lt;/P&gt;&lt;P&gt;Otherwise if they are dynamic you could use the join command but I don't like it or group results using stats, something like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults
| eval input="a", active="d", idle="g"
| append [ 
   | makeresults
   | eval input="b", active="e", idle="h" ]
| append [ 
   | makeresults
   | eval input="c", active="f", idle="i" ]
| append [ 
   | makeresults
   | eval input="a", TEST="d", pwr="1" ]
| append [ 
   | makeresults
   | eval input="b", TEST="e", pwr="2" ]
| append [ 
   | makeresults
   | eval input="c", TEST="f", pwr="3" ]
| append [ 
   | makeresults
   | eval input="a", TEST="g", pwr="4" ]
| append [ 
   | makeresults
   | eval input="b", TEST="h", pwr="5" ]
| append [ 
   | makeresults
   | eval input="c", TEST="i", pwr="6" ]
| fields - _time
| eval first=TEST."|".pwr
| stats values(first) AS first values(active) AS active values(idle) As idle BY input
| mvexpand first
| rex field=first "^(?&amp;lt;TEST&amp;gt;[^\|]*)\|(?&amp;lt;pwr&amp;gt;.*)"
| eval TEST=if(active=TEST,"Active","idle")
| table input TEST pwr
| sort TEST&lt;/LI-CODE&gt;&lt;P&gt;obviously the first rows are to populate my search, you have to consider after the fields command row.&lt;/P&gt;&lt;P&gt;In your case:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(index=index1) OR (index=index2)
| eval first=TEST."|".pwr
| stats values(first) AS first values(active) AS active values(idle) As idle BY input
| mvexpand first
| rex field=first "^(?&amp;lt;TEST&amp;gt;[^\|]*)\|(?&amp;lt;pwr&amp;gt;.*)"
| eval TEST=if(active=TEST,"Active","idle")
| table input TEST pwr
| sort TEST&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jun 2022 07:03:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Use-the-results-of-subsearch-to-rename-those-results-with-other/m-p/603119#M209894</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2022-06-24T07:03:47Z</dc:date>
    </item>
    <item>
      <title>Re: Use the results of subsearch to rename those results with other name in new search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Use-the-results-of-subsearch-to-rename-those-results-with-other/m-p/603286#M209954</link>
      <description>&lt;P&gt;Thanks for&amp;nbsp; your answer...at the end i used selfjoin command ......Voila !&amp;nbsp; ITs done !&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":party_popper:"&gt;🎉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 26 Jun 2022 07:38:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Use-the-results-of-subsearch-to-rename-those-results-with-other/m-p/603286#M209954</guid>
      <dc:creator>paritoshs24</dc:creator>
      <dc:date>2022-06-26T07:38:53Z</dc:date>
    </item>
    <item>
      <title>Re: Use the results of subsearch to rename those results with other name in new search</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Use-the-results-of-subsearch-to-rename-those-results-with-other/m-p/603287#M209955</link>
      <description>&lt;P&gt;Thanks&amp;nbsp; !!&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;My queries/data base is not fixed.&lt;BR /&gt;I used selfjoin though as it made my life simpler thanks&amp;nbsp; for your explanation too.&lt;/P&gt;</description>
      <pubDate>Sun, 26 Jun 2022 07:44:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Use-the-results-of-subsearch-to-rename-those-results-with-other/m-p/603287#M209955</guid>
      <dc:creator>paritoshs24</dc:creator>
      <dc:date>2022-06-26T07:44:25Z</dc:date>
    </item>
  </channel>
</rss>

