日志收集统计逻辑
2024-04-24 18:32:56 0 举报
AI智能生成
日志收集统计逻辑
作者其他创作
大纲/内容
日志接口
api-log
主函数
main.go
部署路径
配置规则
子主题 1
子主题 2
子主题 3
输入格式
event
App、Action、Source、EventEnum、ResourceID、ResourceName、Token、DeviceInfo、StartTime、EndTime、EventDescribe、APIVersion、Param1、Param2、Param3、Param4、Param5
error
EventEnum、Token、DeviceInfo、StartTime、EndTime、ErrorDescribe、APIVersion
输出格式
日志队列
api-event-log
任务中心
phenix-job
分支主题
日志清洗
service-log-extraction
部署路径
子主题 1
清洗维度
运营数据汇总
调度机制
调度脚本
nohup ./service-log-extraction -runmode=prod 2>&1 >> info.log 2>&1 /dev/null &
Init
syncEventBaseJob
job.SyncEvent
syncLoginEvent(开机设备数)
数据来源
select * from log_device_event where (startTime between config.LastUpdateTime and yesterday) and eventCode="DEVICE_LOGIN_EVENT"
去重
select * from log_device_login where deviceId=? and createDay=createDay limit 1
更新
insert log_device_login(ID、DeviceID、RoomID、EventCode、EventBody、StartTime、TenantID、TenantName、CreateDay)
syncPlayEvent(点播设备数)
数据来源
select * from log_device_event where (case when left(startTime,10)=createDay then left(startTime,10) when (left(startTime,4)>2030 or left(startTime,4)<2018) then createDay else left(startTime,10) end)=createDay and eventCode=MEDIA_START_EVENT
去重
select * from log_device_play where deviceId=? and createDay=createDay limit 1
更新
insert log_device_play (ID、DeviceID、RoomID、EventCode、EventBody、StartTime、TenantID、TenantName、CreateDay)
syncOrderEvent(订单)
数据来源
SELECT a.*,b.goodId as resourceId,b.goodName as resourceName FROM mall_order a,mall_order_goods b where a.id = b.orderId and (a.createDate between ? and ?)
更新
insert log_device_orders(id、deviceId、roomId、orderNo、startTime、TenanID、TenantName、ResourceId,ResourceName、PayStatus、CreateDay、SumPrice)
syncActiveDeviceEvent(活跃设备数)
数据来源
select * from log_device_event where (startTime between config.LastUpdateTime and yesterday) and eventCode="DEVICE_LOGIN_EVENT"
去重
select * from log_device_login where deviceId=? and createDay=createDay limit 1
更新
insert log_device_login(ID、DeviceID、RoomID、EventCode、EventBody、StartTime、TenantID、TenantName、CreateDay)
调度机制
调度时间
5:00
调度机制
获取昨天更新的时间
select * from sys_job_config where jobId="LOGIN_JOB" and lastUpdateStatus=1
分支主题
计算时间的distance
规则:range(mod(调度时间-lastUpdateTime)/24,0)
if distance!= 0
i := int64(0); i <= distance; i++
config.LastUpdateTime = util.AddDay(lastUpdateTime, util.Pattern2, i)
执行SyncEvent
sys_job_config更新lastUpdateTime=config.LastUpdateTime
syncEventSummaryJob
获取config
select * from sys_job_config where jobId=SUMMARY_JOB and lastUpdateStatus=createDay
来源
select * from t_tenant where delFlag='0' and left(createDate,10)<= createDay(config.LastUpdateTime)
LoginNum
SELECT count(id) FROM log_device_login where createDay=createDay and tenantId=?
PlayNum
select count(*) from (SELECT deviceId,startTime,resourceId FROM log_device_event where eventCode=? and (case when left(startTime,10)=? then left(startTime,10) when (left(startTime,4)>2030 or left(startTime,4)<2018) then createDay else left(startTime,10) end)=? and tenantId=? group by deviceId,startTime,resourceId)b
PlayDeviceNum
select count(distinct deviceId) from log_device_play where createDay=? and tenantId=?
RoomNum
select count(DISTINCT CONCAT(tenantId,roomId)) from t_tenant_device_user where delFlag='0' and tenantId=?
DeviceNum
select count(DISTINCT CONCAT(tenantId,deviceId)) from t_tenant_device_user where delFlag="0" and tenantId=?
orderNum, unpaidNum, paidNum, shippedNum, sumPrice
select * from log_device_orders where createDay=? and tenantId=?
更新
insert log_device_summary_day
调度机制
调度时间
5:00
调度策略
获取昨天更新时间
select * from sys_job_config where jobId=SUMMARY_JOB and lastUpdateStatus=1
分支主题
计算时间的distance
规则:range(mod(调度时间-lastUpdateTime)/24,0)
if distance!= 0
i := int64(0); i <= distance; i++13;if time.now()=lastUpdateTime continue
config.LastUpdateTime = util.AddDay(lastUpdateTime, util.Pattern1, i)
执行syncEventSummaryJob
sys_job_config更新lastUpdateTime=config.LastUpdateTime
运营二次汇总
调度策略
调度时间
8:00
服务告警
task-order-mail
部署路径
子主题 1
统计维度
sendOrderSummaray
GetOrderSummaryBI
return OrderSummaryBI
Title:day
Remark:"15:04:05"
OrderSummary
UndoneOrderSum
SELECT count(id) FROM mall_order where left(createDate,10)=today and payStatus="Unpaid"
DoneOrderSum
SELECT count(id) FROM mall_order where left(createDate,10)=today and payStatus!="Unpaid"
OrderSum
undoneOrderSum + doneOrderSum
OrderPrice
SELECT sum(price) FROM mall_order where left(createDate,10)=today and payStatus!="Unpaid"
PackageOrderSum
SELECT sum(price) FROM mall_order where left(createDate,10)=today and payStatus!="Unpaid" and goodType="TPackage"
TenantOrderList
TenantOrder(按天统计)
TenantName
OrderSum
WxOrderSum
AliOrderSum
OrderPrice
OrderPriceStr
UndoneOrderSum
DoneOrderSum
调度策略
调度时间
朝九晚六工作时间内每50分钟
调度时间
11,17,24
调度命令
./task-order-mail -runmode=prod -method=sendOrderSummaray -dayType=today
订单发送-指定发送人
调度时间
每一个小时
调度命令
./task-order-mail -runmode=prod -method=sendOrderSummaray -dayType=today -toUser=wangyupeng@unitedview.cn
订单邮件-次日达
调度时间
9点
调度命令
./task-order-mail -runmode=prod -method=sendOrderSummaray -dayType=yesterday
SendOrderWarning
GetTenantOrderListByTime
return OrderCheckBO
Title
订单告警
Remark
DoneOrderSum
Unpaid
UndoneOrderSum
非Unpaid
调度策略
调度时间
每一个小时
调度命令
./task-order-mail -runmode=prod -method=SendOrderWarning
0 条评论
下一页