<?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: multifield key between indexes in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/multifield-key-between-indexes/m-p/692466#M235696</link>
    <description>&lt;P&gt;everything you write is correct but it is not my case.&amp;nbsp;&lt;BR /&gt;Below my indexes with keys:&lt;BR /&gt;index1:&amp;nbsp; AAA&lt;BR /&gt;key values:&amp;nbsp; fieldA1 AND fieldA2&lt;BR /&gt;&lt;BR /&gt;index2 : BBB&lt;BR /&gt;key values: fieldB1 AND fieldB2&lt;/P&gt;
&lt;P&gt;so I suppose I need to do something like&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;| eval JOIN=if (index='AAA', fieldA1+"_"+fieldA2, fieldB1+"_"+fieldB2)&lt;/LI-CODE&gt;
&lt;P&gt;or in your way:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;| eval key=coalesce(fieldA1+"_"+fieldA2 , fieldB1+"_"+fieldB2)&lt;/LI-CODE&gt;
&lt;P&gt;&lt;BR /&gt;btw. In a few sources close to splunk I read IF is more efficient than COALESCE .&amp;nbsp;&amp;nbsp; But of course both methods do more or less the same.&lt;/P&gt;</description>
    <pubDate>Fri, 05 Jul 2024 12:24:22 GMT</pubDate>
    <dc:creator>kp_pl</dc:creator>
    <dc:date>2024-07-05T12:24:22Z</dc:date>
    <item>
      <title>multifield key between indexes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/multifield-key-between-indexes/m-p/692460#M235691</link>
      <description>&lt;LI-CODE lang="markup"&gt;index=db OR index=app
| eval join=if(index="db",processId,pid)
| stats sum(rows) sum(cputime) by join&lt;/LI-CODE&gt;
&lt;P&gt;&lt;EM&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/EM&gt;Above is simple example how to join two indexes. But how to join two indexes where the key value has two fields ?&lt;EM&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;BR /&gt;K.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 06 Jul 2024 12:09:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/multifield-key-between-indexes/m-p/692460#M235691</guid>
      <dc:creator>kp_pl</dc:creator>
      <dc:date>2024-07-06T12:09:01Z</dc:date>
    </item>
    <item>
      <title>Re: multifield key between indexes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/multifield-key-between-indexes/m-p/692462#M235692</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/265845"&gt;@kp_pl&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;yes, it's correct.&lt;/P&gt;&lt;P&gt;I'd use coalesce instead if:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;index IN (db, app)
| eval key=coaesce(processId,pid)
| stats sum(rows) AS rown sum(cputime) AS cputime by key&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jul 2024 07:11:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/multifield-key-between-indexes/m-p/692462#M235692</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2024-07-05T07:11:41Z</dc:date>
    </item>
    <item>
      <title>Re: multifield key between indexes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/multifield-key-between-indexes/m-p/692464#M235694</link>
      <description>&lt;P&gt;I suppose you do not understand my question .&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need a join two indexes by two fields , Something like&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;| eval key=if(index="aaa", I1key1 , I2key1)
| eval key2=if(index="aaa", I1key2 , I2key2)
| stats values(*) as * by (key and  key2)&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 05 Jul 2024 12:22:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/multifield-key-between-indexes/m-p/692464#M235694</guid>
      <dc:creator>kp_pl</dc:creator>
      <dc:date>2024-07-05T12:22:37Z</dc:date>
    </item>
    <item>
      <title>Re: multifield key between indexes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/multifield-key-between-indexes/m-p/692465#M235695</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/265845"&gt;@kp_pl&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;I understood that you have key1 in ndex1 and key2 in index2 and you want to correate events from both the indexes.&lt;/P&gt;&lt;P&gt;using coalesce, you create a new field (caed key) that takes values from index1 (when present key1) or otherwise from index2 (key2).&lt;/P&gt;&lt;P&gt;then you correlate values using stats and you have values from both the indexes.&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jul 2024 08:06:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/multifield-key-between-indexes/m-p/692465#M235695</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2024-07-05T08:06:12Z</dc:date>
    </item>
    <item>
      <title>Re: multifield key between indexes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/multifield-key-between-indexes/m-p/692466#M235696</link>
      <description>&lt;P&gt;everything you write is correct but it is not my case.&amp;nbsp;&lt;BR /&gt;Below my indexes with keys:&lt;BR /&gt;index1:&amp;nbsp; AAA&lt;BR /&gt;key values:&amp;nbsp; fieldA1 AND fieldA2&lt;BR /&gt;&lt;BR /&gt;index2 : BBB&lt;BR /&gt;key values: fieldB1 AND fieldB2&lt;/P&gt;
&lt;P&gt;so I suppose I need to do something like&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;| eval JOIN=if (index='AAA', fieldA1+"_"+fieldA2, fieldB1+"_"+fieldB2)&lt;/LI-CODE&gt;
&lt;P&gt;or in your way:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;| eval key=coalesce(fieldA1+"_"+fieldA2 , fieldB1+"_"+fieldB2)&lt;/LI-CODE&gt;
&lt;P&gt;&lt;BR /&gt;btw. In a few sources close to splunk I read IF is more efficient than COALESCE .&amp;nbsp;&amp;nbsp; But of course both methods do more or less the same.&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jul 2024 12:24:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/multifield-key-between-indexes/m-p/692466#M235696</guid>
      <dc:creator>kp_pl</dc:creator>
      <dc:date>2024-07-05T12:24:22Z</dc:date>
    </item>
    <item>
      <title>Re: multifield key between indexes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/multifield-key-between-indexes/m-p/692468#M235697</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/265845"&gt;@kp_pl&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;yes, coalesce and if are the same, even if I always use coalesce.&lt;/P&gt;&lt;P&gt;I usually use "." instead "+".&lt;/P&gt;&lt;P&gt;let me summarize: for events from index A, you want to use to concatenated fields from this index, otherwise&lt;/P&gt;&lt;P&gt;two concatenated fieds from index B, is it correct?&lt;/P&gt;&lt;P&gt;in this case you could use:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval key=coalesce(fieldA1."_".fieldA2, fieldB1."_".fieldB2)&lt;/LI-CODE&gt;&lt;P&gt;or in your way:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;| eval JOIN=if(index="AAA", fieldA1."_".fieldA2, fieldB1."_".fieldB2)&lt;/LI-CODE&gt;&lt;P&gt;let me know.&lt;/P&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jul 2024 08:42:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/multifield-key-between-indexes/m-p/692468#M235697</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2024-07-05T08:42:38Z</dc:date>
    </item>
  </channel>
</rss>

