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)下载和 ...
随机推荐
- 监控RAC中的临时表空间
it is from metalink:Note:465840.1 1>Monitor the temp space allocation to make sure each instance ...
- Linux查看物理CPU个数、核数、逻辑CPU个数(转载)
# 总核数 = 物理CPU个数 X 每颗物理CPU的核数 # 总逻辑CPU数 = 物理CPU个数 X 每颗物理CPU的核数 X 超线程数 # 查看物理CPU个数cat /proc/cpuinfo| g ...
- 一张图看Goodle Clean设计架构
之前用一张图分析了Google给出的MVP架构,但是在Google给出的所有案例里面除了基本的MVP架构还有其它几种架构,今天就来分析其中的Clean架构.同样的,网上介绍Clean架构的文章很多,我 ...
- USACO Section 4.4 追查坏牛奶Pollutant Control
http://www.luogu.org/problem/show?pid=1344 题目描述 你第一天接手三鹿牛奶公司就发生了一件倒霉的事情:公司不小心发送了一批有三聚氰胺的牛奶.很不幸,你发现这件 ...
- JS的文本编辑框jwysiwyg-0.6
一款轻量的用js写的文本编辑框.
- 09_platform-tools简介&常见adb指令
SDK下面的文件夹说明add-ons 附加的附属的一些信息.docs Android开发的帮助文件.extras 支持的jar包,高版本兼容底版本.google usb的驱动.platforms 存放 ...
- ZoneMinder配置与使用
ZoneMinder是一套基于Linux操作系统的摄像机的视像数据监控的应用软件.应用范围广泛,包括商业或家居防盗等.ZoneMinder支持单一或多台视像镜头应用,包括摄取.分析.记录.和监视来源, ...
- Windbg 线程状态笔记
1.ntdll!ZwWaitForSingleObject 线程被挂起,如果下面跟着是这样子: RetAddr : Args to Child : Call Site `7766e518 : `fff ...
- hosts文件导致打不开某些网站
如果出现,某些网站访问不了,公司也没有进行限制的情况下,考虑是hosts文件出问题了. 解决办法:删除hosts文件,新建一个同名文件.
- javaSE第二十四天
第二十四天 363 1:多线程(理解) 363 (1)JDK5以后的Lock锁 363 A:定义 363 B:方法: 364 C:具体应用(以售票程序为例) 364 ...