<?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 to merge my two searches to output combined stats count results? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-my-two-searches-to-output-combined-stats-count/m-p/155317#M43711</link>
    <description>&lt;P&gt;Sahoo,&lt;BR /&gt;
Please provide an accurate example of your logs otherwise it's impossible for the community to help you.  You must give as much detail as possible in order for anyone to be able to give you an accurate solution to your issue.  Especially when regex's are concerned as they are based on the strings you are looking for.&lt;/P&gt;</description>
    <pubDate>Fri, 20 Feb 2015 15:13:50 GMT</pubDate>
    <dc:creator>markthompson</dc:creator>
    <dc:date>2015-02-20T15:13:50Z</dc:date>
    <item>
      <title>How to merge my two searches to output combined stats count results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-my-two-searches-to-output-combined-stats-count/m-p/155304#M43698</link>
      <description>&lt;P&gt;I have two URL's  for which i take counts separately, &lt;/P&gt;

&lt;P&gt;For example : &lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;(1)&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host="mobile_host" uri="/m.google.com/company-information/cs/*" |stats count AS URL, count(eval(match(uri, "^(/m.google.com/company-information/cs/company-profile)"))) AS company-profile, count(eval(match(uri, "^(/m.google.com/company-information/cs/sales-preparation)"))) AS sales-preparation
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Result is :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;url     company profile     sales-preparation
150            25                  25
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;(2)&lt;/STRONG&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host="host" uri="/www-prd.google.com/company-information/cs/*" |stats count AS URL, count(eval(match(uri, "^(/www-prd.google.com/company-information/cs/company-profile)"))) AS company-profile, count(eval(match(uri, "^(/www-prd.google.com/company-information/cs/sales-preparation)"))) AS sales-preparation
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Result is :&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;url     company profile     sales-preparation
150            75                  75
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;So now what i want is i need the above two searches to be merged so that i should get an combined output as below:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;url     company profile     sales-preparation
300            200                 100
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Please i need help in this issue, i need to get a combined output for the above:&lt;BR /&gt;
Solutions please....&lt;/P&gt;</description>
      <pubDate>Thu, 19 Feb 2015 10:56:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-merge-my-two-searches-to-output-combined-stats-count/m-p/155304#M43698</guid>
      <dc:creator>sahoo0233</dc:creator>
      <dc:date>2015-02-19T10:56:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge my two searches to output combined stats count results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-my-two-searches-to-output-combined-stats-count/m-p/155305#M43699</link>
      <description>&lt;P&gt;for the first string : output is like&lt;/P&gt;

&lt;P&gt;url : 150&lt;BR /&gt;
company profile : 75&lt;BR /&gt;
sales-preparation : 75&lt;/P&gt;

&lt;P&gt;similar for string 2 and output&lt;/P&gt;

&lt;P&gt;i need a solution asap&lt;/P&gt;</description>
      <pubDate>Thu, 19 Feb 2015 10:58:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-merge-my-two-searches-to-output-combined-stats-count/m-p/155305#M43699</guid>
      <dc:creator>sahoo0233</dc:creator>
      <dc:date>2015-02-19T10:58:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge my two searches to output combined stats count results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-my-two-searches-to-output-combined-stats-count/m-p/155306#M43700</link>
      <description>&lt;P&gt;Can you clarify what you actually need to do?  You need to add the 2 values together?&lt;/P&gt;

&lt;P&gt;If so, why not transaction them, then use rex to create new fields and just add the fields together?&lt;/P&gt;</description>
      <pubDate>Thu, 19 Feb 2015 11:01:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-merge-my-two-searches-to-output-combined-stats-count/m-p/155306#M43700</guid>
      <dc:creator>markthompson</dc:creator>
      <dc:date>2015-02-19T11:01:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge my two searches to output combined stats count results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-my-two-searches-to-output-combined-stats-count/m-p/155307#M43701</link>
      <description>&lt;P&gt;hey mark, i need to add the two values together and get a combined output.&lt;/P&gt;

&lt;P&gt;I am just a learner and working on it, so could you please give an example how to create new fields using rex?&lt;/P&gt;</description>
      <pubDate>Thu, 19 Feb 2015 11:08:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-merge-my-two-searches-to-output-combined-stats-count/m-p/155307#M43701</guid>
      <dc:creator>sahoo0233</dc:creator>
      <dc:date>2015-02-19T11:08:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge my two searches to output combined stats count results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-my-two-searches-to-output-combined-stats-count/m-p/155308#M43702</link>
      <description>&lt;P&gt;Ok, so can you provide examples of the 2 events please and I'll write you a search string&lt;/P&gt;</description>
      <pubDate>Thu, 19 Feb 2015 11:16:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-merge-my-two-searches-to-output-combined-stats-count/m-p/155308#M43702</guid>
      <dc:creator>markthompson</dc:creator>
      <dc:date>2015-02-19T11:16:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge my two searches to output combined stats count results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-my-two-searches-to-output-combined-stats-count/m-p/155309#M43703</link>
      <description>&lt;P&gt;Hi Mark,&lt;/P&gt;

