<?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: Looking for dc and then sum of field in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-dc-and-then-sum-of-field/m-p/639200#M221479</link>
    <description>&lt;P&gt;Thanks,&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/231884"&gt;@PickleRick&lt;/a&gt;&amp;nbsp;for your reply.&lt;/P&gt;&lt;P&gt;I think your query works. Let me confirm.&lt;/P&gt;&lt;P&gt;Basically, I want to sum(vm_unit) on an hourly basis, by ignoring duplicate entries in an hour.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 07 Apr 2023 12:43:08 GMT</pubDate>
    <dc:creator>Sathiya123</dc:creator>
    <dc:date>2023-04-07T12:43:08Z</dc:date>
    <item>
      <title>How to get dc and then sum of field?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-dc-and-then-sum-of-field/m-p/639071#M221434</link>
      <description>&lt;PRE&gt;&amp;lt;search&amp;gt;&lt;BR /&gt;| eval vm_unit=case(vmSize="Standard_F16s_v2",2,vmSize="Standard_F8s_v2",1,vmSize="Standard_F4s",0.5,vmSize="Standard_F2s_v2",0.25)
| timechart span=1h dc(vm_name) sum(vm_unit) as USED_VMS&lt;/PRE&gt;
&lt;P&gt;Looking for the sum of vm_unit for distinct VM's by the hour. But it considers all the VM's instead of distinct VM's.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Apr 2023 16:50:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-dc-and-then-sum-of-field/m-p/639071#M221434</guid>
      <dc:creator>Sathiya123</dc:creator>
      <dc:date>2023-04-10T16:50:35Z</dc:date>
    </item>
    <item>
      <title>Re: Looking for dc and then sum of field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-dc-and-then-sum-of-field/m-p/639095#M221438</link>
      <description>&lt;P&gt;Like this:&lt;BR /&gt;&lt;BR /&gt;...&amp;nbsp;| timechart span=1h sum(vm_unit) AS USED_VMS BY vm_name&lt;/P&gt;</description>
      <pubDate>Thu, 06 Apr 2023 20:45:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-dc-and-then-sum-of-field/m-p/639095#M221438</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2023-04-06T20:45:07Z</dc:date>
    </item>
    <item>
      <title>Re: Looking for dc and then sum of field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-dc-and-then-sum-of-field/m-p/639163#M221460</link>
      <description>&lt;P&gt;Thanks,&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/1406"&gt;@woodcock&lt;/a&gt;&amp;nbsp; for your reply!&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;What I am expecting&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Sathiya123_0-1680847554023.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/24835iA78A6FC561F52CAD/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Sathiya123_0-1680847554023.png" alt="Sathiya123_0-1680847554023.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;But what I am getting&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Sathiya123_1-1680847650186.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/24836iEE6CD84A4A64C5A9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Sathiya123_1-1680847650186.png" alt="Sathiya123_1-1680847650186.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Apr 2023 06:07:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-dc-and-then-sum-of-field/m-p/639163#M221460</guid>
      <dc:creator>Sathiya123</dc:creator>
      <dc:date>2023-04-07T06:07:54Z</dc:date>
    </item>
    <item>
      <title>Re: Looking for dc and then sum of field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-dc-and-then-sum-of-field/m-p/639170#M221462</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/255628"&gt;@Sathiya123&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;if you want the sume of vm_unit for each VM, the solution fom&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/1406"&gt;@woodcock&lt;/a&gt;&amp;nbsp;is the correct one.&lt;/P&gt;&lt;P&gt;If instead (as it seems from yur example) you want both the sum of VMs and the count of distinct VMs for each time unit, you could use stats instead timechart, because timechart permits to display only one value for each time unit, something like this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;search&amp;gt;
