<?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: Adding two indexes to one search again in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Adding-two-indexes-to-one-search-again/m-p/672014#M230249</link>
    <description>&lt;P&gt;I'm still not sure what are the source datasets and what should be the result. I see some attempts at solving this riddle in the thread but I'm not 100% sure we're all on the same page regarding what we're working with and what we want to achieve in the end.&lt;/P&gt;&lt;P&gt;Could you please post samples of your data and what the result should look like?&lt;/P&gt;</description>
    <pubDate>Fri, 15 Dec 2023 11:27:43 GMT</pubDate>
    <dc:creator>PickleRick</dc:creator>
    <dc:date>2023-12-15T11:27:43Z</dc:date>
    <item>
      <title>Adding two indexes to one search again</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Adding-two-indexes-to-one-search-again/m-p/671905#M230222</link>
      <description>&lt;LI-CODE lang="markup"&gt;index=jedi   domain="jedi.lightside.com" (master!="yoda" AND master!="mace" AND master="Jinn")
| table saber_color, Jname, strengths, mentor, skill, domain, mission

index-=sith  broker sithlord!=darth_maul
| table saber_color, Sname, strength, teacher, actions&lt;/LI-CODE&gt;
&lt;P&gt;I need to list where Jname=Sname, but I need to list all columns&lt;/P&gt;
&lt;P&gt;The third one is&lt;/P&gt;
&lt;P&gt;where the Jname!=Sname&lt;/P&gt;
&lt;P&gt;The caveat is I cannot use the join for this query.&lt;/P&gt;
&lt;P&gt;This helped however I am unable to utilize the index drill down for each in the search otherwise the query is 75% white noise.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;index=jedi OR index=sith
| eval name=coalesce(Jname, Sname)
| stats values(name) as names by saber_color strengths
| where mvcount(names)=1&lt;/LI-CODE&gt;
&lt;P&gt;Please help.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Dec 2023 15:21:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Adding-two-indexes-to-one-search-again/m-p/671905#M230222</guid>
      <dc:creator>the_dude</dc:creator>
      <dc:date>2023-12-14T15:21:54Z</dc:date>
    </item>
    <item>
      <title>Re: Adding two indexes to one search again</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Adding-two-indexes-to-one-search-again/m-p/671907#M230223</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/261965"&gt;@the_dude&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;your search is correct and I like that you don't use join.&lt;/P&gt;&lt;P&gt;but what's te issue?&lt;/P&gt;&lt;P&gt;You can use the name value for the drilldown, remembering that the filed name is different in the two indexes:&lt;/P&gt;&lt;P&gt;so the drilldown search could be:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=jedi OR index=sith
| eval name=coalesce(Jname, Sname)
| search name=$name$
| table ...&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Thu, 14 Dec 2023 14:55:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Adding-two-indexes-to-one-search-again/m-p/671907#M230223</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2023-12-14T14:55:54Z</dc:date>
    </item>
    <item>
      <title>Re: Adding two indexes to one search again</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Adding-two-indexes-to-one-search-again/m-p/671915#M230224</link>
      <description>&lt;P&gt;I need to filter out the white noise.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;index-=sith broker sithlord!=darth_maul OR index=jedi domain="jedi.lightside.com" (master!="yoda" AND master!="mace" AND master="Jinn")&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I use the correct one, 75% of it is white noise. I need to use the above to isolate what I need specifically from the indexes. I need to show a 1:1 match plus a few other columns. I was asked to get the former but now they need more.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Dec 2023 17:01:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Adding-two-indexes-to-one-search-again/m-p/671915#M230224</guid>
      <dc:creator>the_dude</dc:creator>
      <dc:date>2023-12-14T17:01:31Z</dc:date>
    </item>
    <item>
      <title>Re: Adding two indexes to one search again</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Adding-two-indexes-to-one-search-again/m-p/671924#M230226</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/261965"&gt;@the_dude&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;your above search permits you to find the values common to both the indexes.&lt;/P&gt;&lt;P&gt;The last search gives you (in drilldown), the informations, from both the indexes relative to the choosed value.&lt;/P&gt;&lt;P&gt;So, what do you want to filter?&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Thu, 14 Dec 2023 15:56:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Adding-two-indexes-to-one-search-again/m-p/671924#M230226</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2023-12-14T15:56:27Z</dc:date>
    </item>
    <item>
      <title>Re: Adding two indexes to one search again</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Adding-two-indexes-to-one-search-again/m-p/671942#M230229</link>
      <description>&lt;P&gt;This was the concept:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;index-=sith broker sithlord!=darth_maul OR index=jedi domain="jedi.lightside.com" (master!="yoda" AND master!="mace" AND master="Jinn")
