<?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 write stats to find max value of dynamic host and field in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-stats-to-find-max-value-of-dynamic-host-and-field/m-p/287431#M87007</link>
    <description>&lt;P&gt;I have b/w data from multiple switch&lt;BR /&gt;
&lt;CODE&gt;sourcetype=switch&lt;/CODE&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;_time | sw   | port1  | port2 | port3 | port4
00:01 | sw1  | 10     | 15    |       |   
00:01 | sw2  | 12     | 17    | 10    | 4   
00:11 | sw1  | 7      | 11    |       |   
00:11 | sw2  | 16     | 30    | 0     | 0   
...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and lookup table with service name information about switch and port it running &lt;BR /&gt;
&lt;CODE&gt;[| inputlookup servicename.csv ]&lt;/CODE&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;service | cap | switch1 | port1 | switch2 | port2 
db1     | 100 | sw1     | 1      | sw2     | 1
db2     | 200 | sw1     | 3      | sw2     | 3
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Next I want to run &lt;CODE&gt;stats&lt;/CODE&gt; to calculate maximum and average use of each port on each service and expect result to be something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;service | switch1 | port1 | Peak1 | Avg1  | switch2 | port2 | Peak2 | Avg2
db1     | sw1     | 1     | 30%   | 7%    | sw2     | 1     | 0%    | 0%
db2     | sw1     | 3     | 1%    | 5%    | sw2     | 3     | 49%   | 31%
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I try to use &lt;CODE&gt;transpose&lt;/CODE&gt;, &lt;CODE&gt;subsearch&lt;/CODE&gt;, &lt;CODE&gt;join&lt;/CODE&gt; or &lt;CODE&gt;append&lt;/CODE&gt; with stats  to match the data together but not found a work query yet.&lt;/P&gt;

&lt;P&gt;How to get the value from &lt;CODE&gt;sourcetype=switch&lt;/CODE&gt; to run &lt;CODE&gt;max&lt;/CODE&gt; and &lt;CODE&gt;avg&lt;/CODE&gt; on specific field from table and fill in table service name as show above?&lt;/P&gt;

&lt;P&gt;edit: actual data contain ~80 switch and 300 services. Each switch have port from 20-80 ports.&lt;/P&gt;</description>
    <pubDate>Fri, 23 Dec 2016 04:26:45 GMT</pubDate>
    <dc:creator>TheGU</dc:creator>
    <dc:date>2016-12-23T04:26:45Z</dc:date>
    <item>
      <title>How to write stats to find max value of dynamic host and field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-stats-to-find-max-value-of-dynamic-host-and-field/m-p/287431#M87007</link>
      <description>&lt;P&gt;I have b/w data from multiple switch&lt;BR /&gt;
&lt;CODE&gt;sourcetype=switch&lt;/CODE&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;_time | sw   | port1  | port2 | port3 | port4
00:01 | sw1  | 10     | 15    |       |   
00:01 | sw2  | 12     | 17    | 10    | 4   
00:11 | sw1  | 7      | 11    |       |   
00:11 | sw2  | 16     | 30    | 0     | 0   
...
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and lookup table with service name information about switch and port it running &lt;BR /&gt;
&lt;CODE&gt;[| inputlookup servicename.csv ]&lt;/CODE&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;service | cap | switch1 | port1 | switch2 | port2 
db1     | 100 | sw1     | 1      | sw2     | 1
db2     | 200 | sw1     | 3      | sw2     | 3
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Next I want to run &lt;CODE&gt;stats&lt;/CODE&gt; to calculate maximum and average use of each port on each service and expect result to be something like this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;service | switch1 | port1 | Peak1 | Avg1  | switch2 | port2 | Peak2 | Avg2
db1     | sw1     | 1     | 30%   | 7%    | sw2     | 1     | 0%    | 0%
db2     | sw1     | 3     | 1%    | 5%    | sw2     | 3     | 49%   | 31%
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I try to use &lt;CODE&gt;transpose&lt;/CODE&gt;, &lt;CODE&gt;subsearch&lt;/CODE&gt;, &lt;CODE&gt;join&lt;/CODE&gt; or &lt;CODE&gt;append&lt;/CODE&gt; with stats  to match the data together but not found a work query yet.&lt;/P&gt;

&lt;P&gt;How to get the value from &lt;CODE&gt;sourcetype=switch&lt;/CODE&gt; to run &lt;CODE&gt;max&lt;/CODE&gt; and &lt;CODE&gt;avg&lt;/CODE&gt; on specific field from table and fill in table service name as show above?&lt;/P&gt;

&lt;P&gt;edit: actual data contain ~80 switch and 300 services. Each switch have port from 20-80 ports.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Dec 2016 04:26:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-stats-to-find-max-value-of-dynamic-host-and-field/m-p/287431#M87007</guid>
      <dc:creator>TheGU</dc:creator>
      <dc:date>2016-12-23T04:26:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to write stats to find max value of dynamic host and field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-stats-to-find-max-value-of-dynamic-host-and-field/m-p/287432#M87008</link>
      <description>&lt;P&gt;Hi TheGU,&lt;BR /&gt;
try something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;your_index sourcetype=switch switch=sw1
| rename sw AS switch 
| lookup servicename.csv switch OUTPUT service 
| stats values(switch) AS switch1 values(port) AS Port1 max(port) AS Peak1 avg(port) AS Avg1 by service
| rename switch AS switch1
| appendcols [ search 
   your_index sourcetype=switch switch=sw2
   | rename sw AS switch 
   | lookup servicename.csv switch OUTPUT service 
   | stats values(switch) AS switch2 values(port) AS Port2 max(port) AS Peak2 avg(port) AS Avg2 by service
   | rename switch AS switch2
   ]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Bye.&lt;BR /&gt;
Giuseppe&lt;/P&gt;</description>
      <pubDate>Fri, 23 Dec 2016 11:34:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-stats-to-find-max-value-of-dynamic-host-and-field/m-p/287432#M87008</guid>
      <dc:creator>gcusello</dc:creator>
      <dc:date>2016-12-23T11:34:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to write stats to find max value of dynamic host and field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-stats-to-find-max-value-of-dynamic-host-and-field/m-p/287433#M87009</link>
      <description>&lt;P&gt;The peak and avg is calculated based on which field?&lt;/P&gt;</description>
      <pubDate>Fri, 23 Dec 2016 15:31:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-stats-to-find-max-value-of-dynamic-host-and-field/m-p/287433#M87009</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2016-12-23T15:31:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to write stats to find max value of dynamic host and field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-stats-to-find-max-value-of-dynamic-host-and-field/m-p/287434#M87010</link>
      <description>&lt;P&gt;port1 port2 port3 field.&lt;/P&gt;</description>
      <pubDate>Sun, 25 Dec 2016 14:10:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-stats-to-find-max-value-of-dynamic-host-and-field/m-p/287434#M87010</guid>
      <dc:creator>TheGU</dc:creator>
      <dc:date>2016-12-25T14:10:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to write stats to find max value of dynamic host and field</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-write-stats-to-find-max-value-of-dynamic-host-and-field/m-p/287435#M87011</link>
      <description>&lt;P&gt;Thanks for your response. However, I edit to add info about actual data. They have a lot of switchs and services so appendcols for each switch might not be a good solution.&lt;/P&gt;</description>
      <pubDate>Sun, 25 Dec 2016 14:18:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-write-stats-to-find-max-value-of-dynamic-host-and-field/m-p/287435#M87011</guid>
      <dc:creator>TheGU</dc:creator>
      <dc:date>2016-12-25T14:18:15Z</dc:date>
    </item>
  </channel>
</rss>