| eval vm_unit=case(vmSize="Standard_F16s_v2",2,vmSize="Standard_F8s_v2",1,vmSize="Standard_F4s",0.5,vmSize="Standard_F2s_v2",0.25)
| bin span=1h _time
| stats dc(vm_name) AS vm_name_count sum(vm_unit) AS USED_VMS BY _time&lt;/LI-CODE&gt;&lt;P&gt;Ciao.&lt;/P&gt;&lt;P&gt;Giuseppe&lt;/P&gt;</description>
      <pubDate>Fri, 07 Apr 2023 07:25:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-dc-and-then-sum-of-field/m-p/639170#M221462</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2023-04-07T07:25:50Z</dc:date>
    </item>
    <item>
      <title>Re: Looking for dc and then sum of field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-dc-and-then-sum-of-field/m-p/639178#M221465</link>
      <description>&lt;P&gt;Is this what you were after?&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;search&amp;gt;
| eval vm_unit=case(vmSize="Standard_F16s_v2",2,vmSize="Standard_F8s_v2",1,vmSize="Standard_F4s",0.5,vmSize="Standard_F2s_v2",0.25)
| bin _time span=1h
| stats values(vm_unit) as vm_unit by _time vm_name
| stats dc(vm_name) as vm_count sum(vm_unit) as USED_VMS by _time&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 07 Apr 2023 08:28:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-dc-and-then-sum-of-field/m-p/639178#M221465</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2023-04-07T08:28:52Z</dc:date>
    </item>
    <item>
      <title>Re: Looking for dc and then sum of field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-dc-and-then-sum-of-field/m-p/639191#M221475</link>
      <description>&lt;P&gt;Thanks,&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/161352"&gt;@gcusello&lt;/a&gt;&amp;nbsp;for replying.&lt;/P&gt;&lt;P&gt;Your query provides the same output as mine.&lt;/P&gt;&lt;P&gt;The issue here is that events got duplicated in our Splunk index for some reason.&lt;/P&gt;&lt;P&gt;In a given hour,&amp;nbsp; there should not be two events for the same vm_name.&lt;/P&gt;&lt;P&gt;In order to solve the duplicate issue I am using dc(vm_name) thinking that sum(vm_unit) will avoid the duplicate entries. But in my case sum(vm_unit) includes the duplicate entries.&lt;/P&gt;&lt;P&gt;For e.g. consider all my vm entries are duplicated twice.&lt;/P&gt;&lt;P&gt;_time count(vm_name) sum(vm_unit) ==&amp;gt; _time 120 200&lt;/P&gt;&lt;P&gt;My expectation is&amp;nbsp;&lt;/P&gt;&lt;P&gt;_time dc(vm_name) sum(vm_unit) ==&amp;gt; _time 60 100&lt;/P&gt;&lt;P&gt;Any help is highly appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Apr 2023 10:29:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-dc-and-then-sum-of-field/m-p/639191#M221475</guid>
      <dc:creator>Sathiya123</dc:creator>
      <dc:date>2023-04-07T10:29:46Z</dc:date>
    </item>
    <item>
      <title>Re: Looking for dc and then sum of field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-dc-and-then-sum-of-field/m-p/639192#M221476</link>
      <description>&lt;P&gt;If you do a single stats command with two different aggregation functions, they are performed separately. So dc() counts distinct values and sum() sums _all_ values. That's how it works.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Apr 2023 10:58:35 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-dc-and-then-sum-of-field/m-p/639192#M221476</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2023-04-07T10:58:35Z</dc:date>
    </item>
    <item>
      <title>Re: Looking for dc and then sum of field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-dc-and-then-sum-of-field/m-p/639193#M221477</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/231884"&gt;@PickleRick&lt;/a&gt;&amp;nbsp;Thanks for your reply.&lt;BR /&gt;&lt;BR /&gt;I agree with your statement.&lt;/P&gt;&lt;P&gt;But how to form the Splunk query to get my expected results?&lt;/P&gt;</description>
      <pubDate>Fri, 07 Apr 2023 11:05:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-dc-and-then-sum-of-field/m-p/639193#M221477</guid>
      <dc:creator>Sathiya123</dc:creator>
      <dc:date>2023-04-07T11:05:26Z</dc:date>
    </item>
    <item>
      <title>Re: Looking for dc and then sum of field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-dc-and-then-sum-of-field/m-p/639195#M221478</link>
      <description>&lt;P&gt;To be fully honest, I'm not sure what you want to achieve and what your data looks like. I'll assume that your events have vm_name and vm_unit fields and vm_unit is always the same for given vm_name and you want to count number of disctinct vm_names and sum of corresponding vm_units. Is that right?&lt;/P&gt;&lt;PRE&gt;&amp;lt;your_base_search&amp;gt;&lt;BR /&gt;| bin _time span=1h&lt;BR /&gt;| stats values(vm_unit) as vm_unit by _time vm_name&lt;BR /&gt;| stats dc(vm_name) sum(vm_unit)&amp;nbsp; by _time&lt;/PRE&gt;&lt;P&gt;You can also probably use dedup but I don't like that command and don't use it much so don't remember the syntax&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Apr 2023 11:41:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-dc-and-then-sum-of-field/m-p/639195#M221478</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2023-04-07T11:41:07Z</dc:date>
    </item>
    <item>
      <title>Re: Looking for dc and then sum of field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-dc-and-then-sum-of-field/m-p/639200#M221479</link>
      <description>&lt;P&gt;Thanks,&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/231884"&gt;@PickleRick&lt;/a&gt;&amp;nbsp;for your reply.&lt;/P&gt;&lt;P&gt;I think your query works. Let me confirm.&lt;/P&gt;&lt;P&gt;Basically, I want to sum(vm_unit) on an hourly basis, by ignoring duplicate entries in an hour.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Apr 2023 12:43:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-dc-and-then-sum-of-field/m-p/639200#M221479</guid>
      <dc:creator>Sathiya123</dc:creator>
      <dc:date>2023-04-07T12:43:08Z</dc:date>
    </item>
    <item>
      <title>Re: Looking for dc and then sum of field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-dc-and-then-sum-of-field/m-p/639202#M221480</link>
      <description>&lt;P&gt;That's where your wording is a bit confusing. Because - as far as I understand - you can have several vm_names with the same vm_unit. Otherwise it kinda doesn't make sense to sum some unrelated values as long as they're unique.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Apr 2023 12:45:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-dc-and-then-sum-of-field/m-p/639202#M221480</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2023-04-07T12:45:51Z</dc:date>
    </item>
    <item>
      <title>Re: Looking for dc and then sum of field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-dc-and-then-sum-of-field/m-p/639207#M221483</link>
      <description>&lt;P&gt;For e.g.&lt;/P&gt;&lt;P&gt;Events are like below:&lt;/P&gt;&lt;P&gt;TIME&amp;nbsp; |&amp;nbsp; VM_NAME&amp;nbsp; |&amp;nbsp; VM_UNIT&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2023-03-08 01:05&amp;nbsp; | MONGO_VM |&amp;nbsp; 1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2023-03-08 01:10&amp;nbsp; | NODE_VM&amp;nbsp; &amp;nbsp; &amp;nbsp;|&amp;nbsp; 2&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2023-03-08 01:05&amp;nbsp; | MONGO_VM |&amp;nbsp; 1&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;The splunk query should return SUM(VM_UNIT):&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;TIME&amp;nbsp; |&amp;nbsp; SUM(VM_UNIT)&lt;BR /&gt;&lt;BR /&gt;2023-03-08 01:00&amp;nbsp; |&amp;nbsp; 3&lt;BR /&gt;&lt;BR /&gt;3rd event has to&amp;nbsp; ignored since its duplicate of 1st event. Hope its clear.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Apr 2023 14:04:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-dc-and-then-sum-of-field/m-p/639207#M221483</guid>
      <dc:creator>Sathiya123</dc:creator>
      <dc:date>2023-04-07T14:04:14Z</dc:date>
    </item>
    <item>
      <title>Re: Looking for dc and then sum of field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-dc-and-then-sum-of-field/m-p/639212#M221486</link>
      <description>&lt;P&gt;That's what I thought. More or less. In your example both events have the same time. I suppose in real data the timestamp can differ.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Apr 2023 14:29:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-dc-and-then-sum-of-field/m-p/639212#M221486</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2023-04-07T14:29:47Z</dc:date>
    </item>
    <item>
      <title>Re: Looking for dc and then sum of field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-dc-and-then-sum-of-field/m-p/639218#M221487</link>
      <description>&lt;P&gt;Don't use pictures; use text.&amp;nbsp; Your images are not showing.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Apr 2023 15:25:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-dc-and-then-sum-of-field/m-p/639218#M221487</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2023-04-07T15:25:29Z</dc:date>
    </item>
    <item>
      <title>Re: Looking for dc and then sum of field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-dc-and-then-sum-of-field/m-p/639228#M221491</link>
      <description>&lt;P&gt;There must be something with your browser. The pictures are OK.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Apr 2023 16:46:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-dc-and-then-sum-of-field/m-p/639228#M221491</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2023-04-07T16:46:39Z</dc:date>
    </item>
    <item>
      <title>Re: Looking for dc and then sum of field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-dc-and-then-sum-of-field/m-p/639233#M221493</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/231884"&gt;@PickleRick&lt;/a&gt;&amp;nbsp;Thanks a ton! It worked!&lt;BR /&gt;&lt;BR /&gt;Got my query, just putting it here so that it will be helpful to others.&lt;BR /&gt;&lt;BR /&gt;&amp;lt;search&amp;gt;&lt;BR /&gt;| eval vm_unit=case(vmSize="Standard_F16s_v2",2,vmSize="Standard_F8s_v2",1,vmSize="Standard_F4s",0.5,vmSize="Standard_F2s_v2",0.25)&lt;BR /&gt;| bin _time span=1h&lt;BR /&gt;| stats values(vm_unit) as vm_unit values(location) as location by _time id&lt;BR /&gt;| timechart span=1h usenull=true sum(vm_unit) as vm_count by location&lt;BR /&gt;| fillnull value=0&lt;/P&gt;</description>
      <pubDate>Fri, 07 Apr 2023 17:23:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-dc-and-then-sum-of-field/m-p/639233#M221493</guid>
      <dc:creator>Sathiya123</dc:creator>
      <dc:date>2023-04-07T17:23:09Z</dc:date>
    </item>
    <item>
      <title>Re: Looking for dc and then sum of field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-dc-and-then-sum-of-field/m-p/639237#M221496</link>
      <description>&lt;P&gt;This made me smile - the accepted solution looks remarkably similar to my solution posted 3 hours prior to this&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":beaming_face_with_smiling_eyes:"&gt;😁&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Apr 2023 18:52:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-dc-and-then-sum-of-field/m-p/639237#M221496</guid>
      <dc:creator>ITWhisperer</dc:creator>
      <dc:date>2023-04-07T18:52:18Z</dc:date>
    </item>
    <item>
      <title>Re: Looking for dc and then sum of field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-dc-and-then-sum-of-field/m-p/639240#M221497</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/225168"&gt;@ITWhisperer&lt;/a&gt;&amp;nbsp; Apologise, somehow I missed your reply, otherwise, I would have replied back on that thread.&lt;/P&gt;&lt;P&gt;Thanks again. Given thumps up to your reply.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Apr 2023 19:00:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-dc-and-then-sum-of-field/m-p/639240#M221497</guid>
      <dc:creator>Sathiya123</dc:creator>
      <dc:date>2023-04-07T19:00:15Z</dc:date>
    </item>
    <item>
      <title>Re: Looking for dc and then sum of field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-get-dc-and-then-sum-of-field/m-p/639246#M221498</link>
      <description>&lt;P&gt;True. I must say I didn't read into your answer because I didn't understand the question at that moment XD&lt;/P&gt;</description>
      <pubDate>Fri, 07 Apr 2023 19:48:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-get-dc-and-then-sum-of-field/m-p/639246#M221498</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2023-04-07T19:48:50Z</dc:date>
    </item>
  </channel>
</rss>

