<?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 Optimize query by referring latest source data in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Optimize-query-by-referring-latest-source-data/m-p/276296#M190343</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;Here are the three sources that I have for the below query that I need to optimize :&lt;BR /&gt;
a) tech_detail.gz b) group_member.gz c) tech_summary.gz.&lt;BR /&gt;
Data is populated on daily basis for the above sources.&lt;/P&gt;

&lt;P&gt;As seen below in the query, I am considering only the latest available data in the month for "tech_detail" source using "stats latest(source) as source". My requirement is  to have only the latest source data events for other two sources too(group_memeber.gz and tech_summary.gz) so as improve the performance by using the smaller set of latest data instead of all the data that I have presently use&lt;/P&gt;

&lt;P&gt;I could not get how "stats latest(source) as source by date_month" can be used for the other two sources. How can the  query be modified to use the latest source data file in the month for the other two sources(group_member.gz and tech_summary.gz) in the query . &lt;/P&gt;

&lt;P&gt;$indexString$ sourcetype=cache-v2  source="*tech_detail*" [search $indexString$ sourcetype=cache-v2  source="*tech_detail*" |eval date_month=strftime(_time,"%b")|stats latest(source) as source by date_month|stats values(source) as source]  | join deviceId[search  $indexString$ sourcetype=cache-v2 source="*group_member*" groupId="$group$" ] |  join RuleId [search  $indexString$ sourcetype=cache-v2 source="*tech_summary*" ]  | rex mode=sed field="PrimaryTechnology" "s/^*//" | &lt;BR /&gt;
rex mode=sed field="PrimaryTechnology" "s/^.*//" |stats values(PrimaryTechnology) as PrimaryTechnology |   mvexpand PrimaryTechnology&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 09:19:09 GMT</pubDate>
    <dc:creator>amoldesai</dc:creator>
    <dc:date>2020-09-29T09:19:09Z</dc:date>
    <item>
      <title>Optimize query by referring latest source data</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Optimize-query-by-referring-latest-source-data/m-p/276296#M190343</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;Here are the three sources that I have for the below query that I need to optimize :&lt;BR /&gt;
a) tech_detail.gz b) group_member.gz c) tech_summary.gz.&lt;BR /&gt;
Data is populated on daily basis for the above sources.&lt;/P&gt;

&lt;P&gt;As seen below in the query, I am considering only the latest available data in the month for "tech_detail" source using "stats latest(source) as source". My requirement is  to have only the latest source data events for other two sources too(group_memeber.gz and tech_summary.gz) so as improve the performance by using the smaller set of latest data instead of all the data that I have presently use&lt;/P&gt;

&lt;P&gt;I could not get how "stats latest(source) as source by date_month" can be used for the other two sources. How can the  query be modified to use the latest source data file in the month for the other two sources(group_member.gz and tech_summary.gz) in the query . &lt;/P&gt;

&lt;P&gt;$indexString$ sourcetype=cache-v2  source="*tech_detail*" [search $indexString$ sourcetype=cache-v2  source="*tech_detail*" |eval date_month=strftime(_time,"%b")|stats latest(source) as source by date_month|stats values(source) as source]  | join deviceId[search  $indexString$ sourcetype=cache-v2 source="*group_member*" groupId="$group$" ] |  join RuleId [search  $indexString$ sourcetype=cache-v2 source="*tech_summary*" ]  | rex mode=sed field="PrimaryTechnology" "s/^*//" | &lt;BR /&gt;
rex mode=sed field="PrimaryTechnology" "s/^.*//" |stats values(PrimaryTechnology) as PrimaryTechnology |   mvexpand PrimaryTechnology&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 09:19:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Optimize-query-by-referring-latest-source-data/m-p/276296#M190343</guid>
      <dc:creator>amoldesai</dc:creator>
      <dc:date>2020-09-29T09:19:09Z</dc:date>
    </item>
    <item>
      <title>Re: Optimize query by referring latest source data</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Optimize-query-by-referring-latest-source-data/m-p/276297#M190344</link>
      <description>&lt;P&gt;Try like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;$indexString$ sourcetype=cache-v2 [| tstats count WHERE $indexString$ sourcetype=cache-v2 source="*tech_detail*" by source _time span=1mon |stats latest(source) as source by _time |table source] 
| join deviceId[search $indexString$ sourcetype=cache-v2 source="*group_member*" groupId="$group$" [search $indexString$ sourcetype=cache-v2 source="*group_member*" groupId="$group$"  | bucket span=1mon _time |stats latest(source) as source by  _time |table source] ] 
| join RuleId [search $indexString$ sourcetype=cache-v2 source="*tech_summary*"  [| tstats count WHERE  $indexString$ sourcetype=cache-v2 source="*tech_summary*"  by source _time span=1mon |stats latest(source) as source by _time |table source] ] | rex mode=sed field="PrimaryTechnology" "s/^*//" | 
rex mode=sed field="PrimaryTechnology" "s/\^.*//" |stats values(PrimaryTechnology) as PrimaryTechnology | mvexpand PrimaryTechnology
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 06 Apr 2016 14:54:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Optimize-query-by-referring-latest-source-data/m-p/276297#M190344</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-04-06T14:54:17Z</dc:date>
    </item>
    <item>
      <title>Re: Optimize query by referring latest source data</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Optimize-query-by-referring-latest-source-data/m-p/276298#M190345</link>
      <description>&lt;P&gt;Thanks a lot&lt;/P&gt;</description>
      <pubDate>Sat, 09 Apr 2016 04:58:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Optimize-query-by-referring-latest-source-data/m-p/276298#M190345</guid>
      <dc:creator>amoldesai</dc:creator>
      <dc:date>2016-04-09T04:58:19Z</dc:date>
    </item>
  </channel>
</rss>

