<?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: Creating a table with common columns for multiple fields in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Creating-a-table-with-common-columns-for-multiple-fields/m-p/67734#M16913</link>
    <description>&lt;P&gt;This works perfectly, exactly what I wanted. Thank you.&lt;/P&gt;</description>
    <pubDate>Sat, 02 Apr 2011 03:29:00 GMT</pubDate>
    <dc:creator>jamesklassen</dc:creator>
    <dc:date>2011-04-02T03:29:00Z</dc:date>
    <item>
      <title>Creating a table with common columns for multiple fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Creating-a-table-with-common-columns-for-multiple-fields/m-p/67732#M16911</link>
      <description>&lt;P&gt;I have performance data captured with Splunk with fields and data like this:&lt;/P&gt;

&lt;P&gt;&lt;/P&gt;&lt;P&gt;
DatabaseCachePercentHit=0&lt;BR /&gt;
DatabaseCacheSizeMB=22839&lt;BR /&gt;
DatabasePageFaultStallsPersec=0&lt;BR /&gt;
DatabasePageFaultsPersec=0&lt;BR /&gt;
IODatabaseReadsAttachedAverageLatency=0&lt;BR /&gt;
IODatabaseReadsRecoveryAverageLatency=0&lt;BR /&gt;
ComputerName=MAIL1S1&lt;/P&gt;

&lt;P&gt;I need to turn this into a table with the columns: Name,Latest,Max(last 24h),Average&lt;/P&gt;

&lt;P&gt;How can I use stats to create the same columns for these different fields? And group them each into a row?&lt;/P&gt;</description>
      <pubDate>Fri, 25 Mar 2011 23:49:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Creating-a-table-with-common-columns-for-multiple-fields/m-p/67732#M16911</guid>
      <dc:creator>jamesklassen</dc:creator>
      <dc:date>2011-03-25T23:49:09Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a table with common columns for multiple fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Creating-a-table-with-common-columns-for-multiple-fields/m-p/67733#M16912</link>
      <description>&lt;P&gt;Here's one approach.&lt;/P&gt;

&lt;P&gt;For simplicity, this assumes that your max is calculated over the same time period as your reporting range. It pulls everything into field values rather than field names, since &lt;CODE&gt;stats&lt;/CODE&gt; and most other transformative commands want to operate against values:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;sourcetype=whatever
| rex field=_raw max_match=10 "(?&amp;lt;kvpair&amp;gt;\w+=\d+)"
| mvexpand kvpair
| rex field=kvpair "(?&amp;lt;key&amp;gt;\w+)=(?&amp;lt;value&amp;gt;\d+)"
| stats first(value) as "Latest" max(value) as "Max" avg(value) as "Average" by host,key
| sort host,key
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;If your intent was to have the 'Max' value for only the last 24 hours, regardless of the overall search time window, you can mask out the older values:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;...
| eval todayvalue=if(now()-86400&amp;lt;_time, todayvalue, null)
| stats first(value) as "Latest" max(todayvalue) as "24h Max" avg(value) as "Average" by host,key
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 26 Mar 2011 08:26:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Creating-a-table-with-common-columns-for-multiple-fields/m-p/67733#M16912</guid>
      <dc:creator>southeringtonp</dc:creator>
      <dc:date>2011-03-26T08:26:14Z</dc:date>
    </item>
    <item>
      <title>Re: Creating a table with common columns for multiple fields</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Creating-a-table-with-common-columns-for-multiple-fields/m-p/67734#M16913</link>
      <description>&lt;P&gt;This works perfectly, exactly what I wanted. Thank you.&lt;/P&gt;</description>
      <pubDate>Sat, 02 Apr 2011 03:29:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Creating-a-table-with-common-columns-for-multiple-fields/m-p/67734#M16913</guid>
      <dc:creator>jamesklassen</dc:creator>
      <dc:date>2011-04-02T03:29:00Z</dc:date>
    </item>
  </channel>
</rss>

