初学耗时:0.5h
注:CSDN手机端暂不支持章节内链跳转,但外链可用,更好体验还请上电脑端。
一、模块开发:统计分析 - 流量分析 - 基础指标多维统计分析
1.1 基础指标统计。
1.2 多维统计分析。
记忆词:
基础指标统计、多维统计分析
一、模块开发:统计分析 - 流量分析 - 基础指标多维统计分析
1.1 ~ 基础指标统计。
- 对于指标业务含义的解读是关键。
1.1.1 . PageView 浏览次数(pv)
# 排除静态资源
select count(*) from ods_weblog_detail where datestr ="20181101" and valid = "true";
1.1.2 . Unique Visitor 独立访客(UV)
select count(distinct remote_addr) as uvs from ods_weblog_detail where datestr ="20181101";
1.1.3 . 访问次数(VV)
select count(distinct session) as vvs from ods_click_stream_visit where datestr ="20181101";
1.1.4 . IP
select count(distinct remote_addr) as ips from ods_weblog_detail where datestr ="20181101";
create table dw_webflow_basic_info(month string,day string,
pv bigint,uv bigint ,ip bigint, vv bigint) partitioned by(datestr string);
insert into table dw_webflow_basic_info partition(datestr="20181101")
select '201811','01',a.*,b.* from
(select count(*) as pv,count(distinct remote_addr) as uv,count(distinct remote_addr) as ips
from ods_weblog_detail
where datestr ='20181101') a join
(select count(distinct session) as vvs from ods_click_stream_visit where datestr ="20181101") b;
1.2 ~ 多维统计分析。
1.2.1 . 按时间维度。
- 直接在 ods_weblog_detail 单表上进行查询。
# 计算该处理批次(一天)中的各小时 pvs
drop table dw_pvs_everyhour_oneday;
create table dw_pvs_everyhour_oneday(month string,day string,hour string,pvs bigint) partitioned by(datestr
string);
insert into table dw_pvs_everyhour_oneday partition(datestr='20130918')
select a.month as month,a.day as day,a.hour as hour,count(*) as pvs from ods_weblog_detail a
where a.datestr='20130918' group by a.month,a.day,a.hour;
# 计算每天的 pvs
drop table dw_pvs_everyday;
create table dw_pvs_everyday(pvs bigint,month string,day string);
insert into table dw_pvs_everyday
select count(*) as pvs,a.month as month,a.day as day from ods_weblog_detail a
group by a.month,a.day;
- 与时间维表关联查询。
# 维度:日
drop table dw_pvs_everyday;
create table dw_pvs_everyday(pvs bigint,month string,day string);
insert into table dw_pvs_everyday
select count(*) as pvs,a.month as month,a.day as day from (select distinct month, day from t_dim_time) a
join ods_weblog_detail b
on a.month=b.month and a.day=b.day
group by a.month,a.day;
# 维度:月
drop table dw_pvs_everymonth;
create table dw_pvs_everymonth (pvs bigint,month string);
insert into table dw_pvs_everymonth
select count(*) as pvs,a.month from (select distinct month from t_dim_time) a
join ods_weblog_detail b on a.month=b.month group by a.month;
# 另外,也可以直接利用之前的计算结果。比如从之前算好的小时结果中统计每一天的
Insert into table dw_pvs_everyday
Select sum(pvs) as pvs,month,day from dw_pvs_everyhour_oneday group by month,day having day='18';
1.2.2 . 按 referer 维度。
# 统计每小时各来访 url 产生的 pv 量
drop table dw_pvs_referer_everyhour;
create table dw_pvs_referer_everyhour(referer_url string,referer_host string,month string,day string,hour
string,pv_referer_cnt bigint) partitioned by(datestr string);
insert into table dw_pvs_referer_everyhour partition(datestr='20130918')
select http_referer,ref_host,month,day,hour,count(1) as pv_referer_cnt
from ods_weblog_detail
group by http_referer,ref_host,month,day,hour
having ref_host is not null
order by hour asc,day asc,month asc,pv_referer_cnt desc;
# 统计每小时各来访 host 的产生的 pv 数并排序
drop table dw_pvs_refererhost_everyhour;
create table dw_pvs_refererhost_everyhour(ref_host string,month string,day string,hour string,ref_host_cnts
bigint) partitioned by(datestr string);
insert into table dw_pvs_refererhost_everyhour partition(datestr='20130918')
select ref_host,month,day,hour,count(1) as ref_host_cnts
from ods_weblog_detail
group by ref_host,month,day,hour
having ref_host is not null
order by hour asc,day asc,month asc,ref_host_cnts desc;
1.2.3 . 按终端维度。
- 数据中能够反映出用户终端信息的字段是 http_user_agent。
- User Agent 也简称 UA。它是一个特殊字符串头,是一种向访问网站提供所使用的浏览器类型及版本、操作系统及版本、浏览器内核、等信息的标识。
- 例如:
User-Agent,Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/58.0.3029.276 Safari/537.36
- 上述 UA 信息就可以提取出以下的信息:
chrome 58.0、浏览器 chrome、浏览器版本 58.0、系统平台 windows、浏览器内核 webkit
…
感兴趣的可以查看参考资料:《如何自定义 UDF 解析 UA》。
1.2.4 . 按栏目维度。
- 网站栏目可以理解为网站中内容相关的主题集中。体现在域名上来看就是不同的栏目会有不同的二级目录。
- 比如某网站网址为 www.xxxx.cn,旗下栏目可以通过如下方式访问:
栏目维度:…/job
栏目维度:…/news
栏目维度:…/sports
栏目维度:…/technology
- 那么根据用户请求 url 就可以解析出访问栏目,然后按照栏目进行统计分析。
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
^ 至此,模块开发:统计分析 - 流量分析 - 基础指标多维统计分析完成。
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
※ 世间诱惑何其多,坚定始终不动摇。
版本控制软件ClearCase涵盖的范围包括 _____、建立管理、工作空间管理和过程控制。
…
版本控制
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
注:CSDN手机端暂不支持章节内链跳转,但外链可用,更好体验还请上电脑端。
我知道我的不足,我也知道你的挑剔,但我就是我,不一样的烟火,谢谢你的指指点点,造就了我的点点滴滴:)!