<?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 My join command is not extracting data from 2 indexes in Monitoring Splunk</title>
    <link>https://community.splunk.com/t5/Monitoring-Splunk/My-join-command-is-not-extracting-data-from-2-indexes/m-p/371201#M3196</link>
    <description>&lt;P&gt;The below query is the original one, it was working fine in the lower environments, once moved to the production with the over head, i m facing very bad performance and jobs are queuing. &lt;BR /&gt;
I am trying to optimize the query to use join instead of OR between 2 different indexes but it is not extracting the messages i m looking for . &lt;BR /&gt;
My original Query &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(index=A source=test message="PUBLISH message recieved" ) OR (index=B  sourcetype=test2  "Message Successfully Processed to x")   
| eval Vin=if(isNull(clientId),Vin,clientId)
| eval activityId=if(isNull(activityId),ActivityID,activityId) 
| eval Entry= if(match(message,"PUBLISH message recieved"),_time,NULL)
| eval Exit=if(match(Message,"Message Successfully Processed to x"),_time,NULL) 
|stats min(Entry) as Entry,max(Exit) as Exit, values(Vin) as Vin, values(deviceid) as ESN by activityId
| rename activityId as traceid
 | fillnull value="NULL" | where Exit!="NULL"
 |eval duration=Exit-Entry | eval  Durations= if(duration&amp;lt;0,0,duration)
| convert ctime(Entry) |convert ctime(Exit) |table traceid, Entry,Exit,Vin,ESN,Durations | rename traceid as "Trace Id"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The one i m trying to build with the  join command &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(index=A   source=test  message="PUBLISH message recieved" ) 
|join activityId [search index=B  sourcetype="test2 " "Message Successfully Processed to x"  
 | eval Vin=if(isNull(clientId),Vin,clientId)
| eval activityId=if(isNull(activityId),ActivityID,activityId) ]
| eval Entry= if(match(message,"PUBLISH message recieved"),_time,NULL)
| eval Exit=if(match(Message,"Message Successfully Processed to x"),_time,NULL) 
|stats min(Entry) as Entry,max(Exit) as Exit, values(Vin) as Vin, values(deviceid) as ESN by activityId
| rename activityId as traceid
 | fillnull value="NULL" | where Exit!="NULL"
 |eval duration=Exit-Entry | eval  Durations= if(duration&amp;lt;0,0,duration)
| convert ctime(Entry) |convert ctime(Exit) |table traceid, Entry,Exit,Vin,ESN,Durations | rename traceid as "Trace Id"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks and appreciate the support!&lt;/P&gt;</description>
    <pubDate>Wed, 16 Aug 2017 14:00:31 GMT</pubDate>
    <dc:creator>delgendy</dc:creator>
    <dc:date>2017-08-16T14:00:31Z</dc:date>
    <item>
      <title>My join command is not extracting data from 2 indexes</title>
      <link>https://community.splunk.com/t5/Monitoring-Splunk/My-join-command-is-not-extracting-data-from-2-indexes/m-p/371201#M3196</link>
      <description>&lt;P&gt;The below query is the original one, it was working fine in the lower environments, once moved to the production with the over head, i m facing very bad performance and jobs are queuing. &lt;BR /&gt;
I am trying to optimize the query to use join instead of OR between 2 different indexes but it is not extracting the messages i m looking for . &lt;BR /&gt;
My original Query &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(index=A source=test message="PUBLISH message recieved" ) OR (index=B  sourcetype=test2  "Message Successfully Processed to x")   
| eval Vin=if(isNull(clientId),Vin,clientId)
| eval activityId=if(isNull(activityId),ActivityID,activityId) 
| eval Entry= if(match(message,"PUBLISH message recieved"),_time,NULL)
| eval Exit=if(match(Message,"Message Successfully Processed to x"),_time,NULL) 
|stats min(Entry) as Entry,max(Exit) as Exit, values(Vin) as Vin, values(deviceid) as ESN by activityId
| rename activityId as traceid
 | fillnull value="NULL" | where Exit!="NULL"
 |eval duration=Exit-Entry | eval  Durations= if(duration&amp;lt;0,0,duration)