| where Jname=Sname
| table Jname, Sname, strengths, mentor, skill, domain, mission, strength, teacher, actions&lt;/LI-CODE&gt;
&lt;P&gt;And&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;index-=sith broker sithlord!=darth_maul OR index=jedi domain="jedi.lightside.com" (master!="yoda" AND master!="mace" AND master="Jinn")
| where Jname!=Sname
| table Jname, Sname, strengths, mentor, skill, domain, mission, strength, teacher, actions&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am trying to get the results where Jname=Sname are the same plus all following columns. This is for a comparison for our analysts and they want the first two columns to match plus following columns. Then a report where they are not matching.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Dec 2023 17:03:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Adding-two-indexes-to-one-search-again/m-p/671942#M230229</guid>
      <dc:creator>the_dude</dc:creator>
      <dc:date>2023-12-14T17:03:29Z</dc:date>
    </item>
    <item>
      <title>Re: Adding two indexes to one search again</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Adding-two-indexes-to-one-search-again/m-p/671967#M230234</link>
      <description>&lt;P&gt;Would an aggregated resulting dataset be sufficient for your ask?&lt;BR /&gt;I tried to do what I think you are asking by utilizing a stats command to aggregate data from the two indexes together but has just a compressed overview of the analysis.&lt;BR /&gt;&lt;BR /&gt;Example of output with simulation data:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dtburrows3_0-1702583556619.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/28527iE0B81FA0D508D8C7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="dtburrows3_0-1702583556619.png" alt="dtburrows3_0-1702583556619.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;To achieve this with the base searches you provided would look like this.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(index=sith broker sithlord!=darth_maul) OR (index=jedi domain="jedi.lightside.com" (master!="yoda" AND master!="mace" AND master="Jinn"))
    | fields + _time, index, Jname, saber_color, domain, master, strengths, mentor, skill, mission, Sname, strength, teacher, actions
    | tojson str(saber_color) str(domain) str(master) str(actions) str(mentor) str(mission) str(skill) str(strength) str(strengths) str(teacher) output_field=unique_field_combos_json
    | fields + _time, index, Jname, Sname, unique_field_combos_json
    | eval
        name=coalesce('Jname', 'Sname')
    | stats
        min(_time) as earliest_event,
        max(_time) as latest_event,
        count as total_count,
        count(eval('index'=="jedi")) as jedi_count,
        count(eval('index'=="sith")) as sith_count,
        values(index) as indexes,
        dc(index) as dc_indexes,
        latest(eval(case('index'=="jedi", unique_field_combos_json))) as jedi_unique_field_combos_json,
        latest(eval(case('index'=="sith", unique_field_combos_json))) as sith_unique_field_combos_json
            by name
    | eval
        scenario=if(
            'dc_indexes'==1,
                case(
                    'indexes'=="jedi", "Jedi Only",
                    'indexes'=="sith", "Sith Only"
                    ),
                "Jedi and Sith"
            )
    | foreach *_unique_field_combos_json
        [
            | eval
                unique_field_combos_json=if(
                    isnotnull('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'),
                        mvappend(
                            'unique_field_combos_json',
                            json_set('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;', "type", "&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;")
                            ),
                        'unique_field_combos_json'
                    )
            ]
    | fields - *_unique_field_combos_json
    | mvexpand unique_field_combos_json
    | fromjson unique_field_combos_json
    | fields - unique_field_combos_json
    | fields + name, type, scenario, total_count, jedi_count, sith_count, saber_color, domain, master, actions, mentor, mission, skill, strength, strengths, teacher
    | stats
        values(*) as *
            by name
    | fields + name, type, scenario, *_count, saber_color, domain, master, actions, mentor, mission, skill, strength, strengths, teacher
    | eval
        scenario_sort=case(
            'scenario'=="Jedi and Sith", 1,
            'scenario'=="Jedi Only", 2,
            'scenario'=="Sith Only", 3
            )
    | sort 0 +scenario_sort
    | fields - scenario_sort&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;To generate the simulation data was a doozy since I dont have a datagen setup right now but was able to put something together using build in splunk commands. SPL used to simulate for reference.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| makeresults count=1000
    | eval
        low=1,
        high=[ 
            | makeresults
                | eval
                    index="sith",
                    fields_to_gen=split("Sname|saber_color|strength|teacher|actions", "|")
                | append
                    [
                        | makeresults
                            | eval
                                index="jedi",
                                fields_to_gen=split("Jname|saber_color|strengths|mentor|skill|mission|master|domain", "|")
                        ]
                | mvexpand fields_to_gen
                | fields - _time
                | eval
                    value_format=if(
                        match('fields_to_gen', "^[A-Z]name$"), 
                            "name",
                            'fields_to_gen'
                        )
                | rename
                    fields_to_gen as fieldname
                | tojson str(fieldname) str(value_format) output_field=field_format_json
                | fields + index, field_format_json
                | stats
                    values(field_format_json) as field_format_json
                        by index
                | eval
                    field_format_json_array="[".mvjoin(field_format_json, ",")."]"
                | fields - field_format_json
                | streamstats
                    count as index_number_assignment
                | stats
                    max(index_number_assignment) as index_count
                | return $index_count
            ],
        rand=round(((random()%'high')/'high')*('high'-'low')+'low')
    | fields - low, high
    | rename
        rand as index_number_assignment
    ``` distribute timestamps ```
    | streamstats
        count as iter
    | eval
        _time=now()-('iter'/10)
    
    
    | join type=left index_number_assignment
        [
            | makeresults
                | eval
                    index="sith",
                    fields_to_gen=split("Sname|saber_color|strength|teacher|actions", "|")
                | append
                    [
                        | makeresults
                            | eval
                                index="jedi",
                                fields_to_gen=split("Jname|saber_color|strengths|mentor|skill|mission|master|domain", "|")
                        ]
                | mvexpand fields_to_gen
                | fields - _time
                | eval
                    value_format=if(
                        match('fields_to_gen', "^[A-Z]name$"), 
                            "name",
                            'fields_to_gen'
                        )
                | rename
                    fields_to_gen as fieldname
                | tojson str(fieldname) str(value_format) output_field=field_format_json
                | fields + index, field_format_json
                | stats
                    values(field_format_json) as field_format_json
                        by index
                | tojson str(index) str(field_format_json) output_field=json
                | streamstats
                    count as index_number_assignment
                | fields + index_number_assignment, json
            ]
    | fromjson json
    | fields - json, index_number_assignment
    
    | eval
        json=json_object()
    | foreach mode=multivalue field_format_json
        [
            | eval
                fieldname=spath('&amp;lt;&amp;lt;ITEM&amp;gt;&amp;gt;', "fieldname"),
                json=json_set(json, 'fieldname', spath('&amp;lt;&amp;lt;ITEM&amp;gt;&amp;gt;', "value_format")."_")
            ]
    | fields - field_format_json
    | spath input=json
    | fields - json, fieldname
    | fields + index, *
    | foreach *name
        [
            | eval
                low=1, 
                high=5, 
                rand=round(((random()%'high')/'high')*('high'-'low')+'low'),
                &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;='&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'.'rand'
                | fields - low, high, rand
            ]
    | foreach *
        [
            | eval
                low=1, 
                nested_high=10,
                nested_rand=round(((random()%'nested_high')/'nested_high')*('nested_high'-'low')+'low'),
                high='nested_rand', 
                rand=round(((random()%'high')/'high')*('high'-'low')+'low'),
                &amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;=if(
                    NOT match("&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;", "[A-Z]name$") AND NOT "&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;"=="index",
                        '&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'.'rand',
                        '&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'
                    )
                | fields - low, high, rand, nested_high, nested_rand
            ]  
    | eval
        Jname=if(
            'index'=="jedi" AND 'Jname'=="name_1",
                "name_unique_jedi",
                'Jname'
            ),
        Sname=if(
            'index'=="sith" AND 'Sname'=="name_2",
                "name_unique_sith",
                'Sname'
            )
            
            
            
            
