<?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 append data from two indexes in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/append-data-from-two-indexes/m-p/403270#M168705</link>
    <description>&lt;P&gt;i have two indexes:&lt;BR /&gt;
index#1 contain raw event log.&lt;BR /&gt;
from this event log i calc for every domain the number of events so that i have:&lt;BR /&gt;
domain_name description Event_count&lt;BR /&gt;
in this index i look at time span in the time span selection in search&lt;/P&gt;

&lt;P&gt;index#2 contain aggregated information on domain meaning for each domain i have query_count on each day&lt;BR /&gt;
in this index i calc more data for every domain_name&lt;BR /&gt;
in this index i look at time span of last 30 days&lt;/P&gt;

&lt;P&gt;what i want at the end of the day is that the query will return for me a table that will contain:&lt;BR /&gt;
event_domain Event_count    Dates_Count SumQueries  MaxQueries  avg30Days&lt;/P&gt;

&lt;P&gt;i tried to use join but some domain that appear in index2 don't appear after the join&lt;/P&gt;

&lt;P&gt;the query i use:&lt;BR /&gt;
index="event_raw_data" | join event_domain [search index="domain_agg_info" earliest=-30d | eval epoch33days_ago=relative_time(now(), "-33d@d" ) | eval epochEventDays = strptime(date,"%Y-%m-%d")  | where epochEventDays &amp;gt; epoch33days_ago | eventstats dc(date) as "Dates_Count" by event_domain| eventstats count(date) as "Record_count" by event_domain | eventstats max(query_count) as "MaxQueries" by date | eventstats max(Dates_Count) as "MaxDatesCount"| eventstats sum(query_count) as "SumQueries" by event_domain | eventstats avg(customer_count) as "AvgCustomerCount" by event_domain | eval AvgCustomerCount=round(AvgCustomerCount,0)| eval avg30Days=round(if(Record_count &amp;lt; 30,SumQueries/MaxDatesCount,SumQueries/Record_count)) | eval avg30Days=avg30Days+1 | eventstats max(query_count) as "MaxQueries" by event_domain | eval Ratio = round(MaxQueries/avg30Days,3) | where Ratio &amp;lt;= 5 ] | eventstats count as "Event_count" by event_domain  | table event_domain,Event_count,Dates_Count,AvgCustomerCount,Ratio,SumQueries,MaxQueries,avg30Days | dedup event_domain,Event_count,Dates_Count,AvgCustomerCount,Ratio,SumQueries,MaxQueries,avg30Days | sort by Event_count desc | head 10&lt;/P&gt;

&lt;P&gt;what i need to change to get this data for every domain on index1?&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 20:08:59 GMT</pubDate>
    <dc:creator>mcohen13</dc:creator>
    <dc:date>2020-09-29T20:08:59Z</dc:date>
    <item>
      <title>append data from two indexes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/append-data-from-two-indexes/m-p/403270#M168705</link>
      <description>&lt;P&gt;i have two indexes:&lt;BR /&gt;
index#1 contain raw event log.&lt;BR /&gt;
from this event log i calc for every domain the number of events so that i have:&lt;BR /&gt;
domain_name description Event_count&lt;BR /&gt;
in this index i look at time span in the time span selection in search&lt;/P&gt;

&lt;P&gt;index#2 contain aggregated information on domain meaning for each domain i have query_count on each day&lt;BR /&gt;
in this index i calc more data for every domain_name&lt;BR /&gt;
in this index i look at time span of last 30 days&lt;/P&gt;

&lt;P&gt;what i want at the end of the day is that the query will return for me a table that will contain:&lt;BR /&gt;
event_domain Event_count    Dates_Count SumQueries  MaxQueries  avg30Days&lt;/P&gt;

&lt;P&gt;i tried to use join but some domain that appear in index2 don't appear after the join&lt;/P&gt;

