<?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: Convert this query to a data model in Knowledge Management</title>
    <link>https://community.splunk.com/t5/Knowledge-Management/Convert-this-query-to-a-data-model/m-p/349752#M2963</link>
    <description>&lt;P&gt;I see what you mean.  I changed it around based on your suggestions but now the index and log time columns do not populate.  Any idea why?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=* OR index=_
| convert ctime(_indextime) AS "Index Time"
| convert ctime(_time) AS "Log Time"
| eval lag=_time-_indextime
| stats avg(lag) as lag by source,host
| search lag&amp;gt;1000 OR lag&amp;lt;-1000
| table "Log Time","Index Time",lag,index,host,source
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 15 Mar 2018 17:07:06 GMT</pubDate>
    <dc:creator>DEAD_BEEF</dc:creator>
    <dc:date>2018-03-15T17:07:06Z</dc:date>
    <item>
      <title>Convert this query to a data model</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/Convert-this-query-to-a-data-model/m-p/349748#M2959</link>
      <description>&lt;P&gt;Hello all!  I am having problems understanding how to structure my query to a data model with the ultimate goal being for it to be an accelerated data model as the existing search takes much too long to run.  The problem I am having is breaking out my query into child queries from the root event and not understanding where to put the constraints (on the parent above or on the child).&lt;/P&gt;

&lt;P&gt;I ask that you take a look at this query and provide any input so I can better understand how to build this to an accelerated data model so that I can get the results of this query faster.  Maybe this isn't possible or doesn't benefit since I am searching across all indexes and just better to look at at scheduled search?  I use this query to find systems that have incorrect time zone settings.  Perhaps am I just not understanding what data models are for and attempting to use it in a way it was not designed.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=* OR index=_*
| dedup host,source
| eval lag=_time-_indextime
| search lag&amp;gt;1000 OR lag&amp;lt;-1000
| convert ctime(_indextime) AS "Index Time"
| convert ctime(_time) AS "Log Time"
|table "Log Time","Index Time",lag,index,host,source
| rename range AS TZ
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 14 Mar 2018 20:22:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/Convert-this-query-to-a-data-model/m-p/349748#M2959</guid>
      <dc:creator>DEAD_BEEF</dc:creator>
      <dc:date>2018-03-14T20:22:58Z</dc:date>
    </item>
    <item>
      <title>Re: Convert this query to a data model</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/Convert-this-query-to-a-data-model/m-p/349749#M2960</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;

&lt;P&gt;Creating a datamodel for a single query seems too much. Why don't you save it as a scheduled search and accelerate it?&lt;/P&gt;</description>
      <pubDate>Wed, 14 Mar 2018 22:24:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/Convert-this-query-to-a-data-model/m-p/349749#M2960</guid>
      <dc:creator>tiagofbmm</dc:creator>
      <dc:date>2018-03-14T22:24:57Z</dc:date>
    </item>
    <item>
      <title>Re: Convert this query to a data model</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/Convert-this-query-to-a-data-model/m-p/349750#M2961</link>
      <description>&lt;P&gt;Hmm, looks like it can't be accelerated because it doesn't have a transforming command.  Trying to rewrite the query to include one to check the box.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Mar 2018 12:34:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/Convert-this-query-to-a-data-model/m-p/349750#M2961</guid>
      <dc:creator>DEAD_BEEF</dc:creator>
      <dc:date>2018-03-15T12:34:16Z</dc:date>
    </item>
    <item>
      <title>Re: Convert this query to a data model</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/Convert-this-query-to-a-data-model/m-p/349751#M2962</link>
      <description>&lt;P&gt;You query seems to not be very accurate. dedup host and source will give you one specific value for that, and if you are trying to understand the lag time of a (source,host) pair, you;d do some stats first.&lt;/P&gt;

&lt;P&gt;index=* OR index=_*&lt;BR /&gt;
 | eval lag=_time-_indextime&lt;BR /&gt;
 | stats avg(lag) as lag by source,host&lt;BR /&gt;
 | search lag&amp;gt;1000 OR lag&amp;lt;-1000&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 18:32:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/Convert-this-query-to-a-data-model/m-p/349751#M2962</guid>
      <dc:creator>tiagofbmm</dc:creator>
      <dc:date>2020-09-29T18:32:53Z</dc:date>
    </item>
    <item>
      <title>Re: Convert this query to a data model</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/Convert-this-query-to-a-data-model/m-p/349752#M2963</link>
      <description>&lt;P&gt;I see what you mean.  I changed it around based on your suggestions but now the index and log time columns do not populate.  Any idea why?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=* OR index=_
| convert ctime(_indextime) AS "Index Time"
| convert ctime(_time) AS "Log Time"
| eval lag=_time-_indextime
| stats avg(lag) as lag by source,host
| search lag&amp;gt;1000 OR lag&amp;lt;-1000
| table "Log Time","Index Time",lag,index,host,source
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 15 Mar 2018 17:07:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/Convert-this-query-to-a-data-model/m-p/349752#M2963</guid>
      <dc:creator>DEAD_BEEF</dc:creator>
      <dc:date>2018-03-15T17:07:06Z</dc:date>
    </item>
    <item>
      <title>Re: Convert this query to a data model</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/Convert-this-query-to-a-data-model/m-p/349753#M2964</link>
      <description>&lt;P&gt;Sorry maybe I was no clear enough. &lt;/P&gt;

&lt;P&gt;The &lt;STRONG&gt;stats&lt;/STRONG&gt; I put there was to help you get some more information than just what you had with &lt;STRONG&gt;dedup&lt;/STRONG&gt; (which gave you information only from one event per (source,host) pair).&lt;/P&gt;

&lt;P&gt;I think you have two paths here. Either you want to see the Log_Time, Index_Time for all the events, and you can do the following (which is messy as it shows you all the events:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=* OR index=_
 | convert ctime(_indextime) AS "Index Time"
 | convert ctime(_time) AS "Log Time"
 | eval lag=_time-_indextime
 | search lag&amp;gt;1000 OR lag&amp;lt;-1000
 | table "Log Time","Index Time",lag,index,host,source
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;What I would do is make some stats on top of that lag, &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=* OR index=_
 | convert ctime(_indextime) AS "Index Time"
 | convert ctime(_time) AS "Log Time"
 | eval lag=_time-_indextime
 | bucket _time
 | stats avg(lag) as lag by source,host, "Index Time"
 | search lag&amp;gt;1000 OR lag&amp;lt;-1000
 | table  "Index Time",lag,index,host,source
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I believe this last one gives you the information you actually are looking for.&lt;/P&gt;

&lt;P&gt;Let me know&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 18:33:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/Convert-this-query-to-a-data-model/m-p/349753#M2964</guid>
      <dc:creator>tiagofbmm</dc:creator>
      <dc:date>2020-09-29T18:33:04Z</dc:date>
    </item>
    <item>
      <title>Re: Convert this query to a data model</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/Convert-this-query-to-a-data-model/m-p/349754#M2965</link>
      <description>&lt;P&gt;Yup, the second query was what I was looking for.  Much appreciated!&lt;/P&gt;</description>
      <pubDate>Mon, 19 Mar 2018 19:43:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/Convert-this-query-to-a-data-model/m-p/349754#M2965</guid>
      <dc:creator>DEAD_BEEF</dc:creator>
      <dc:date>2018-03-19T19:43:32Z</dc:date>
    </item>
  </channel>
</rss>