```
(index-=sith broker sithlord!=darth_maul) OR (index=jedi domain="jedi.lightside.com" (master!="yoda" AND master!="mace" AND master="Jinn"))
    | fields + _time, index, Jname, saber_color, domain, master, strengths, mentor, skill, mission, Sname, strength, teacher, actions
```
    | tojson str(saber_color) str(domain) str(master) str(actions) str(mentor) str(mission) str(skill) str(strength) str(strengths) str(teacher) output_field=unique_field_combos_json
    | fields + _time, index, Jname, Sname, unique_field_combos_json
    | eval
        name=coalesce('Jname', 'Sname')
    | stats
        min(_time) as earliest_event,
        max(_time) as latest_event,
        count as total_count,
        count(eval('index'=="jedi")) as jedi_count,
        count(eval('index'=="sith")) as sith_count,
        values(index) as indexes,
        dc(index) as dc_indexes,
        latest(eval(case('index'=="jedi", unique_field_combos_json))) as jedi_unique_field_combos_json,
        latest(eval(case('index'=="sith", unique_field_combos_json))) as sith_unique_field_combos_json
            by name
    | eval
        scenario=if(
            'dc_indexes'==1,
                case(
                    'indexes'=="jedi", "Jedi Only",
                    'indexes'=="sith", "Sith Only"
                    ),
                "Jedi and Sith"
            )
    | foreach *_unique_field_combos_json
        [
            | eval
                unique_field_combos_json=if(
                    isnotnull('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;'),
                        mvappend(
                            'unique_field_combos_json',
                            json_set('&amp;lt;&amp;lt;FIELD&amp;gt;&amp;gt;', "type", "&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;")
                            ),
                        'unique_field_combos_json'
                    )
            ]
    | fields - *_unique_field_combos_json
    | mvexpand unique_field_combos_json
    | fromjson unique_field_combos_json
    | fields - unique_field_combos_json
    | fields + name, type, scenario, total_count, jedi_count, sith_count, saber_color, domain, master, actions, mentor, mission, skill, strength, strengths, teacher
    | stats
        values(*) as *
            by name
    | fields + name, type, scenario, *_count, saber_color, domain, master, actions, mentor, mission, skill, strength, strengths, teacher
    | eval
        scenario_sort=case(
            'scenario'=="Jedi and Sith", 1,
            'scenario'=="Jedi Only", 2,
            'scenario'=="Sith Only", 3
            )
    | sort 0 +scenario_sort
    | fields - scenario_sort&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 14 Dec 2023 19:56:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Adding-two-indexes-to-one-search-again/m-p/671967#M230234</guid>
      <dc:creator>dtburrows3</dc:creator>
      <dc:date>2023-12-14T19:56:20Z</dc:date>
    </item>
    <item>
      <title>Re: Adding two indexes to one search again</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Adding-two-indexes-to-one-search-again/m-p/671969#M230235</link>
      <description>&lt;P&gt;It is correct somewhat, I'm trying to 1:1 for the two specific columns. The use it just to start with the two columns matching at first, then another where they do not. Where Qui-gonn Jinn is in both Sith and Jedi indexes and listed in both columns. For some reason I thinking I might be making this more difficult than it needs to be. If the two IDs match in both columns then they are listed with the rest. Hopefully that clear is up. I am still trying to relearn the whole search in Splunk currently so I do apologize.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Dec 2023 22:03:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Adding-two-indexes-to-one-search-again/m-p/671969#M230235</guid>
      <dc:creator>the_dude</dc:creator>
      <dc:date>2023-12-14T22:03:13Z</dc:date>
    </item>
    <item>
      <title>Re: Adding two indexes to one search again</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Adding-two-indexes-to-one-search-again/m-p/672009#M230247</link>
      <description>&lt;P&gt;First, it seems to me that&amp;nbsp;&lt;FONT face="courier new,courier"&gt;(master!="yoda" AND master!="mace" AND master="Jinn")&lt;/FONT&gt; and &lt;FONT face="courier new,courier"&gt;master="Jinn"&lt;/FONT&gt;&amp;nbsp;are semantically identical. &amp;nbsp;Is this correct? (I'm unfamiliar with the Jedi lore.) &amp;nbsp;I'll assume it to be true in the following.&lt;/P&gt;&lt;P&gt;Second, what is preventing you from doing, for example&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=sith broker sithlord!=darth_maul OR index=jedi domain="jedi.lightside.com" master="Jinn"
| eval name=coalesce(Jname, Sname)
| stats values(name) as names by saber_color strengths
| where mvcount(names)=1&lt;/LI-CODE&gt;&lt;P&gt;or even&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index=sith broker sithlord!=darth_maul OR index=jedi domain="jedi.lightside.com" master="Jinn"
| eval name=coalesce(Jname, Sname)
| stats values(*) as * by saber_color strengths
| where mvcount(names)=1&lt;/LI-CODE&gt;&lt;P&gt;This way, you will have all columns preserved.&lt;/P&gt;&lt;P&gt;Third, could you explain "&lt;SPAN&gt;unable to utilize the index drill down for each in the search otherwise the query is 75% white noise?" &amp;nbsp;Are you trying to use "Automatic" in drilldown action? &amp;nbsp;Anything "automatic" is really Splunk's guess. &amp;nbsp;If you have something specific in mind. you will want to write custom drilldown instead.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 15 Dec 2023 10:29:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Adding-two-indexes-to-one-search-again/m-p/672009#M230247</guid>
      <dc:creator>yuanliu</dc:creator>
      <dc:date>2023-12-15T10:29:10Z</dc:date>
    </item>
    <item>
      <title>Re: Adding two indexes to one search again</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Adding-two-indexes-to-one-search-again/m-p/672014#M230249</link>
      <description>&lt;P&gt;I'm still not sure what are the source datasets and what should be the result. I see some attempts at solving this riddle in the thread but I'm not 100% sure we're all on the same page regarding what we're working with and what we want to achieve in the end.&lt;/P&gt;&lt;P&gt;Could you please post samples of your data and what the result should look like?&lt;/P&gt;</description>
      <pubDate>Fri, 15 Dec 2023 11:27:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Adding-two-indexes-to-one-search-again/m-p/672014#M230249</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2023-12-15T11:27:43Z</dc:date>
    </item>
  </channel>
</rss>