&lt;P&gt;the query i use:&lt;BR /&gt;
index="event_raw_data" | join event_domain [search index="domain_agg_info" earliest=-30d | eval epoch33days_ago=relative_time(now(), "-33d@d" ) | eval epochEventDays = strptime(date,"%Y-%m-%d")  | where epochEventDays &amp;gt; epoch33days_ago | eventstats dc(date) as "Dates_Count" by event_domain| eventstats count(date) as "Record_count" by event_domain | eventstats max(query_count) as "MaxQueries" by date | eventstats max(Dates_Count) as "MaxDatesCount"| eventstats sum(query_count) as "SumQueries" by event_domain | eventstats avg(customer_count) as "AvgCustomerCount" by event_domain | eval AvgCustomerCount=round(AvgCustomerCount,0)| eval avg30Days=round(if(Record_count &amp;lt; 30,SumQueries/MaxDatesCount,SumQueries/Record_count)) | eval avg30Days=avg30Days+1 | eventstats max(query_count) as "MaxQueries" by event_domain | eval Ratio = round(MaxQueries/avg30Days,3) | where Ratio &amp;lt;= 5 ] | eventstats count as "Event_count" by event_domain  | table event_domain,Event_count,Dates_Count,AvgCustomerCount,Ratio,SumQueries,MaxQueries,avg30Days | dedup event_domain,Event_count,Dates_Count,AvgCustomerCount,Ratio,SumQueries,MaxQueries,avg30Days | sort by Event_count desc | head 10&lt;/P&gt;

&lt;P&gt;what i need to change to get this data for every domain on index1?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 20:08:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/append-data-from-two-indexes/m-p/403270#M168705</guid>
      <dc:creator>mcohen13</dc:creator>
      <dc:date>2020-09-29T20:08:59Z</dc:date>
    </item>
    <item>
      <title>Re: append data from two indexes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/append-data-from-two-indexes/m-p/403271#M168706</link>
      <description>&lt;P&gt;hi, the default settings of join is inner, which is to say if you have 2 indexes A and B, you will get A intersection B if you use default join.&lt;BR /&gt;
If you want ALL values for the first index you need to specify | join type=left.&lt;BR /&gt;
I would advise you to look at other options in the join docs - &lt;A href="http://docs.splunk.com/Documentation/Splunk/7.1.1/SearchReference/Join"&gt;http://docs.splunk.com/Documentation/Splunk/7.1.1/SearchReference/Join&lt;/A&gt;&lt;BR /&gt;
AND&lt;BR /&gt;
do you really need a join? it has its own limitations&lt;/P&gt;</description>
      <pubDate>Tue, 26 Jun 2018 12:11:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/append-data-from-two-indexes/m-p/403271#M168706</guid>
      <dc:creator>Sukisen1981</dc:creator>
      <dc:date>2018-06-26T12:11:08Z</dc:date>
    </item>
    <item>
      <title>Re: append data from two indexes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/append-data-from-two-indexes/m-p/403272#M168707</link>
      <description>&lt;P&gt;thats not answering my problem&lt;BR /&gt;
i am familiar with join type=left but that also doesn't work properly.&lt;BR /&gt;
some domain names that are in both indexes (i checked) doesn't appear after the join (no matter which type of join)&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jun 2018 06:25:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/append-data-from-two-indexes/m-p/403272#M168707</guid>
      <dc:creator>mcohen13</dc:creator>
      <dc:date>2018-06-27T06:25:51Z</dc:date>
    </item>
    <item>
      <title>Re: append data from two indexes</title>
      <link>https://community.splunk.com/t5/Splunk-Search/append-data-from-two-indexes/m-p/403273#M168708</link>
      <description>&lt;P&gt;how many rows of data is the join running on?&lt;BR /&gt;
Also, you have a head10 at the end, could it be that the domain name you are expecting is getting trimmed by the head command?&lt;BR /&gt;
Suggest, run the query without head and see the job inspector, if the join is not able to pick data due to large volumes the job inspector will state the same.&lt;BR /&gt;
It will be helpful to get a mock of your data and expected output&lt;/P&gt;</description>
      <pubDate>Wed, 27 Jun 2018 06:45:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/append-data-from-two-indexes/m-p/403273#M168708</guid>
      <dc:creator>Sukisen1981</dc:creator>
      <dc:date>2018-06-27T06:45:52Z</dc:date>
    </item>
  </channel>
</rss>

