<?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 create a report to get session based user-agent statistics on a per site basis (from Tomcat logs)? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-report-to-get-session-based-user-agent/m-p/230528#M68344</link>
    <description>&lt;P&gt;Also close but it looks like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; Site:                        User-Agent:            Sessions: 
 blah.companyname.com                 Internet Explorer 8        3
 blah.companyname.com                       Internet Explorer 9            2
 blah.companyname.com                       Internet Explorer 10            5

 junk.companyname.com                 Internet Explorer 8        2
 junk.companyname.com                        Internet Explorer 9            6
 junk.companyname.com                         Internet Explorer 10            5
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 29 Jun 2016 13:40:02 GMT</pubDate>
    <dc:creator>michael_sleep</dc:creator>
    <dc:date>2016-06-29T13:40:02Z</dc:date>
    <item>
      <title>How to create a report to get session based user-agent statistics on a per site basis (from Tomcat logs)?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-report-to-get-session-based-user-agent/m-p/230523#M68339</link>
      <description>&lt;P&gt;Hey there,&lt;/P&gt;

&lt;P&gt;I've been learning how to use the search features in Splunk and trying to find a way to get some user-agent metrics from all of our aggregated Tomcat log data. There are 3 key fields that I'm looking at to determine how many browsers are hitting different websites that we run:&lt;/P&gt;

&lt;P&gt;site (this is the domain URL from the logs, consider the format to be blahblah.companyname.com)&lt;BR /&gt;
tr_cookie (a tracking cookie with a unique id per session)&lt;BR /&gt;
http_user_agent (the user agent we pull from each log entry)&lt;/P&gt;

&lt;P&gt;What I need to do is generate a report that counts how many http_user_agents exist using the tr_cookie as a source (this cookie will never have two different http_user_agent values) and then break that down into statistics on a per 'site' basis. I have two searches so far:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=tomcat_logs  "GET /company/index.php " | stats dc(tr_cookie) as sessions by http_user_agent
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The above gives me the overall breakdown of how many unique sessions can be attributed to different http_user_agents. So it will say that 100 people are using ie8. 50 people are using Firefox and etc, ex:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko    541
Mozilla/5.0 (Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko   198
Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.94 Safari/537.36  172
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;But what I really need is something like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;somecompany.companyname.com:
     Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko   300
     Mozilla/5.0 (Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko   100
     Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.94 Safari/537.36 75

someothercompany.companyname.com:
     Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko   200
     Mozilla/5.0 (Windows NT 6.1; Trident/7.0; rv:11.0) like Gecko   110
     Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.94 Safari/537.36 63
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The closest that I have gotten is this search, but it just lists the statistics line by line with the "site" line repeating over and over:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; index=tomcat_logs  "GET /company/index.php " | stats dc(SKP_TS) as sessions by http_user_agent, site
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Example:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)  XXXXX.companyname.com   1
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727; .NET CLR 1.1.4322; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)  XXXXX.companyname.com   1
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729) XXXXX.companyname.com   1
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 3.0.04506.30; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)   XXXXX.companyname.com   2
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 10.0; WOW64; Trident/7.0; .NET4.0C; .NET4.0E; InfoPath.3; .NET CLR 2.0.50727; .NET CLR 3.0.30729; .NET CLR 3.5.30729) YYYYY.companyname.com   1
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 10.0; WOW64; Trident/7.0; Touch; .NET4.0C; .NET4.0E; .NET CLR 2.0.50727; .NET CLR 3.0.30729; .NET CLR 3.5.30729; Tablet PC 2.0)   ZZZZZ.companyname.com   1
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Any idea how to make this happen?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 10:03:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-report-to-get-session-based-user-agent/m-p/230523#M68339</guid>
      <dc:creator>michael_sleep</dc:creator>
      <dc:date>2020-09-29T10:03:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a report to get session based user-agent statistics on a per site basis (from Tomcat logs)?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-report-to-get-session-based-user-agent/m-p/230524#M68340</link>
      <description>&lt;P&gt;Try this&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | stats values(http_user_agent) as UA dc(SKP_TS) as sessions by site
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 27 Jun 2016 22:19:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-report-to-get-session-based-user-agent/m-p/230524#M68340</guid>
      <dc:creator>sundareshr</dc:creator>
      <dc:date>2016-06-27T22:19:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a report to get session based user-agent statistics on a per site basis (from Tomcat logs)?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-report-to-get-session-based-user-agent/m-p/230525#M68341</link>
      <description>&lt;P&gt;That's somewhat closer but what that returns is the total count of unique SKP_TS sessions for each site, along side each unique value of the user-agent. What I need is the unique count of SKP_TS sessions per user-agent per site.&lt;/P&gt;

