<?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 How can I search event based on other event value and combine the results? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-search-event-based-on-other-event-value-and-combine/m-p/617711#M214674</link>
    <description>&lt;P&gt;hi&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;our system logs test runs as single events. in some cases we would have a re-run of a test. both events are logically related but are separate for each run (the original run and the re-run).&lt;/P&gt;
&lt;P&gt;I wish to extract data from both events and present it together, have tried several approaches but none worked so far.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;step 1:&lt;/P&gt;
&lt;P&gt;identifying the re-run event and getting a unique identifier for the original run using some textual parsing on the workarea path:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;index=my_index aa_data_source="my_info" is_rerun=True
| eval orig_workarea=workarea_path
| rex field=orig_workarea mode=sed "s@/rerun?$@@"&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;step 2:&lt;BR /&gt;now, I would like to find and match the original run event for each of the results.&lt;/P&gt;
&lt;P&gt;tried map:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;| map search="search index=my_index aa_data_source=my_info workarea_path=$orig_workarea$ " maxsearches=100000&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;this is probably wrong because it is both resource expensive and after I found the original event per result, I could only use the data of the original event (result of map) - didnt find how to combine it with the re-run event data I searched upon.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I also tried subsearch in various ways, the main problem is that the subsearch cannot use the "orig_workarea" I extract from the primary search because it runs first.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;step 3 would be present the results from both events together. meaning - take field_from_eventA, field_from_eventB and place them in the same raw (note that renaming might be required for the fields since both events have the same fields)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;kind of in a dead end here, could use ideas on how to implement this search. any ideas are welcome&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;thanks,&lt;/P&gt;
&lt;P&gt;noam&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 19 Oct 2022 14:41:13 GMT</pubDate>
    <dc:creator>noammeir</dc:creator>
    <dc:date>2022-10-19T14:41:13Z</dc:date>
    <item>
      <title>How can I search event based on other event value and combine the results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-search-event-based-on-other-event-value-and-combine/m-p/617711#M214674</link>
      <description>&lt;P&gt;hi&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;our system logs test runs as single events. in some cases we would have a re-run of a test. both events are logically related but are separate for each run (the original run and the re-run).&lt;/P&gt;
&lt;P&gt;I wish to extract data from both events and present it together, have tried several approaches but none worked so far.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;step 1:&lt;/P&gt;
&lt;P&gt;identifying the re-run event and getting a unique identifier for the original run using some textual parsing on the workarea path:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;index=my_index aa_data_source="my_info" is_rerun=True
| eval orig_workarea=workarea_path
| rex field=orig_workarea mode=sed "s@/rerun?$@@"&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;step 2:&lt;BR /&gt;now, I would like to find and match the original run event for each of the results.&lt;/P&gt;
&lt;P&gt;tried map:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;| map search="search index=my_index aa_data_source=my_info workarea_path=$orig_workarea$ " maxsearches=100000&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;this is probably wrong because it is both resource expensive and after I found the original event per result, I could only use the data of the original event (result of map) - didnt find how to combine it with the re-run event data I searched upon.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I also tried subsearch in various ways, the main problem is that the subsearch cannot use the "orig_workarea" I extract from the primary search because it runs first.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;step 3 would be present the results from both events together. meaning - take field_from_eventA, field_from_eventB and place them in the same raw (note that renaming might be required for the fields since both events have the same fields)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;kind of in a dead end here, could use ideas on how to implement this search. any ideas are welcome&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;thanks,&lt;/P&gt;
&lt;P&gt;noam&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2022 14:41:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-search-event-based-on-other-event-value-and-combine/m-p/617711#M214674</guid>
      <dc:creator>noammeir</dc:creator>
      <dc:date>2022-10-19T14:41:13Z</dc:date>
    </item>
    <item>
      <title>Re: searching event based on other event value and combining the results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-search-event-based-on-other-event-value-and-combine/m-p/617712#M214675</link>
      <description>&lt;P&gt;forgot to mention - I might be able to use transaction or stats based on the orig_workarea value since it will be the same path with addition. however - at the point I evaluated orig_workarea, I can no longer pipe to transaction since I already eliminated some of the events in the process - the one I need included.&lt;/P&gt;&lt;P&gt;moreover - even if I was able to use transaction - not sure how I extract the data from the fields of the two events I'd have in it once they are grouped (again, assume renaming might be required since both events have the same fields)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2022 14:44:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-search-event-based-on-other-event-value-and-combine/m-p/617712#M214675</guid>
      <dc:creator>noammeir</dc:creator>
      <dc:date>2022-10-19T14:44:59Z</dc:date>
    </item>
    <item>
      <title>Re: How can I search event based on other event value and combine the results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-search-event-based-on-other-event-value-and-combine/m-p/617713#M214676</link>
      <description>&lt;P&gt;Try something like this to gather the field values from related events&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=my_index aa_data_source="my_info" is_rerun=True
