yhd日志分析(二)
yhd日志分析(二)
继续yhd日志分析,统计数据
| 日期 | uv | pv | 登录人数 | 游客人数 | 平均访问时长 | 二跳率 | 独立ip数 |
|---|
1 分析
登录人数
count(distinct endUserId)
游客人数
count(distinct guid) - count(distinct endUserId)
平均访问时长
先把tracktime转换为unix timestamp, 相同sessionId的tracktime中,max(tracktime)-min(tracktime),得到用户停留时间。所有用户的停留时间相加,得到总停留时间。总停留时间和总访问次数的比例,就是平均访问时长
select sum(stay_time) as total_stay_time
from (select max(to_unix_timestamp(trackTime)) - min(to_unix_timestamp(trackTime)) as stay_time from yhd_log group by sessionId) stay
用户访问总数
count(distinct sessionId)
二跳率
sessionViewNo=2的用户,即为二跳用户。统计出二跳用户和uv的比例
select count(distinct guid) from yhd_log where sessionViewNo=2
独立ip数
count(distinct ip)
实现
借助中间表,分别存放停留时间和二次跳用户总数
// 存放总停留时间 create table if not exists yhd_log_total_stay_time(
date string,
total_stay_time bigint
)
row format delimited fields terminated by '\t'
stored as textfile; // 存放二次跳用户总数 create table if not exists yhd_log_total_second_jump(
date string,
total_second_jump bigint
)
row format delimited fields terminated by '\t'
stored as textfile;
计算总停留时间,存放在yhd_log_total_stay_time, 按日期分组
insert overwrite table yhd_log_total_stay_time
select date, sum(stay_time) as total_stay_time
from (select max(to_unix_timestamp(trackTime)) - min(to_unix_timestamp(trackTime)) as stay_time, date from yhd_log group by date, sessionId) stay
group by date
计算二次跳用户总数,存放在yhd_log_total_second_jump, 按日期分组
insert overwrite table yhd_log_total_second_jump
select date, count(distinct guid)
from yhd_log
where sessionViewNo=2
group by date
统计
把yhd_log_total_stay_time,yhd_log_total_second_jump和yhd_log按照 date连接查询 select date, pv, uv, user_count, guest_count,
total_stay_time/total_visit as average_stay_time,
total_second_jump/ uv as second_jump_rate, indepent_ip
from (
select log.date,
count(url) as pv,
count(distinct guid) as uv,
count(distinct endUserId) as user_count,
count(distinct guid) - count(distinct endUserId) as guest_count,
count(distinct sessionId) as total_visit,
min(stay.total_stay_time) as total_stay_time,
min(second.total_second_jump) as total_second_jump,
count(distinct ip) as indepent_ip
from yhd_log log inner join yhd_log_total_stay_time stay on stay.date=log.date inner join yhd_log_total_second_jump second on second.date=log.date
group by log.date
) stat
结果
| date | pv | uv | user_count | guest_count | average_stay_time | second_jump_rate | indepent_ip |
|---|---|---|---|---|---|---|---|
| 20150828 | 126134 | 39007 | 17687 | 21320 | 745.9797393244751 | 0.13118158279283207 | 30462 |
yhd日志分析(二)的更多相关文章
- yhd日志分析(一)
yhd日志分析(一) 依据yhd日志文件统计分析每日各时段的pv和uv 建hive表, 表列分隔符和文件保持一致 load数据到hive表 写hive sql统计pv和uv, 结果保存到hive表2 ...
- 日志分析(二) logstash patterns
grok-patterns内置了很多基础变量的正则表达式的log解析规则,其中包括apache的log解析(同样可以用于nginx的log解析). 基于nginx日志分析配置: 1.配置nginx ...
- Apache 日志分析(二)
01.查看IP cat access_log | awk ‘{print $1}’ 02.对IP排序 cat access_log | awk ‘{print $1}’ | sort 03.打 ...
- ELK 日志分析实例
ELK 日志分析实例一.ELK-web日志分析二.ELK-MySQL 慢查询日志分析三.ELK-SSH登陆日志分析四.ELK-vsftpd 日志分析 一.ELK-web日志分析 通过logstash ...
- Hadoop学习笔记—20.网站日志分析项目案例(二)数据清洗
网站日志分析项目案例(一)项目介绍:http://www.cnblogs.com/edisonchou/p/4449082.html 网站日志分析项目案例(二)数据清洗:当前页面 网站日志分析项目案例 ...
- Linux服务器access_log日志分析及配置详解(二)
默认nginx / Linux日志在哪个文件夹? 一般在 xxx.xxx.xxxx.com/home/admin 路径下面的error.log文件和access.log文件error_log logs ...
- MySQL慢查询(二) - pt-query-digest详解慢查询日志 pt-query-digest 慢日志分析
随笔 - 66 文章 - 0 评论 - 19 MySQL慢查询(二) - pt-query-digest详解慢查询日志 一.简介 pt-query-digest是用于分析mysql慢查询的一个工具,它 ...
- centos7搭建ELK Cluster集群日志分析平台(二):Logstash
续 centos7搭建ELK Cluster集群日志分析平台(一) 已经安装完Elasticsearch 5.4 集群. 安装Logstash步骤 . 安装Java 8 官方说明:需要安装Java ...
- ELK搭建实时日志分析平台之二Logstash和Kibana搭建
本文书接前回<ELK搭建实时日志分析平台之一ElasticSearch> 文:铁乐与猫 四.安装Logstash logstash是一个数据分析软件,主要目的是分析log日志. 1)下载和 ...
随机推荐
- XAML学习笔记
XAML是用于实例化.NET对象的标记语言,主要用于构造WPF界面.不同于WPF之前的Windows编程技术(WinForm,MFC及win32sdk),在WPF之中界面主要是在XAML中添 ...
- jBox 弹出窗口中焦点设置问题
jBox 是一个不错的组件库,可以用来比较简单地弹出窗口. 我希望在 jBox 弹出窗口之后,自动将焦点设置到子窗口的某个输入框中,可是发现并不容易. 在 jBox 2.3 中,提供了如下的增强. ...
- 007 The Inheritance In JAVA
在JAVA中有一个特型叫继承(Inheritance),通过继承我们可以重复使用代码,令代码简洁,易于扩展.例如:有一个sharp的类,这个类实现了sharp的一些方法,现在我们要写一个circle的 ...
- ZigBee无线网络技术在小区路灯照明系统的应用
小区路灯照明系统是楼宇智能的一部分,但受制于布线.成本等的问题,难以得以实施.随着计算机技术的迅猛发展,无线网络技术越来越成熟,ZigBee无线网络成本低.功耗低.传输距离远等的特点,非常适合在无线路 ...
- WEB前端研发工程师编程能力成长之路(1)(转)
WEB前端研发工程师编程能力成长之路(1) [背景] 如果你是刚进入WEB前端研发领域,想试试这潭水有多深,看这篇文章吧: 如果你是做了两三年WEB产品前端研发,迷茫找不着提高之路,看这篇文章吧: ...
- 慕课网-安卓工程师初养成-2-5 如何命名Java变量
来源:http://www.imooc.com/code/1221 如同酒店会给每个房间起个性化的名字一样,程序中的变量也需要用合理的名字进行管理---变量名! 需要注意,给酒店房间起名字时可以是数字 ...
- 学习练习 java输入输出流 练习题1
.编写TextRw.java的Java应用程序,程序完成的功能是:首先向TextRw.txt中写入自己的学号和姓名,读取TextRw.txt中信息并将其显示在屏幕上. package com.hanq ...
- badge ionic tab
我需要在tab上动态显示 badge badge="badges.carts" badge-style="badge-assertive" 将这段代码 放在了 ...
- A planning attack on a commuter train carriage in Taipei
Last night an explosion on a commuter train carriage in Taipei Songshan railway station wounded at l ...
- Linux之档案管理
1:档案类型[1] d :目录 -:档案 l:链接档 b:装置文件中可存储接口设备 c:装置文件中串行设备,例如:键盘,鼠标 2:RWX: R:read (可读),W:write(可写),X:excu ...