azkaban自带的监控
azkban目前仅仅支持邮件监控,又分两个部分:
flow自带的邮件功能
- First failure
当flow中出现第一个failure时发邮件 - Flow finished
在flow执行完后,有错误再出邮件
发的邮件内容如下:
SLA
Service-Level Agreement的缩写,意思是服务等级协议.即azkaban上表示,在什么时候内满足什么条件.SLA的设置:
- FINISH
表示flow在要什么时间点之前完成,不管是success还是failure. - SUCCESS
表示flow要在什么时间点之前执行功能.
目前azkaban有两种action: - Emain Action
不满足SLA条件,则发送EAMIL - kill Actinon
不满足SLA条件,则kill flow
总结
不管是flow自带的邮件功能还是SLA,都是flow级别的预警,都不针对单个的job发邮件
写程序监控job情况
写程序监控job情况有两种方式:
监控azkaban的元数据库
写程序查询azkaban的元数据库,监控job的运行情况.以下sql可以查出0点-8点之间所有的flow,job执行情况
select
a.id as project_id,
a.name project_name,
b.flow_id,
c.status flow_status,#50success 70 failed 30 running 80 running with failure 60 killed
from_unixtime(c.start_time/1000) flow_start_time,
from_unixtime(c.end_time/1000) flow_end_time,
d.job_id,
d.status job_status,
d.start_time job_start_time,
d.end_time job_end_time
from projects a left join
(select project_id,max(version) version,flow_id from project_flows group by project_id,flow_id) b
on a.id = b.project_id
left join execution_flows c
on a.id = c.project_id and b.flow_id = c.flow_id and b.version = c.version
and c.start_time>= unix_timestamp( date_format(curdate(),'%Y-%m-%d %H:%i:%S'))*1000 #早上0点
and c.end_time<=unix_timestamp(date_format(date_add(curdate(), interval 8 HOUR),'%Y-%m-%d %H:%i:%S'))*1000
left join execution_jobs d
on a.id = d.project_id and b.version =d.version and b.flow_id=d.flow_id
and d.start_time>= unix_timestamp( date_format(curdate(),'%Y-%m-%d %H:%i:%S'))*1000 #早上0点
and d.end_time<=unix_timestamp(date_format(date_add(curdate(), interval 8 HOUR),'%Y-%m-%d %H:%i:%S'))*1000
where a.name in ('E_S1','E_S3')
order by a.name,case when c.start_time is null then 9999999999999999999 else c.start_time end
使用azkaban API监控
通过azkaban的aip: http://azkaban.github.io/azkaban/docs/latest/#api-fetch-a-flow-execution job的执行情况.
总结
azkaban自带的监控只支持flow级别的监控,job级别的监控必须通过开发程序实现.