<?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: How come our tstats with datamodel does not group by field? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-come-our-tstats-with-datamodel-does-not-group-by-field/m-p/401491#M116224</link>
    <description>&lt;P&gt;OK, we figured out the exact syntax: our datamodel has an object named "Package", which has such extracted fields as "length", "width", "height" and a calculated "tot_dim" which is a sum of the three dimensions. It also has a "token" field, which for some reason is not extracted properly, so I tested the GROUPBY syntax on some other field.&lt;/P&gt;

&lt;P&gt;All in all, it looks like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| tstats count first(Package.tot_dim) AS tot_dim1 last(Package.tot_dim) AS tot_dim2
from datamodel=Our_Datamodel
where index=our_index
by Package.token
| search count=2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Shall we agree that some of Splunks intricacies are somewhat underdocumented? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Oh, and we are still in 6.6.2 - though I doubt it changes much in the latest version.&lt;/P&gt;</description>
    <pubDate>Thu, 10 Jan 2019 17:57:09 GMT</pubDate>
    <dc:creator>arkadyz1</dc:creator>
    <dc:date>2019-01-10T17:57:09Z</dc:date>
    <item>
      <title>How come our tstats with datamodel does not group by field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-come-our-tstats-with-datamodel-does-not-group-by-field/m-p/401484#M116217</link>
      <description>&lt;P&gt;We have an index with quite a few index-time fields, and an accelerated datamodel that adds a calculated field there. Our objective is to group by one of the fields, find the first and the last value of some other field and compare them. Unfortunately, a usual &lt;CODE&gt;| tstats first(length) as length1 last(length) as length2 from datamodel=ourdatamodel groupby token&lt;/CODE&gt; does not work.&lt;/P&gt;

&lt;P&gt;Just &lt;CODE&gt;tstats&lt;/CODE&gt; using the index but not the data model works, but it lacks that calculated field that's only in the datamodel, so it does not satisfy our needs.&lt;/P&gt;

&lt;P&gt;I can add more precise search strings as replies to clarify things if needed.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Jan 2019 21:59:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-come-our-tstats-with-datamodel-does-not-group-by-field/m-p/401484#M116217</guid>
      <dc:creator>arkadyz1</dc:creator>
      <dc:date>2019-01-09T21:59:25Z</dc:date>
    </item>
    <item>
      <title>Re: How come our tstats with datamodel does not group by field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-come-our-tstats-with-datamodel-does-not-group-by-field/m-p/401485#M116218</link>
      <description>&lt;P&gt;Does your datamodel tstats search work without &lt;CODE&gt;groupby&lt;/CODE&gt;? &lt;/P&gt;</description>
      <pubDate>Thu, 10 Jan 2019 03:05:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-come-our-tstats-with-datamodel-does-not-group-by-field/m-p/401485#M116218</guid>
      <dc:creator>dflodstrom</dc:creator>
      <dc:date>2019-01-10T03:05:17Z</dc:date>
    </item>
    <item>
      <title>Re: How come our tstats with datamodel does not group by field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-come-our-tstats-with-datamodel-does-not-group-by-field/m-p/401486#M116219</link>
      <description>&lt;P&gt;The &lt;CODE&gt;length&lt;/CODE&gt; and &lt;CODE&gt;token&lt;/CODE&gt; fields are in the datamodel, right?  If so, it should be:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| tstats first(Our_Datamodel.length) AS length1 last(Our_Datamodel.length) AS length2
