<?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: Need help with splunk query with aggregation over repeated pattern. in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Need-help-with-splunk-query-with-aggregation-over-repeated/m-p/170726#M48871</link>
    <description>&lt;P&gt;Thanks for a quick response.&lt;/P&gt;

&lt;P&gt;Say I've 3 such entries in the log:&lt;BR /&gt;
Message="Metric1=11887,Metric2=179544,Metric3=157892,Metric4=61,Metric5=3438"&lt;BR /&gt;
Message="Metric1=10800,Metric2=179040,Metric3=157002,Metric4=60,Metric5=3428"&lt;BR /&gt;
Message="Metric1=10007,Metric2=179030,Metric3=157101,Metric4=62,Metric5=3418"&lt;/P&gt;

&lt;P&gt;I am expecting the output to be average across all the 3 Message field entries for a specific metric.&lt;/P&gt;</description>
    <pubDate>Fri, 06 Dec 2013 23:02:06 GMT</pubDate>
    <dc:creator>splunknovice</dc:creator>
    <dc:date>2013-12-06T23:02:06Z</dc:date>
    <item>
      <title>Need help with splunk query with aggregation over repeated pattern.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-with-splunk-query-with-aggregation-over-repeated/m-p/170723#M48868</link>
      <description>&lt;P&gt;I am trying to construct from my log which logs sla tracking metrics like below:&lt;BR /&gt;
Message="Metric1=11887,Metric2=179544,Metric3=157892,Metric4=61,Metric5=3438"&lt;/P&gt;

&lt;P&gt;Here's the query I am trying with. &lt;/P&gt;

&lt;P&gt;host=testmachine* INFO source=/var/log/tomcat/test/app.log | rex max_match=100 field=Message "(?&lt;METRIC&gt;\w+)=(?&lt;LATENCY&gt;\d+) us," | stats avg(latency) by metric&lt;/LATENCY&gt;&lt;/METRIC&gt;&lt;/P&gt;

&lt;P&gt;With the above query, the aggregation seem to be happening across all the matches, i.e. all the metric show the same value of avg(latency). Is there a way I can relate the metric and latency together?&lt;/P&gt;</description>
      <pubDate>Fri, 06 Dec 2013 21:55:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-with-splunk-query-with-aggregation-over-repeated/m-p/170723#M48868</guid>
      <dc:creator>splunknovice</dc:creator>
      <dc:date>2013-12-06T21:55:20Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with splunk query with aggregation over repeated pattern.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-with-splunk-query-with-aggregation-over-repeated/m-p/170724#M48869</link>
      <description>&lt;P&gt;I guess you're getting data in below form&lt;BR /&gt;
metric    avg(latency)                             Metric1   87346.000000&lt;BR /&gt;&lt;BR /&gt;
Metric2   87346.000000&lt;BR /&gt;&lt;BR /&gt;
Metric3   87346.000000&lt;BR /&gt;&lt;BR /&gt;
Metric4   87346.000000 &lt;/P&gt;

&lt;P&gt;What output you're expecting?&lt;/P&gt;</description>
      <pubDate>Fri, 06 Dec 2013 22:40:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-with-splunk-query-with-aggregation-over-repeated/m-p/170724#M48869</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2013-12-06T22:40:53Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with splunk query with aggregation over repeated pattern.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-with-splunk-query-with-aggregation-over-repeated/m-p/170725#M48870</link>
      <description>&lt;P&gt;You can try something like this for starter.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host=testmachine* INFO source=/var/log/tomcat/test/app.log 
| rex max_match=100 field=Message "(?P&amp;lt;metric&amp;gt;[^=]+)=(?P&amp;lt;latency&amp;gt;[^,]+)[,]" |eval metric="Metric"| stats avg(latency) by metric
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This should give you one entry per host.&lt;/P&gt;

&lt;H2&gt;Updated answer&lt;/H2&gt;

&lt;P&gt;Use following:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host=testmachine* INFO source=/var/log/tomcat/test/app.log | rex max_match=100 field=Message "(?P&amp;lt;metricdata&amp;gt;[^,]+)[,]" | table metricdata | mvexpand metricdata | rex field=metricdata "(?&amp;lt;metric&amp;gt;.*)=(?&amp;lt;latency&amp;gt;.*)" | stats avg(latency) by metric
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 06 Dec 2013 22:43:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-with-splunk-query-with-aggregation-over-repeated/m-p/170725#M48870</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2013-12-06T22:43:51Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with splunk query with aggregation over repeated pattern.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-with-splunk-query-with-aggregation-over-repeated/m-p/170726#M48871</link>
      <description>&lt;P&gt;Thanks for a quick response.&lt;/P&gt;