| eval orig_workarea=workarea_path
| rex field=orig_workarea mode=sed "s@/rerun?$@@"
| stats list(*) as * by orig_workarea&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 19 Oct 2022 14:48:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-search-event-based-on-other-event-value-and-combine/m-p/617713#M214676</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-10-19T14:48:01Z</dc:date>
    </item>
    <item>
      <title>Re: How can I search event based on other event value and combine the results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-search-event-based-on-other-event-value-and-combine/m-p/617746#M214685</link>
      <description>&lt;P&gt;thanks for the prompt reply!&lt;/P&gt;&lt;P&gt;almost there...&lt;/P&gt;&lt;P&gt;removing some of the conditions (is_rerun=True in this simplified case) indeed grouped the relevant events together.&lt;/P&gt;&lt;P&gt;so now I have some cases where there is a single event (no re-run exists) and some where there are two (re-run exists)&lt;/P&gt;&lt;P&gt;1) how do you suggest to filter out only the ones with two events? moreover - filter according to some conditions on the fields of one of the events (for example field_A_in_rerun != field_B_in_rerun)&lt;/P&gt;&lt;P&gt;2) once I filtered the relevant events, how can I access the specific event fields in each of them?&lt;/P&gt;&lt;P&gt;use case example:&lt;/P&gt;&lt;P&gt;I want to show a table of rerun_event_field_A, original_run_field_A, some_more_fields - in cases where field_A != field_B in rerun event&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks,&lt;/P&gt;&lt;P&gt;Noam&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2022 18:59:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-search-event-based-on-other-event-value-and-combine/m-p/617746#M214685</guid>
      <dc:creator>noammeir</dc:creator>
      <dc:date>2022-10-19T18:59:28Z</dc:date>
    </item>
    <item>
      <title>Re: How can I search event based on other event value and combine the results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-search-event-based-on-other-event-value-and-combine/m-p/617813#M214696</link>
      <description>&lt;P&gt;workarea_path will be a multi-value field with values from all the events so you could find just those with only two events by doing this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| where mvcount(workarea_path) = 2&lt;/LI-CODE&gt;&lt;P&gt;By using list() (instead of values()) in the stats command you maintain all the values and they maintain correlation with each other i.e. the first value in all the lists are from the same event, as are all the second values, etc. You can reference these with mvindex&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval first_path=mvindex(workarea_path,0)
| eval second_path=mvindex(workarea_path,1)&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 20 Oct 2022 10:55:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-search-event-based-on-other-event-value-and-combine/m-p/617813#M214696</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2022-10-20T10:55:00Z</dc:date>
    </item>
    <item>
      <title>Re: How can I search event based on other event value and combine the results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-can-I-search-event-based-on-other-event-value-and-combine/m-p/618063#M214808</link>
      <description>&lt;P&gt;thanks for the suggestion!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;it works however I chose a different approach in this specific case - filtering the data I need before reaching the stats command:&lt;/P&gt;&lt;P&gt;index=my_index aa_data_source="my_info" is_rerun=True&lt;BR /&gt;| where fieldA!=fieldB ```filtering out cases```&lt;BR /&gt;&lt;SPAN&gt;| eval orig_&lt;SPAN&gt;some_field&lt;/SPAN&gt;= if(is_rerun=="False", some_field, NULL)&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;```saving data to show only in original```&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;| eval &lt;SPAN&gt;rerun_some_field&lt;/SPAN&gt;= if(is_rerun=="True", some_field, NULL)&amp;nbsp;&amp;nbsp;&lt;SPAN&gt;```saving data to show only in re-run```&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;| eval orig_workarea=workarea_path&lt;/P&gt;&lt;P&gt;| rex field=orig_workarea mode=sed "s@/rerun?$@@"&lt;/P&gt;&lt;P&gt;| stats count(aa_data_source) as event_count list(*) as * by orig_workarea ```using stats to group the events together```&lt;BR /&gt;| where event_count==2 ```additional filtering after stats```&lt;BR /&gt;|table&amp;nbsp;&lt;SPAN&gt;orig_some_field&amp;nbsp;rerun_some_field&amp;nbsp;orig_workarea&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 23 Oct 2022 10:16:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-can-I-search-event-based-on-other-event-value-and-combine/m-p/618063#M214808</guid>
      <dc:creator>noammeir</dc:creator>
      <dc:date>2022-10-23T10:16:57Z</dc:date>
    </item>
  </channel>
</rss>

