<?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 do I add an Average column to this stats table? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-add-an-Average-column-to-this-stats-table/m-p/373555#M109852</link>
    <description>&lt;P&gt;not sure, but please check this - &lt;BR /&gt;
&lt;PRE&gt;index=star_aws sourcetype=aws:ec2 State=running | dedup InstanceID | rename InstanceSize as Instance_Type &lt;BR /&gt;
 | eval Operating_System = case(match(OS,"RHE.+"), "RHEL", match(OS,"win.+"), "Windows", match(OS,"Win.+"), "Windows", 1=1, "Linux")&lt;BR /&gt;&lt;BR /&gt;
 | fields InstanceID Instance_Type OS Operating_System Service StarName&lt;BR /&gt;&lt;BR /&gt;
 | join type=left max=1 Instance_Type Operating_System [ | inputlookup aws_price.csv ] &lt;BR /&gt;
 | eval PricePerYr=round(PricePerYr,2) &lt;BR /&gt;
 | eval totalPerYr=(PricePerYr * 1.5)&lt;BR /&gt;
 | stats sum(PricePerYr) as "Compute  OPEX (US$/yr)", sum(totalPerYr) as "Total OPEX inc Ancillaries(storage, backup etc)", count as "Instance Count", by Service,  avg("Total OPEX inc Ancillaries(storage, backup etc)") as Avg_total_cost_per_instance by "Instance Count" &lt;/PRE&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 15:27:18 GMT</pubDate>
    <dc:creator>inventsekar</dc:creator>
    <dc:date>2020-09-29T15:27:18Z</dc:date>
    <item>
      <title>How do I add an Average column to this stats table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-add-an-Average-column-to-this-stats-table/m-p/373554#M109851</link>
      <description>&lt;P&gt;I have this query to create a stats table:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=star_aws sourcetype=aws:ec2 State=running | dedup InstanceID | rename InstanceSize as Instance_Type 
| eval Operating_System = case(match(OS,"RHE.+"), "RHEL", match(OS,"win.+"), "Windows", match(OS,"Win.+"), "Windows", 1=1, "Linux")  
| fields InstanceID Instance_Type OS Operating_System Service StarName     
| join type=left max=1 Instance_Type Operating_System [ | inputlookup aws_price.csv ] 
| eval PricePerYr=round(PricePerYr,2) 
| eval totalPerYr=(PricePerYr * 1.5)
| stats sum(PricePerYr) as "Compute  OPEX (US$/yr)", sum(totalPerYr) as "Total OPEX inc Ancillaries(storage, backup etc)", count as "Instance Count", by Service 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Stats table output is in the attached screen shot&lt;span class="lia-inline-image-display-wrapper" image-alt="alt text"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/3373iA0593D7D2531C66C/image-size/large?v=v2&amp;amp;px=999" role="button" title="alt text" alt="alt text" /&gt;&lt;/span&gt;&lt;/P&gt;

&lt;P&gt;How can I add a 5th column showing Average total cost per instance?&lt;BR /&gt;
IE Column 4 divided by column 5?&lt;BR /&gt;
Instances are different sizes/costs&lt;/P&gt;

&lt;P&gt;Thanks&lt;BR /&gt;
Mark&lt;/P&gt;</description>
      <pubDate>Fri, 18 Aug 2017 10:23:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-add-an-Average-column-to-this-stats-table/m-p/373554#M109851</guid>
      <dc:creator>mjm295</dc:creator>
      <dc:date>2017-08-18T10:23:16Z</dc:date>
    </item>
    <item>
      <title>Re: How do I add an Average column to this stats table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-add-an-Average-column-to-this-stats-table/m-p/373555#M109852</link>
      <description>&lt;P&gt;not sure, but please check this - &lt;BR /&gt;
&lt;PRE&gt;index=star_aws sourcetype=aws:ec2 State=running | dedup InstanceID | rename InstanceSize as Instance_Type &lt;BR /&gt;
 | eval Operating_System = case(match(OS,"RHE.+"), "RHEL", match(OS,"win.+"), "Windows", match(OS,"Win.+"), "Windows", 1=1, "Linux")&lt;BR /&gt;&lt;BR /&gt;
 | fields InstanceID Instance_Type OS Operating_System Service StarName&lt;BR /&gt;&lt;BR /&gt;
 | join type=left max=1 Instance_Type Operating_System [ | inputlookup aws_price.csv ] &lt;BR /&gt;
 | eval PricePerYr=round(PricePerYr,2) &lt;BR /&gt;
 | eval totalPerYr=(PricePerYr * 1.5)&lt;BR /&gt;
 | stats sum(PricePerYr) as "Compute  OPEX (US$/yr)", sum(totalPerYr) as "Total OPEX inc Ancillaries(storage, backup etc)", count as "Instance Count", by Service,  avg("Total OPEX inc Ancillaries(storage, backup etc)") as Avg_total_cost_per_instance by "Instance Count" &lt;/PRE&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 15:27:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-add-an-Average-column-to-this-stats-table/m-p/373555#M109852</guid>
      <dc:creator>inventsekar</dc:creator>
      <dc:date>2020-09-29T15:27:18Z</dc:date>
    </item>
    <item>
      <title>Re: How do I add an Average column to this stats table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-add-an-Average-column-to-this-stats-table/m-p/373556#M109853</link>
      <description>&lt;P&gt;Thanks, i've been trying similar - and we are getting:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Error in 'stats' command: The output field 'Instance Count' cannot have the same name as a group-by field.
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 18 Aug 2017 11:29:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-add-an-Average-column-to-this-stats-table/m-p/373556#M109853</guid>
      <dc:creator>mjm295</dc:creator>
      <dc:date>2017-08-18T11:29:50Z</dc:date>
    </item>
    <item>
      <title>Re: How do I add an Average column to this stats table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-add-an-Average-column-to-this-stats-table/m-p/373557#M109854</link>
      <description>&lt;P&gt;his was my thoughs:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | stats sum(PricePerYr) as "Compute  OPEX (US$/yr)", sum(totalPerYr) as "Total OPEX inc Ancillaries(storage, backup etc)", count as "Instance Count",  eval Avg_total_cost_per_instance=("Total OPEX inc Ancillaries(storage, backup etc)" / "Instance Count" ) as Avg_total_cost_per_instance by Service 
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 18 Aug 2017 11:33:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-add-an-Average-column-to-this-stats-table/m-p/373557#M109854</guid>
      <dc:creator>mjm295</dc:creator>
      <dc:date>2017-08-18T11:33:19Z</dc:date>
    </item>
    <item>
      <title>Re: How do I add an Average column to this stats table?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-do-I-add-an-Average-column-to-this-stats-table/m-p/373558#M109855</link>
      <description>&lt;P&gt;AH nailed it&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; | stats sum(PricePerYr) as "Compute  OPEX (US$/yr)", sum(totalPerYr) as "Total OPEX", count as "Instance Count" by Service | eval Avg_total_cost_per_instance=('Total OPEX' / 'Instance Count' )
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Simple&lt;/P&gt;</description>
      <pubDate>Fri, 18 Aug 2017 11:39:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-do-I-add-an-Average-column-to-this-stats-table/m-p/373558#M109855</guid>
      <dc:creator>mjm295</dc:creator>
      <dc:date>2017-08-18T11:39:31Z</dc:date>
    </item>
  </channel>
</rss>

