<?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 data from two indexes, with separate events in Reporting</title>
    <link>https://community.splunk.com/t5/Reporting/Use-data-from-two-indexes-with-separate-events/m-p/547764#M8951</link>
    <description>&lt;LI-CODE lang="markup"&gt;| makeresults 
| eval _raw="ESN,UnitTemperature
1234,20
2345,23
4567,56"
| multikv forceheader=1 
| append 
    [| makeresults 
    | eval _raw="Thermocouple,Temperature
1,10
2,11
3,12
4,13
5,31
6,32
7,33
8,34"
    | multikv forceheader=1 
    ]
``` Replace above with index=index1 OR index=index2 ```


    | append
    [| makeresults 
    | eval _raw="ESN,ClosestFrontThermocouple,ClosestBackThermocouple
1234,5,1
2345,6,2
4567,7,3"
    | multikv forceheader=1
    ``` Replace this with inputlookup of your lookup table ```
    ]
| fields - _* linecount
``` The above makes up some dummy data and should be replaced with your search of both indexes and appending your lookup table ```

``` Gather closest thermocouple ids for each ESN ```
| eventstats values(ClosestBackThermocouple) as ClosestBackThermocouple values(ClosestFrontThermocouple) as ClosestFrontThermocouple by ESN
``` Evaluate whether thermocouple is front or back ```
| eval ClosestBackThermocouple=if(Thermocouple&amp;lt;5,Thermocouple,ClosestBackThermocouple)
| eval ClosestFrontThermocouple=if(Thermocouple&amp;gt;4,Thermocouple,ClosestFrontThermocouple)
``` Gather closest temperatures from thermocouples ```
| eventstats values(Temperature) as ClosestBackThermocoupleTemperature by ClosestBackThermocouple
| eventstats values(Temperature) as ClosestFrontThermocoupleTemperature by ClosestFrontThermocouple
``` Just keep the original ESN events ```
| where isnotnull(UnitTemperature)
``` Just keep the required fields ```
| fields ESN UnitTemperature ClosestFrontThermocoupleTemperature ClosestBackThermocoupleTemperature&lt;/LI-CODE&gt;</description>
    <pubDate>Tue, 13 Apr 2021 14:44:48 GMT</pubDate>
    <dc:creator>ITWhisperer</dc:creator>
    <dc:date>2021-04-13T14:44:48Z</dc:date>
    <item>
      <title>Use data from two indexes, with separate events</title>
      <link>https://community.splunk.com/t5/Reporting/Use-data-from-two-indexes-with-separate-events/m-p/547756#M8948</link>
      <description>&lt;P&gt;Hi, I have two indexes from two different sources, but I want to use them together, preferably in a table.&lt;/P&gt;&lt;P&gt;index1 contains data on hardware units in a rack, with fields ESN (serial number) and UnitTemperature.&lt;BR /&gt;index2 contains external temperature data, with fields Thermocouple (which are just numbered 1 to 8 ) and Temperature. Thermocouples 1-4 are at the back and 5-8 are at the front of the rack.&lt;/P&gt;&lt;P&gt;I have a lookup table to get the number of the two thermocouples (front and back) closest to each unit from their ESN.&lt;/P&gt;&lt;P&gt;Now what I want is to make a table with columns:&lt;BR /&gt;ESN, Unit Temperature, Closest Front Thermocouple Temperature, Closest Back Thermocouple Temperature.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there any easy way to do this?&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Apr 2021 12:34:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Reporting/Use-data-from-two-indexes-with-separate-events/m-p/547756#M8948</guid>
      <dc:creator>morganj1</dc:creator>
      <dc:date>2021-04-13T12:34:40Z</dc:date>
    </item>
    <item>
      <title>Re: Use data from two indexes, with separate events</title>
      <link>https://community.splunk.com/t5/Reporting/Use-data-from-two-indexes-with-separate-events/m-p/547760#M8949</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/233426"&gt;@morganj1&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;if you have the ESN field in both indexes you can correlate data from both the indexes using the stats command, some thing like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=index1 OR index=index2
