一:监控主键重复
select '${dealDate}' as p_dt
, count(1) as duplicate_pk_cnt
from
(
select vehicle_id
, ble_id
, manufacturer_id
, manufacturer_name
,model_brand
,produce_time
, count(1) as cnt
from temp_db.temp_data_monitor_table_info_day_02
group by vehicle_id
, ble_id
, manufacturer_id
, manufacturer_name
,model_brand
,produce_time
having cnt > 1;
二:监控关键字段非空
如果字段中有空,concat()直接返回空。
select '${dealDate}' as p_dt
, count(concat(vehicle_id, ble_id, manufacturer_id, manufacturer_name,model_brand,produce_time))
as null_cnt
from temp_db.temp_data_monitor_table_info_day_02
三:数据量监控
针对表中每天数据量会变的表重数据量方面监控。
表中每天数据量是否会变化.
如果连续俩天数据量都没有变化,就需要排查。
select '${dealDate}' as p_dt
,count(a.vehicle_id) as cur_cnt
from temp_db.temp_data_monitor_table_info_day_02 a
四:僵尸表监控
针对每天变化的表,从内容方面监控。
select '${dealDate}' as p_dt
, count(a.vehicle_id) as last_cnt
, count(b.vehicle_id) as cur_cnt
, case when
count(case when a.vehicle_id is null then b.vehicle_id end) > 0
or count(case when b.vehicle_id is null then a.vehicle_id end) > 0
then 0
else 1
end as chk_diff
from temp_db.temp_data_monitor_table_info_day_02_yesterday a
full join temp_db.temp_data_monitor_table_info_day_02 b
on a.vehicle_id = b.vehicle_id
五:表中内容监控 使用正则对表中字段的格式等进行监控。
|