FROM datamodel=ourdatamodel
WHERE index=*
BY Our_Datamodel.token
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 10 Jan 2019 03:18:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-come-our-tstats-with-datamodel-does-not-group-by-field/m-p/401486#M116219</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-01-10T03:18:34Z</dc:date>
    </item>
    <item>
      <title>Re: How come our tstats with datamodel does not group by field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-come-our-tstats-with-datamodel-does-not-group-by-field/m-p/401487#M116220</link>
      <description>&lt;P&gt;Not sure - never tried it, as we need that by/groupby anyway. I think our mistake was a wrong field notation - we did not realize that datamodel fields are referenced as &lt;CODE&gt;datamodelname.fieldname&lt;/CODE&gt;. Thanks to @woodcock 's answer below, we realized our mistake.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jan 2019 15:07:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-come-our-tstats-with-datamodel-does-not-group-by-field/m-p/401487#M116220</guid>
      <dc:creator>arkadyz1</dc:creator>
      <dc:date>2019-01-10T15:07:51Z</dc:date>
    </item>
    <item>
      <title>Re: How come our tstats with datamodel does not group by field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-come-our-tstats-with-datamodel-does-not-group-by-field/m-p/401488#M116221</link>
      <description>&lt;P&gt;Could you please clarify: if our datamodel is named "Our Datamodel" with internal name &lt;CODE&gt;Our_Datamodel&lt;/CODE&gt;, it has an event named &lt;CODE&gt;Event&lt;/CODE&gt; and in it are a couple of fields named &lt;CODE&gt;length&lt;/CODE&gt; and &lt;CODE&gt;token&lt;/CODE&gt;, what would be our search string?&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jan 2019 15:57:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-come-our-tstats-with-datamodel-does-not-group-by-field/m-p/401488#M116221</guid>
      <dc:creator>arkadyz1</dc:creator>
      <dc:date>2019-01-10T15:57:44Z</dc:date>
    </item>
    <item>
      <title>Re: How come our tstats with datamodel does not group by field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-come-our-tstats-with-datamodel-does-not-group-by-field/m-p/401489#M116222</link>
      <description>&lt;P&gt;I have updated my answer with what should probably work.  If you post your &lt;CODE&gt;Our_Datamodel.json&lt;/CODE&gt; then I can say for sure.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jan 2019 16:13:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-come-our-tstats-with-datamodel-does-not-group-by-field/m-p/401489#M116222</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-01-10T16:13:51Z</dc:date>
    </item>
    <item>
      <title>Re: How come our tstats with datamodel does not group by field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-come-our-tstats-with-datamodel-does-not-group-by-field/m-p/401490#M116223</link>
      <description>&lt;P&gt;If an answer or comment has helped you, then you should &lt;CODE&gt;UpVote&lt;/CODE&gt; it; if it solved it for you, then you should click &lt;CODE&gt;Accept&lt;/CODE&gt; to close the question.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jan 2019 16:15:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-come-our-tstats-with-datamodel-does-not-group-by-field/m-p/401490#M116223</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-01-10T16:15:49Z</dc:date>
    </item>
    <item>
      <title>Re: How come our tstats with datamodel does not group by field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-come-our-tstats-with-datamodel-does-not-group-by-field/m-p/401491#M116224</link>
      <description>&lt;P&gt;OK, we figured out the exact syntax: our datamodel has an object named "Package", which has such extracted fields as "length", "width", "height" and a calculated "tot_dim" which is a sum of the three dimensions. It also has a "token" field, which for some reason is not extracted properly, so I tested the GROUPBY syntax on some other field.&lt;/P&gt;

&lt;P&gt;All in all, it looks like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| tstats count first(Package.tot_dim) AS tot_dim1 last(Package.tot_dim) AS tot_dim2
from datamodel=Our_Datamodel
where index=our_index
by Package.token
| search count=2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Shall we agree that some of Splunks intricacies are somewhat underdocumented? &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;Oh, and we are still in 6.6.2 - though I doubt it changes much in the latest version.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jan 2019 17:57:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-come-our-tstats-with-datamodel-does-not-group-by-field/m-p/401491#M116224</guid>
      <dc:creator>arkadyz1</dc:creator>
      <dc:date>2019-01-10T17:57:09Z</dc:date>
    </item>
    <item>
      <title>Re: How come our tstats with datamodel does not group by field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-come-our-tstats-with-datamodel-does-not-group-by-field/m-p/401492#M116225</link>
      <description>&lt;P&gt;I voted up an answer by @woodcock as it gave us the right idea. Here is the syntax that works:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | tstats count first(Package.tot_dim) AS tot_dim1 last(Package.tot_dim) AS tot_dim2
 from datamodel=Our_Datamodel
 where index=our_index
 by Package.token
 | search count=2
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now for the details: we have a datamodel named &lt;CODE&gt;Our_Datamodel&lt;/CODE&gt; (make sure you refer to its internal name, not display name), an object named &lt;CODE&gt;Package&lt;/CODE&gt; within it and fields named &lt;CODE&gt;tot_dim&lt;/CODE&gt; and &lt;CODE&gt;token&lt;/CODE&gt;. The &lt;CODE&gt;| search count=2&lt;/CODE&gt; addition is for illustration only - you can pipe the tstats command into many other commands.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jan 2019 18:15:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-come-our-tstats-with-datamodel-does-not-group-by-field/m-p/401492#M116225</guid>
      <dc:creator>arkadyz1</dc:creator>
      <dc:date>2019-01-10T18:15:46Z</dc:date>
    </item>
    <item>
      <title>Re: How come our tstats with datamodel does not group by field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-come-our-tstats-with-datamodel-does-not-group-by-field/m-p/401493#M116226</link>
      <description>&lt;P&gt;Perfect.  Be sure to &lt;CODE&gt;UpVote&lt;/CODE&gt; and helpful comments and answers and the click on &lt;CODE&gt;Accept&lt;/CODE&gt; to the best answer to close the question.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jan 2019 19:01:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-come-our-tstats-with-datamodel-does-not-group-by-field/m-p/401493#M116226</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2019-01-10T19:01:32Z</dc:date>
    </item>
  </channel>
</rss>