| convert ctime(Entry) |convert ctime(Exit) |table traceid, Entry,Exit,Vin,ESN,Durations | rename traceid as "Trace Id"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The one i m trying to build with the  join command &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(index=A   source=test  message="PUBLISH message recieved" ) 
|join activityId [search index=B  sourcetype="test2 " "Message Successfully Processed to x"  
 | eval Vin=if(isNull(clientId),Vin,clientId)
| eval activityId=if(isNull(activityId),ActivityID,activityId) ]
| eval Entry= if(match(message,"PUBLISH message recieved"),_time,NULL)
| eval Exit=if(match(Message,"Message Successfully Processed to x"),_time,NULL) 
|stats min(Entry) as Entry,max(Exit) as Exit, values(Vin) as Vin, values(deviceid) as ESN by activityId
| rename activityId as traceid
 | fillnull value="NULL" | where Exit!="NULL"
 |eval duration=Exit-Entry | eval  Durations= if(duration&amp;lt;0,0,duration)
| convert ctime(Entry) |convert ctime(Exit) |table traceid, Entry,Exit,Vin,ESN,Durations | rename traceid as "Trace Id"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks and appreciate the support!&lt;/P&gt;</description>
      <pubDate>Wed, 16 Aug 2017 14:00:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Monitoring-Splunk/My-join-command-is-not-extracting-data-from-2-indexes/m-p/371201#M3196</guid>
      <dc:creator>delgendy</dc:creator>
      <dc:date>2017-08-16T14:00:31Z</dc:date>
    </item>
    <item>
      <title>Re: My join command is not extracting data from 2 indexes</title>
      <link>https://community.splunk.com/t5/Monitoring-Splunk/My-join-command-is-not-extracting-data-from-2-indexes/m-p/371202#M3197</link>
      <description>&lt;P&gt;Why use join?  It's slow.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Aug 2017 14:41:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Monitoring-Splunk/My-join-command-is-not-extracting-data-from-2-indexes/m-p/371202#M3197</guid>
      <dc:creator>richgalloway</dc:creator>
      <dc:date>2017-08-16T14:41:17Z</dc:date>
    </item>
    <item>
      <title>Re: My join command is not extracting data from 2 indexes</title>
      <link>https://community.splunk.com/t5/Monitoring-Splunk/My-join-command-is-not-extracting-data-from-2-indexes/m-p/371203#M3198</link>
      <description>&lt;P&gt;cause i want to search first in the index after the search, get the activityId then search with those in the first index . &lt;BR /&gt;
i think i found the solution already , i just need to correlate between the 2 indexes by | fields message activityId so i can connect the 2 indexes . This worked for me . Thanks ! &lt;/P&gt;</description>
      <pubDate>Wed, 16 Aug 2017 14:51:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Monitoring-Splunk/My-join-command-is-not-extracting-data-from-2-indexes/m-p/371203#M3198</guid>
      <dc:creator>delgendy</dc:creator>
      <dc:date>2017-08-16T14:51:16Z</dc:date>
    </item>
    <item>
      <title>Re: My join command is not extracting data from 2 indexes</title>
      <link>https://community.splunk.com/t5/Monitoring-Splunk/My-join-command-is-not-extracting-data-from-2-indexes/m-p/371204#M3199</link>
      <description>&lt;P&gt;&lt;CODE&gt;join&lt;/CODE&gt; is almost always slower than a direct combined search.  The way you've done it, it should be much slower, except that as an inner join, it will drop all records which do not have members on both sides of the join.&lt;/P&gt;

&lt;P&gt;Just to verify - over the time range that you normally run this report, are duplicate traceids / activityids ever expected?&lt;/P&gt;