&lt;P&gt;Say I've 3 such entries in the log:&lt;BR /&gt;
Message="Metric1=11887,Metric2=179544,Metric3=157892,Metric4=61,Metric5=3438"&lt;BR /&gt;
Message="Metric1=10800,Metric2=179040,Metric3=157002,Metric4=60,Metric5=3428"&lt;BR /&gt;
Message="Metric1=10007,Metric2=179030,Metric3=157101,Metric4=62,Metric5=3418"&lt;/P&gt;

&lt;P&gt;I am expecting the output to be average across all the 3 Message field entries for a specific metric.&lt;/P&gt;</description>
      <pubDate>Fri, 06 Dec 2013 23:02:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-with-splunk-query-with-aggregation-over-repeated/m-p/170726#M48871</guid>
      <dc:creator>splunknovice</dc:creator>
      <dc:date>2013-12-06T23:02:06Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with splunk query with aggregation over repeated pattern.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-with-splunk-query-with-aggregation-over-repeated/m-p/170727#M48872</link>
      <description>&lt;P&gt;See my updated answer below. This should do it.&lt;/P&gt;</description>
      <pubDate>Sat, 07 Dec 2013 01:19:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-with-splunk-query-with-aggregation-over-repeated/m-p/170727#M48872</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2013-12-07T01:19:03Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with splunk query with aggregation over repeated pattern.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-with-splunk-query-with-aggregation-over-repeated/m-p/170728#M48873</link>
      <description>&lt;P&gt;Thanks again. I think this is getting closer to what I am expecting. However now the avg(latency) column is empty for all rows. If I remove the | stats avg(latency) by metric, i see data in metric and latency columns as expected. Its the aggregation that's not returning anything.&lt;/P&gt;</description>
      <pubDate>Sat, 07 Dec 2013 01:51:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-with-splunk-query-with-aggregation-over-repeated/m-p/170728#M48873</guid>
      <dc:creator>splunknovice</dc:creator>
      <dc:date>2013-12-07T01:51:41Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with splunk query with aggregation over repeated pattern.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-with-splunk-query-with-aggregation-over-repeated/m-p/170729#M48874</link>
      <description>&lt;P&gt;How are the values coming up in latency column? Do they seem numbers? I used the sample that you provided and I am seeing data.&lt;/P&gt;</description>
      <pubDate>Sat, 07 Dec 2013 01:59:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-with-splunk-query-with-aggregation-over-repeated/m-p/170729#M48874</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2013-12-07T01:59:14Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with splunk query with aggregation over repeated pattern.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-with-splunk-query-with-aggregation-over-repeated/m-p/170730#M48875</link>
      <description>&lt;P&gt;It was mistake on my part. The last query you gave is working like charm. Big thanks to you for helping me construct this query which I was stuck for many hours!!!&lt;/P&gt;</description>
      <pubDate>Sat, 07 Dec 2013 02:16:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-with-splunk-query-with-aggregation-over-repeated/m-p/170730#M48875</guid>
      <dc:creator>splunknovice</dc:creator>
      <dc:date>2013-12-07T02:16:50Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with splunk query with aggregation over repeated pattern.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-with-splunk-query-with-aggregation-over-repeated/m-p/170731#M48876</link>
      <description>&lt;P&gt;Glad I could help.&lt;/P&gt;</description>
      <pubDate>Sat, 07 Dec 2013 02:20:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-with-splunk-query-with-aggregation-over-repeated/m-p/170731#M48876</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2013-12-07T02:20:12Z</dc:date>
    </item>
    <item>
      <title>Re: Need help with splunk query with aggregation over repeated pattern.</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Need-help-with-splunk-query-with-aggregation-over-repeated/m-p/170732#M48877</link>
      <description>&lt;P&gt;would you mind closing the question, if everything is set for you?&lt;/P&gt;</description>
      <pubDate>Sat, 07 Dec 2013 02:37:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Need-help-with-splunk-query-with-aggregation-over-repeated/m-p/170732#M48877</guid>
      <dc:creator>somesoni2</dc:creator>
      <dc:date>2013-12-07T02:37:00Z</dc:date>
    </item>
  </channel>
</rss>

