<?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 How to rewrite query to sum both fields based on another field in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-rewrite-query-to-sum-both-fields-based-on-another-field/m-p/304105#M160209</link>
    <description>&lt;P&gt;Hi All,&lt;/P&gt;

&lt;P&gt;Here is a query which returns me DATA size and Index size based on domain.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=db_connect sourcetype=db_metric |join TABLE_NAME [|inputlookup Domain_Module_List.csv |search (Domain ="Inventory")] |eval DATA_MB =round(DATA_KB/1024,2) |eval INDEX_MB = round(INDEX_SIZE_KB/1024,2) |timechart span=1mon sum(DATA_MB),sum(INDEX_MB) by Domain limit=25
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I tried to do a sum of DATA and INDEX by rewriting the above query as &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=db_connect sourcetype=db_metric |join TABLE_NAME [|inputlookup Domain_Module_List.csv |search (Domain ="Inventory")] |eval DATA_MB =(DATA_KB/1024) |eval INDEX_MB = (INDEX_SIZE_KB/1024) |eval SIZE = round((DATA_MB + INDEX_MB),2) |timechart span=1mon sum(SIZE) by Domain
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But this doesn't result correct value when validated. I think i am wrong somewhere in the syntax of summing up query.&lt;/P&gt;

&lt;P&gt;How do I sum both DATA and Index together and display the result ? &lt;/P&gt;

&lt;P&gt;Thanks&lt;BR /&gt;
Sangeetha&lt;/P&gt;</description>
    <pubDate>Wed, 12 Jul 2017 05:14:52 GMT</pubDate>
    <dc:creator>sangs8788</dc:creator>
    <dc:date>2017-07-12T05:14:52Z</dc:date>
    <item>
      <title>How to rewrite query to sum both fields based on another field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-rewrite-query-to-sum-both-fields-based-on-another-field/m-p/304105#M160209</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;

&lt;P&gt;Here is a query which returns me DATA size and Index size based on domain.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=db_connect sourcetype=db_metric |join TABLE_NAME [|inputlookup Domain_Module_List.csv |search (Domain ="Inventory")] |eval DATA_MB =round(DATA_KB/1024,2) |eval INDEX_MB = round(INDEX_SIZE_KB/1024,2) |timechart span=1mon sum(DATA_MB),sum(INDEX_MB) by Domain limit=25
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I tried to do a sum of DATA and INDEX by rewriting the above query as &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=db_connect sourcetype=db_metric |join TABLE_NAME [|inputlookup Domain_Module_List.csv |search (Domain ="Inventory")] |eval DATA_MB =(DATA_KB/1024) |eval INDEX_MB = (INDEX_SIZE_KB/1024) |eval SIZE = round((DATA_MB + INDEX_MB),2) |timechart span=1mon sum(SIZE) by Domain
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But this doesn't result correct value when validated. I think i am wrong somewhere in the syntax of summing up query.&lt;/P&gt;

&lt;P&gt;How do I sum both DATA and Index together and display the result ? &lt;/P&gt;

&lt;P&gt;Thanks&lt;BR /&gt;
Sangeetha&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jul 2017 05:14:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-rewrite-query-to-sum-both-fields-based-on-another-field/m-p/304105#M160209</guid>
      <dc:creator>sangs8788</dc:creator>
      <dc:date>2017-07-12T05:14:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to rewrite query to sum both fields based on another field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-rewrite-query-to-sum-both-fields-based-on-another-field/m-p/304106#M160210</link>
      <description>&lt;P&gt;First, unrelated Why are you doing join on inputlookup? That feels rather odd, as opposed to say just using the lookup command (maybe with an eval prior to insert a needed input field? ) &lt;/P&gt;

&lt;P&gt;Second I suspect that sum may not be the timechart function you want? I would think metric of data sizes would be reported as a gauge metric, so each sampling period would report current total consumption as opposed current consumption each sampling period, in which case performing sum over time increases the value by a factor of your sample period per Table... You may need to be looking at smaller windows and min/max/stddev metrics an then aggregate across this for larger windows. Can you share more info on  what your source data means and c&lt;/P&gt;</description>
      <pubDate>Wed, 12 Jul 2017 05:55:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-rewrite-query-to-sum-both-fields-based-on-another-field/m-p/304106#M160210</guid>
      <dc:creator>acharlieh</dc:creator>
      <dc:date>2017-07-12T05:55:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to rewrite query to sum both fields based on another field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-rewrite-query-to-sum-both-fields-based-on-another-field/m-p/304107#M160211</link>
      <description>&lt;P&gt;My lookup files contains the tables which belong to domain - this is not captured anywhere in the logs. So I am fetching the domain from the lookup and file the datasize of table from the logs. The splunk indexed log will contain table level data size and index size &lt;/P&gt;</description>
      <pubDate>Wed, 12 Jul 2017 06:25:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-rewrite-query-to-sum-both-fields-based-on-another-field/m-p/304107#M160211</guid>
      <dc:creator>sangs8788</dc:creator>
      <dc:date>2017-07-12T06:25:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to rewrite query to sum both fields based on another field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-rewrite-query-to-sum-both-fields-based-on-another-field/m-p/304108#M160212</link>
      <description>&lt;P&gt;your original query gives you the expected results? would this work for you, then?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=db_connect sourcetype=db_metric |join TABLE_NAME [|inputlookup Domain_Module_List.csv |search (Domain ="Inventory")] |eval DATA_MB =round(DATA_KB/1024,2) |eval INDEX_MB = round(INDEX_SIZE_KB/1024,2) |timechart span=1mon limit=25 sum(DATA_MB) as datamb,sum(INDEX_MB) as indexmb by Domain|foreach indexmb* datamb* [eval size&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;='datamd&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;'+'indexmd&amp;lt;&amp;lt;MATCHSTR&amp;gt;&amp;gt;']|fields - datamd* indexmd*
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 12 Jul 2017 11:44:07 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-rewrite-query-to-sum-both-fields-based-on-another-field/m-p/304108#M160212</guid>
      <dc:creator>cmerriman</dc:creator>
      <dc:date>2017-07-12T11:44:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to rewrite query to sum both fields based on another field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-rewrite-query-to-sum-both-fields-based-on-another-field/m-p/304109#M160213</link>
      <description>&lt;P&gt;Yes it does work. Thanks a lot.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jul 2017 04:41:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-rewrite-query-to-sum-both-fields-based-on-another-field/m-p/304109#M160213</guid>
      <dc:creator>sangs8788</dc:creator>
      <dc:date>2017-07-13T04:41:20Z</dc:date>
    </item>
  </channel>
</rss>