| stats values(UnitTemperature) AS UnitTemperature values(ClosestFrontThermocoupleTemperature) AS ClosestFrontThermocoupleTemperature values(ClosestBackThermocoupleTemperature) AS ClosestBackThermocoupleTemperature BY ESN&lt;/LI-CODE&gt;&lt;P&gt;if ENS has a different name in one index, you have to rename it.&lt;/P&gt;&lt;P&gt;If you have more values for Temperature, you have to define the function to use: min, max, avg, etc...&lt;/P&gt;&lt;P&gt;If you have spaces in the field names, rename them.&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Tue, 13 Apr 2021 12:41:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Reporting/Use-data-from-two-indexes-with-separate-events/m-p/547760#M8949</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2021-04-13T12:41:06Z</dc:date>
    </item>
    <item>
      <title>Re: Use data from two indexes, with separate events</title>
      <link>https://community.splunk.com/t5/Reporting/Use-data-from-two-indexes-with-separate-events/m-p/547763#M8950</link>
      <description>&lt;P&gt;Thanks for your quick response!&lt;/P&gt;&lt;P&gt;I'm afraid this doesn't really work for me, I don't have the ESN field in both indexes. Sorry, it's quite hard to word what I actually want.&lt;/P&gt;&lt;P&gt;Is there any way of sort of using index2 as a lookup table?&lt;/P&gt;&lt;P&gt;So, I have a lookup table which gives me TC_Back and TC_Front from the ESN. So these will be number 1-4 or 5-8, respectively. Is there a way I can input this number into index2 and receive the latest Temperature for the corresponding Thermocouple number?&lt;/P&gt;&lt;P&gt;Something like:&lt;BR /&gt;index=index1 | lookup lookup_table ESN TC_Back | eval TempBack=function([index=index2 |&amp;nbsp; latest(Temperature) | where Thermocouple=TC_Back])&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope this makes sense...&lt;/P&gt;</description>
      <pubDate>Tue, 13 Apr 2021 14:00:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Reporting/Use-data-from-two-indexes-with-separate-events/m-p/547763#M8950</guid>
      <dc:creator>morganj1</dc:creator>
      <dc:date>2021-04-13T14:00:24Z</dc:date>
    </item>
    <item>
      <title>Re: Use data from two indexes, with separate events</title>
      <link>https://community.splunk.com/t5/Reporting/Use-data-from-two-indexes-with-separate-events/m-p/547764#M8951</link>
      <description>&lt;LI-CODE lang="markup"&gt;| makeresults 
| eval _raw="ESN,UnitTemperature
1234,20
2345,23
4567,56"
| multikv forceheader=1 
| append 
    [| makeresults 
    | eval _raw="Thermocouple,Temperature
1,10
2,11
3,12
4,13
5,31
6,32
7,33
8,34"
    | multikv forceheader=1 
    ]
``` Replace above with index=index1 OR index=index2 ```


    | append
    [| makeresults 
    | eval _raw="ESN,ClosestFrontThermocouple,ClosestBackThermocouple
1234,5,1
2345,6,2
4567,7,3"
    | multikv forceheader=1
    ``` Replace this with inputlookup of your lookup table ```
    ]
| fields - _* linecount
``` The above makes up some dummy data and should be replaced with your search of both indexes and appending your lookup table ```

``` Gather closest thermocouple ids for each ESN ```
| eventstats values(ClosestBackThermocouple) as ClosestBackThermocouple values(ClosestFrontThermocouple) as ClosestFrontThermocouple by ESN
``` Evaluate whether thermocouple is front or back ```
| eval ClosestBackThermocouple=if(Thermocouple&amp;lt;5,Thermocouple,ClosestBackThermocouple)
| eval ClosestFrontThermocouple=if(Thermocouple&amp;gt;4,Thermocouple,ClosestFrontThermocouple)
``` Gather closest temperatures from thermocouples ```
| eventstats values(Temperature) as ClosestBackThermocoupleTemperature by ClosestBackThermocouple
| eventstats values(Temperature) as ClosestFrontThermocoupleTemperature by ClosestFrontThermocouple
``` Just keep the original ESN events ```
| where isnotnull(UnitTemperature)
``` Just keep the required fields ```
| fields ESN UnitTemperature ClosestFrontThermocoupleTemperature ClosestBackThermocoupleTemperature&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 13 Apr 2021 14:44:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Reporting/Use-data-from-two-indexes-with-separate-events/m-p/547764#M8951</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2021-04-13T14:44:48Z</dc:date>
    </item>
    <item>
      <title>Re: Use data from two indexes, with separate events</title>
      <link>https://community.splunk.com/t5/Reporting/Use-data-from-two-indexes-with-separate-events/m-p/547767#M8952</link>
      <description>&lt;P&gt;Wow this is actually exactly what I wanted! Thank you very much, I'm surprised you even understood what I was asking &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 13 Apr 2021 15:25:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Reporting/Use-data-from-two-indexes-with-separate-events/m-p/547767#M8952</guid>
      <dc:creator>morganj1</dc:creator>
      <dc:date>2021-04-13T15:25:52Z</dc:date>
    </item>
    <item>
      <title>Re: Use data from two indexes, with separate events</title>
      <link>https://community.splunk.com/t5/Reporting/Use-data-from-two-indexes-with-separate-events/m-p/547768#M8953</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/233426"&gt;@morganj1&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;I'm not sure to completely understand your need, but I think that you could use eval command to distinguish your temparature:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval index2_temperature=if(index=index2,temperature,""), index1_temperature=if(index=index1,temperature,"")&lt;/LI-CODE&gt;&lt;P&gt;in this way you could have a variable that contains temperature from a specific index and use it in your stats command.&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Tue, 13 Apr 2021 15:27:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Reporting/Use-data-from-two-indexes-with-separate-events/m-p/547768#M8953</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2021-04-13T15:27:05Z</dc:date>
    </item>
  </channel>
</rss>

