<?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: Modify the result of a query using csv lookup in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Modify-the-result-of-a-query-using-csv-lookup/m-p/354066#M104792</link>
    <description>&lt;P&gt;After &lt;CODE&gt;| fields S.No,Provider,ServiceName,Version,ConsumerName,TotalHits,ErrorCount,MaxResponseTime(ms),MinResponseTime(ms),AvgResponseTime(ms)&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Can you try adding:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stast values(S.No) values(Provider) values(ServiceName) values(Version) sum(TotalHits) sum(ErrorCount) sum(MaxResponseTime(ms)) sum(MinResponseTime(ms)) sum(AvgResponseTime(ms)) by ConsumerName
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 15 Mar 2018 11:37:27 GMT</pubDate>
    <dc:creator>p_gurav</dc:creator>
    <dc:date>2018-03-15T11:37:27Z</dc:date>
    <item>
      <title>Modify the result of a query using csv lookup</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Modify-the-result-of-a-query-using-csv-lookup/m-p/354065#M104791</link>
      <description>&lt;P&gt;Before asking the question, here is a brief description of what I have done and doing.&lt;BR /&gt;
 Below query is working fine which returns the results as I need them:-&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index="test" | rex "\"(?[^\"]+)\"\s+(?\d{4}-\d{2}-\d{2}\s\d{2}:\d{2}:\d{2})\s(?[^\s]+)\s(?[^\s]+)\s(?\d+)\s(?[^\s]+)\s(?[^\s]+)\s(?[^\s]+)\s(?.+)" | stats values(EndpointURI),count as TotalHits count(eval(ResponseCode!=200)) as ErrorCount max(eval(ResponseTime*1000)) as MaxResponseTime min(eval(ResponseTime*1000)) as MinResponseTime avg(eval(ResponseTime*1000)) as AvgRT by EndpointURI ConsumerIP | eval AvgRT=round(AvgRT,2) | rename AvgRT as AvgResponseTime | lookup ConsumerIPLookup ConsumerIP OUTPUT ConsumerName | lookup EndpointURILookup EndpointURI OUTPUT Provider,ServiceName,Version | streamstats count as "S.No" | fields S.No,Provider,ServiceName,Version,ConsumerName,TotalHits,ErrorCount,MaxResponseTime(ms),MinResponseTime(ms),AvgResponseTime(ms)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Result of the above query:-&lt;/P&gt;

&lt;P&gt;1   Provider1   Service1    1.0 Consumer1   3   1   572 220 396.67&lt;BR /&gt;
2   Provider1   Service1    1.0 Consumer2   3   1   50  25  300.00&lt;BR /&gt;
3   Provider1   Service1    1.0 Consumer2   7   4   100 50  200.00&lt;BR /&gt;
4   Provider1   Service1    1.0 Consumer3   14  12  214 106 602.64&lt;/P&gt;

&lt;P&gt;EndpointURILookup.csv contents:-&lt;/P&gt;

&lt;P&gt;EndpointURI,Provider,ServiceName,Version&lt;BR /&gt;
/abc/Provider1/Service1,Provider1,Service1,1.0&lt;/P&gt;

&lt;P&gt;ConsumerIPLookup.csv Contents:-&lt;/P&gt;

&lt;P&gt;ConsumerIP,ConsumerName&lt;BR /&gt;
10.10.10.1,Consumer1&lt;BR /&gt;
10.10.10.2,Consumer2&lt;BR /&gt;
10.10.10.3,Consumer2&lt;BR /&gt;
10.10.10.4,Consumer3&lt;/P&gt;

&lt;P&gt;What i need to know how can I modify/update the result of my query so that it returns the sum of Totalhits for those ConsumerNames who have multiple ConsumerIPs. For example, in ConsumerIPLookup.csv, Consumer 2 has multiple IP and Consumer Name is "Consumer2", I need to sum so that one record should come calculating TotalHits,ErrorCount,MaxResponseTime,,MinReponseTime,AvgResponseTime.&lt;/P&gt;

&lt;P&gt;The result should be like below:-&lt;/P&gt;

&lt;P&gt;1   Provider1   Service1    1.0 Consumer1   3   1   572 220 396.67&lt;BR /&gt;
2   Provider1   Service1    1.0 Consumer2   10  5   75  36  250.00&lt;BR /&gt;
4   Provider1   Service1    1.0 Consumer3   14  12  214 106 602.64&lt;/P&gt;

&lt;P&gt;How can i achieve this without losing any other stats? Is there any method to save csv lookup contents in a variable and use that variable to put condition and calculate the stats from my actual log?&lt;/P&gt;</description>
      <pubDate>Thu, 15 Mar 2018 05:27:51 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Modify-the-result-of-a-query-using-csv-lookup/m-p/354065#M104791</guid>
      <dc:creator>AdsicSplunk</dc:creator>
      <dc:date>2018-03-15T05:27:51Z</dc:date>
    </item>
    <item>
      <title>Re: Modify the result of a query using csv lookup</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Modify-the-result-of-a-query-using-csv-lookup/m-p/354066#M104792</link>
      <description>&lt;P&gt;After &lt;CODE&gt;| fields S.No,Provider,ServiceName,Version,ConsumerName,TotalHits,ErrorCount,MaxResponseTime(ms),MinResponseTime(ms),AvgResponseTime(ms)&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Can you try adding:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stast values(S.No) values(Provider) values(ServiceName) values(Version) sum(TotalHits) sum(ErrorCount) sum(MaxResponseTime(ms)) sum(MinResponseTime(ms)) sum(AvgResponseTime(ms)) by ConsumerName
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 15 Mar 2018 11:37:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Modify-the-result-of-a-query-using-csv-lookup/m-p/354066#M104792</guid>
      <dc:creator>p_gurav</dc:creator>
      <dc:date>2018-03-15T11:37:27Z</dc:date>
    </item>
    <item>
      <title>Re: Modify the result of a query using csv lookup</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Modify-the-result-of-a-query-using-csv-lookup/m-p/354067#M104793</link>
      <description>&lt;P&gt;Thank you @p_gaurav!!&lt;/P&gt;

&lt;P&gt;I tried this by modifying the above query and it worked for me. This was very helpful. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Apr 2018 04:46:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Modify-the-result-of-a-query-using-csv-lookup/m-p/354067#M104793</guid>
      <dc:creator>AdsicSplunk</dc:creator>
      <dc:date>2018-04-02T04:46:54Z</dc:date>
    </item>
    <item>
      <title>Re: Modify the result of a query using csv lookup</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Modify-the-result-of-a-query-using-csv-lookup/m-p/354068#M104794</link>
      <description>&lt;P&gt;Happy to help!! I converted this to answer, you can accept it if it helped. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Apr 2018 04:52:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Modify-the-result-of-a-query-using-csv-lookup/m-p/354068#M104794</guid>
      <dc:creator>p_gurav</dc:creator>
      <dc:date>2018-04-02T04:52:01Z</dc:date>
    </item>
    <item>
      <title>Re: Modify the result of a query using csv lookup</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Modify-the-result-of-a-query-using-csv-lookup/m-p/354069#M104795</link>
      <description>&lt;P&gt;@AdsicSplunk, please accept the answer by @p_gurav to mark this question as answered.&lt;/P&gt;</description>
      <pubDate>Mon, 02 Apr 2018 04:53:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Modify-the-result-of-a-query-using-csv-lookup/m-p/354069#M104795</guid>
      <dc:creator>niketn</dc:creator>
      <dc:date>2018-04-02T04:53:34Z</dc:date>
    </item>
  </channel>
</rss>