&lt;P&gt;The above are the two strings(in the description i gave) , i just replaced my company name with google as per confidential purposes.&lt;/P&gt;

&lt;P&gt;please go through the two strings and give me a common search string ...&lt;/P&gt;

&lt;P&gt;for reference below are the two strings:&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;&lt;P&gt;host="mobile_host" uri="/m.google.com/company-information/cs/*" |stats count AS URL, count(eval(match(uri, "^(/m.google.com/company-information/cs/company-profile)"))) AS company-profile, count(eval(match(uri, "^(/m.google.com/company-information/cs/sales-preparation)"))) AS sales-preparation&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;host="host" uri="/www-prd.google.com/company-information/cs/*" |stats count AS URL, count(eval(match(uri, "^(/www-prd.google.com/company-information/cs/company-profile)"))) AS company-profile, count(eval(match(uri, "^(/www-prd.google.com/company-information/cs/sales-preparation)"))) AS sales-preparation&lt;/LI&gt;
&lt;/OL&gt;&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;Thanks for the reply... &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Feb 2015 11:23:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-merge-my-two-searches-to-output-combined-stats-count/m-p/155309#M43703</guid>
      <dc:creator>sahoo0233</dc:creator>
      <dc:date>2015-02-19T11:23:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge my two searches to output combined stats count results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-my-two-searches-to-output-combined-stats-count/m-p/155310#M43704</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I don't know if i got this correctly. Have you tried something like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;(host="mobile_host" OR host="host") (uri="/m.google.com/company-information/cs/*" OR uri="/www-prd.google.com/company-information/cs/*") | stats count AS URL, count(eval(match(uri, "^(/m.google.com/company-information/cs/company-profile)"))) AS company-profile_m, count(eval(match(uri, "^(/m.google.com/company-information/cs/sales-preparation)"))) AS sales-preparation_m count(eval(match(uri, "^(/www-prd.google.com/company-information/cs/company-profile)"))) AS company-profile, count(eval(match(uri, "^(/www-prd.google.com/company-information/cs/sales-preparation)"))) AS sales-preparation | eval "sum_company-profile" = 'company-profile' + 'company-profile_m' | eval "sum_sales-preparation"='sales-preparation' + 'sales-preparation_m'
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Or do you get wrong results out of this search?&lt;/P&gt;</description>
      <pubDate>Thu, 19 Feb 2015 12:00:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-merge-my-two-searches-to-output-combined-stats-count/m-p/155310#M43704</guid>
      <dc:creator>tom_frotscher</dc:creator>
      <dc:date>2015-02-19T12:00:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge my two searches to output combined stats count results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-my-two-searches-to-output-combined-stats-count/m-p/155311#M43705</link>
      <description>&lt;P&gt;I think Tom might have the right answer, so please share if it's correct, also convert it to answer if it is correct.&lt;/P&gt;</description>
      <pubDate>Thu, 19 Feb 2015 12:30:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-merge-my-two-searches-to-output-combined-stats-count/m-p/155311#M43705</guid>
      <dc:creator>markthompson</dc:creator>
      <dc:date>2015-02-19T12:30:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge my two searches to output combined stats count results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-my-two-searches-to-output-combined-stats-count/m-p/155312#M43706</link>
      <description>&lt;P&gt;Hi Tom,&lt;BR /&gt;
I believe you're right, but is that really optimized?&lt;/P&gt;</description>
      <pubDate>Thu, 19 Feb 2015 12:30:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-merge-my-two-searches-to-output-combined-stats-count/m-p/155312#M43706</guid>
      <dc:creator>markthompson</dc:creator>
      <dc:date>2015-02-19T12:30:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge my two searches to output combined stats count results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-my-two-searches-to-output-combined-stats-count/m-p/155313#M43707</link>
      <description>&lt;P&gt;HI tom,&lt;/P&gt;

&lt;P&gt;I have run the string you provided but didn't get he desired output.&lt;/P&gt;

&lt;P&gt;I got the below output:&lt;/P&gt;

&lt;P&gt;URL : 765701&lt;BR /&gt;&lt;BR /&gt;
company-profile_m : 98110&lt;BR /&gt;&lt;BR /&gt;
company-profile : 543304&lt;/P&gt;

&lt;P&gt;In the above i have removed the sales part and have run it. Now what i want is, In the table i need to get&lt;/P&gt;

