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)下载和 ...
随机推荐
- 部署windows服务
(1) cd C:\Windows\Microsoft.NET\Framework64\v4.0.30319(2) InstallUtil.exe D:\SVN\zhongchao\开发\WeiXin ...
- ASP.Net软件工程师基础(二)
1.封装 答:属性封装了字段,通过get和set访问器限制字段对外开放的程度:将重复的代码封装成方法,实现DCR原则(Don't Copy yourself):方法的参数组合可以用类实现,即在方法中不 ...
- php中检查文件或目录是否存在的代码小结
检查文件或目录是否存在 ,我们使用了php中常用的函数file_exists,这个函数就可以实现我想要的功能,下面大家慢慢参考一下下面是一个简单的检查文件是否存在的实例代码: <?php $fi ...
- Functions类,一个Javascript的函数加法类,将两个函数加起来,顺序执行
以下是类的代码: var Functions = { oFunctions: null, add: function (oFunc, oNewFunc) { var oNew = function ( ...
- 尼姆博弈HDU1907
HDU1907 http://acm.hdu.edu.cn/showproblem.php?pid=1907 两种情况1.当全是1时,要看堆数的奇偶性 2.判断是奇异局势还是非奇异局势 代码: #in ...
- linux内核学习(一步一步走)——内核概述
一.用户空间与内核空间: 用户通过用户空间与操作系统打交道,程序员开发或使用的应用程序位于用户空间.用户空间不能直接访问内核,从而不能访问硬件资源,但是可以通过内核定义的最外层例程——系统调用来访问. ...
- js鼠标,键盘,坐标轴事件
鼠标按下事件,左键是0,滑轮是1,右键2 document.getElementById("box").onmousedown =function(e) { if (e.butto ...
- Lamp源码包安装实录
Lamp源码包安装实录 附件中是安装步骤,下载站点里包含视频(http://down.51cto.com/data/460776) 本文出自 "李晨光原创技术博客" 博客,请务必保 ...
- a mystrious max subquence sum
#include<cstdio>#include<cstring>const int maxn=100005;int buf[maxn];int main(){ freopen ...
- error: could not find library containing RSA_new
error: could not find library containing RSA_new yum -y install openssl-devel apt-get install libssl ...