&lt;P&gt;Here's a version of your original with some slight performance enhancements.  You should look at this, and incorporate most of these changes into your join if you proceed that way.  For instance, add the &lt;CODE&gt;fields&lt;/CODE&gt; command at the top, and use the &lt;CODE&gt;index=&lt;/CODE&gt; rather than the &lt;CODE&gt;match&lt;/CODE&gt; code to test which record you have.  An &lt;CODE&gt;index=&lt;/CODE&gt; command will be able to reject the test at the first non-matching character, whereas match will have to scan the entire message field.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; (index=A source=test message="PUBLISH message recieved" ) OR 
 (index=B  sourcetype=test2  "Message Successfully Processed to x")   
 | fields index, Vin, clientId, activityId, ActivityID,  deviceid
 | eval Vin=coalesce(clientId,Vin)
 | eval traceid=coalesce(activityId,ActivityID) 
 | eval Entry = if(index="A",_time,null())
 | eval Exit = if(index="B",_time,null()) 
 | stats min(Entry) as Entry, max(Exit) as Exit, values(Vin) as Vin, values(deviceid) as ESN by traceid
 | where isnotnull(Exit)
 | eval  Durations= if(Exit&amp;lt;Entry,0,Exit-Entry)
 | convert ctime(Entry) 
 | convert ctime(Exit) 
 | table traceid, Entry, Exit, Vin, ESN, Durations 
 | rename traceid as "Trace Id"
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 16 Aug 2017 15:23:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Monitoring-Splunk/My-join-command-is-not-extracting-data-from-2-indexes/m-p/371204#M3199</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-08-16T15:23:35Z</dc:date>
    </item>
    <item>
      <title>Re: My join command is not extracting data from 2 indexes</title>
      <link>https://community.splunk.com/t5/Monitoring-Splunk/My-join-command-is-not-extracting-data-from-2-indexes/m-p/371205#M3200</link>
      <description>&lt;P&gt;Thanks DalJeanis so much this was helpful &lt;BR /&gt;
I have made little changes on the query as well with your performance recommendation, but i want to perform timechart for the 95th perc of the Total Duration which is not working &lt;/P&gt;

&lt;P&gt;index=A source=&lt;EM&gt;test&lt;/EM&gt; &lt;BR /&gt;
 message="PUBLISH message recieved" OR logtype="Dog.Exit" &lt;BR /&gt;
| eval Entry= if(match(message,"PUBLISH message recieved"),_time,NULL)&lt;BR /&gt;
| eval Exit= if(match(logtype,"Dog.Exit"),_time,NULL)&lt;BR /&gt;
| eval traceid=coalesce(traceid,activityId) | eval esn=coalesce(esn,deviceid)&lt;BR /&gt;
|stats min(Entry) as Entry max(Exit) as Exit values(esn) as ESN  by traceid|where isnotnull(Exit)&lt;BR /&gt;
|eval VsdnDurations=if(Exit&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 15:27:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Monitoring-Splunk/My-join-command-is-not-extracting-data-from-2-indexes/m-p/371205#M3200</guid>
      <dc:creator>delgendy</dc:creator>
      <dc:date>2020-09-29T15:27:33Z</dc:date>
    </item>
    <item>
      <title>Re: My join command is not extracting data from 2 indexes</title>
      <link>https://community.splunk.com/t5/Monitoring-Splunk/My-join-command-is-not-extracting-data-from-2-indexes/m-p/371206#M3201</link>
      <description>&lt;P&gt;@delgendy - your code cut off, and I'm not sure what your question is.  &lt;/P&gt;

&lt;P&gt;A percentile is only valid across a population, so you probably just need to do something like &lt;CODE&gt;eventstats&lt;/CODE&gt; ...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| eventstats perc95(Durations) as p95Durations      (((by field???)))
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But what you want to chart against that, I'm not really clear on.  If you want each time period's 95th percentile, then you'll need to &lt;CODE&gt;bin&lt;/CODE&gt;the appropriate time field (&lt;CODE&gt;Entry&lt;/CODE&gt;, probably) and then run eventstats on that.  If you just want a horizontal line for the 95th percentile across the entire time period, that's another method.  And if you want a running calculation of the 95th percentile, changing daily, then that's a third one (probably streamstats).&lt;/P&gt;

&lt;P&gt;It would probably be most clear to start a new question devoted to what you are trying to achieve there.  &lt;/P&gt;

&lt;P&gt;By the way, you can probably use &lt;CODE&gt;=&lt;/CODE&gt; instead of &lt;CODE&gt;match()&lt;/CODE&gt; with the &lt;CODE&gt;logtype&lt;/CODE&gt; comparison.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Aug 2017 20:50:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Monitoring-Splunk/My-join-command-is-not-extracting-data-from-2-indexes/m-p/371206#M3201</guid>
      <dc:creator>DalJeanis</dc:creator>
      <dc:date>2017-08-18T20:50:18Z</dc:date>
    </item>
  </channel>
</rss>