&lt;P&gt;URL : value(765701)&lt;BR /&gt;
Sum_company-profile : summation of company-profile+company-profile_m(641414)&lt;/P&gt;

&lt;P&gt;Solution please.....&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 19:01:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-merge-my-two-searches-to-output-combined-stats-count/m-p/155313#M43707</guid>
      <dc:creator>sahoo0233</dc:creator>
      <dc:date>2020-09-28T19:01:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge my two searches to output combined stats count results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-my-two-searches-to-output-combined-stats-count/m-p/155314#M43708</link>
      <description>&lt;P&gt;I'd wager this works.  When you are using match, it's based on regular expressions so you can get away with being a little imprecise.  Based on your regexes in the two different searches you should have enough commonality between the "company-profile" and "sales-preparation" on both the mobile and not-mobile sites...&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;( host="mobile_host" OR host="host" ) 
( uri="/m.google.com/company-information/cs/*" OR uri="/www-prd.google.com/company-information/cs/*" )
|stats count AS URL, 
       count(eval(match(uri, "/company-profile/"))) AS company-profile, 
       count(eval(match(uri, "/sales-preparation/"))) AS sales-preparation
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 20 Feb 2015 04:08:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-merge-my-two-searches-to-output-combined-stats-count/m-p/155314#M43708</guid>
      <dc:creator>dwaddle</dc:creator>
      <dc:date>2015-02-20T04:08:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge my two searches to output combined stats count results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-my-two-searches-to-output-combined-stats-count/m-p/155315#M43709</link>
      <description>&lt;P&gt;Hi dwaddle, its not not working. May be its adding the URL count but not the company-profile nor the sales-preapartion&lt;/P&gt;</description>
      <pubDate>Fri, 20 Feb 2015 07:22:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-merge-my-two-searches-to-output-combined-stats-count/m-p/155315#M43709</guid>
      <dc:creator>sahoo0233</dc:creator>
      <dc:date>2015-02-20T07:22:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge my two searches to output combined stats count results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-my-two-searches-to-output-combined-stats-count/m-p/155316#M43710</link>
      <description>&lt;P&gt;Well, just a thought here.  It's hard to make 100% correct regexes for anonymized URLs.  I don't think this work is for Google - there is no www-prd.google.com, nor does &lt;A href="http://www.google.com/company-information"&gt;http://www.google.com/company-information&lt;/A&gt; actually exist.  Further, I doubt Google would use Splunk to do web analytics for their own websites. &lt;/P&gt;

&lt;P&gt;I don't have examples of your actual URLs so I'm counting on you to do be able to see the general technique and apply it in lieu of just copypasta.  So let's break down the &lt;CODE&gt;stats&lt;/CODE&gt; command above.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; |stats count AS URL, 
        count(eval(match(uri, "/company-profile/"))) AS company-profile, 
        count(eval(match(uri, "/sales-preparation/"))) AS sales-preparation
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Each of the &lt;CODE&gt;count(eval(match&lt;/CODE&gt; commands, counts items where the field &lt;CODE&gt;uri&lt;/CODE&gt; matches a given regular expression.  For &lt;CODE&gt;company-profile&lt;/CODE&gt; the regex is general enough that anything with "/company-profile/" in the &lt;CODE&gt;uri&lt;/CODE&gt; field should be a match, like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;m.google.com/company-information/cs/company-profile/index.html
www-prd.google.com/company-information/cs/company-profile/about-us/locations/Texas/Austin.html
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And so on.  Since you anonymized URLs and didn't examples to write regexes from, it's a guessing game to get the regexes right.  If the above search didn't work, it's because the regexes are wrong.  Get them right and it will work -- but that part is on you....&lt;/P&gt;</description>
      <pubDate>Fri, 20 Feb 2015 14:51:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-merge-my-two-searches-to-output-combined-stats-count/m-p/155316#M43710</guid>
      <dc:creator>dwaddle</dc:creator>
      <dc:date>2015-02-20T14:51:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to merge my two searches to output combined stats count results?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-merge-my-two-searches-to-output-combined-stats-count/m-p/155317#M43711</link>
      <description>&lt;P&gt;Sahoo,&lt;BR /&gt;
Please provide an accurate example of your logs otherwise it's impossible for the community to help you.  You must give as much detail as possible in order for anyone to be able to give you an accurate solution to your issue.  Especially when regex's are concerned as they are based on the strings you are looking for.&lt;/P&gt;</description>
      <pubDate>Fri, 20 Feb 2015 15:13:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-merge-my-two-searches-to-output-combined-stats-count/m-p/155317#M43711</guid>
      <dc:creator>markthompson</dc:creator>
      <dc:date>2015-02-20T15:13:50Z</dc:date>
    </item>
  </channel>
</rss>