&lt;P&gt;So instead of:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Site:                       User-Agent:         Sessions: 
blah.companyname.com    Internet Explorer 8     10
                        Internet Explorer 9
                        Internet Explorer 10

junk.companyname.com    Internet Explorer 8     13
                        Internet Explorer 9
                        Internet Explorer 10
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It should be:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Site:                       User-Agent:         Sessions: 
blah.companyname.com    Internet Explorer 8     3
                        Internet Explorer 9         2
                        Internet Explorer 10            5

junk.companyname.com    Internet Explorer 8     2
                        Internet Explorer 9         6
                        Internet Explorer 10            5
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 29 Sep 2020 10:03:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-report-to-get-session-based-user-agent/m-p/230525#M68341</guid>
      <dc:creator>michael_sleep</dc:creator>
      <dc:date>2020-09-29T10:03:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a report to get session based user-agent statistics on a per site basis (from Tomcat logs)?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-report-to-get-session-based-user-agent/m-p/230526#M68342</link>
      <description>&lt;P&gt;I know the syntax doesn't make sense but in my mind it's like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;index=tomcat_logs  "GET /company/index.php " | (stats dc(tr_cookie) as sessions by http_user_agent) by site
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Essentially using by twice.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jun 2016 00:32:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-report-to-get-session-based-user-agent/m-p/230526#M68342</guid>
      <dc:creator>michael_sleep</dc:creator>
      <dc:date>2016-06-28T00:32:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a report to get session based user-agent statistics on a per site basis (from Tomcat logs)?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-report-to-get-session-based-user-agent/m-p/230527#M68343</link>
      <description>&lt;P&gt;Like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;... | stats dc(SKP_TS) AS sessions BY site http_user_agent
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 28 Jun 2016 23:21:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-report-to-get-session-based-user-agent/m-p/230527#M68343</guid>
      <dc:creator>woodcock</dc:creator>
      <dc:date>2016-06-28T23:21:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a report to get session based user-agent statistics on a per site basis (from Tomcat logs)?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-report-to-get-session-based-user-agent/m-p/230528#M68344</link>
      <description>&lt;P&gt;Also close but it looks like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; Site:                        User-Agent:            Sessions: 
 blah.companyname.com                 Internet Explorer 8        3
 blah.companyname.com                       Internet Explorer 9            2
 blah.companyname.com                       Internet Explorer 10            5

 junk.companyname.com                 Internet Explorer 8        2
 junk.companyname.com                        Internet Explorer 9            6
 junk.companyname.com                         Internet Explorer 10            5
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 29 Jun 2016 13:40:02 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-report-to-get-session-based-user-agent/m-p/230528#M68344</guid>
      <dc:creator>michael_sleep</dc:creator>
      <dc:date>2016-06-29T13:40:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a report to get session based user-agent statistics on a per site basis (from Tomcat logs)?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-report-to-get-session-based-user-agent/m-p/230529#M68345</link>
      <description>&lt;P&gt;This works.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| search .....
| stats dc(SKP_TS) as sessions by site, http_user_agent
| streamstats current=false last(site) as previousSite 
| eval site=if(match(site,previousSite),"",site)
| fields site, http_user_agent, sessions
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I used sideview's answer from &lt;A href="https://answers.splunk.com/answers/25102/question-regarding-grouping-of-results-into-a-table.html"&gt;https://answers.splunk.com/answers/25102/question-regarding-grouping-of-results-into-a-table.html&lt;/A&gt; &lt;/P&gt;</description>
      <pubDate>Thu, 30 Jun 2016 16:10:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-report-to-get-session-based-user-agent/m-p/230529#M68345</guid>
      <dc:creator>lycollicott</dc:creator>
      <dc:date>2016-06-30T16:10:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a report to get session based user-agent statistics on a per site basis (from Tomcat logs)?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-report-to-get-session-based-user-agent/m-p/230530#M68346</link>
      <description>&lt;P&gt;That does indeed the give the effect I'm looking for.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jul 2016 13:49:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-create-a-report-to-get-session-based-user-agent/m-p/230530#M68346</guid>
      <dc:creator>michael_sleep</dc:creator>
      <dc:date>2016-07-13T13:49:36Z</dc:date>
    </item>
  </channel>
</rss>

