|
@@ -171,14 +171,28 @@ def slb_request_status_metric():
|
|
|
@app.route('/metrics')
|
|
|
def all_metric():
|
|
|
|
|
|
-# start_time = int(time.strftime("%Y%m%d%H%M", time.localtime())) * 100000000000
|
|
|
-# end_time = (int(time.strftime("%Y%m%d%H%M", time.localtime())) + 5) * 100000000000
|
|
|
+ start_time = int(time.strftime("%Y%m%d%H%M", time.localtime())) * 100000000000
|
|
|
+ end_time = (int(time.strftime("%Y%m%d%H%M", time.localtime())) + 5) * 100000000000
|
|
|
+ query_sql = ("select round((successCount + processingCount1)/totalCount * 100,2) from "
|
|
|
+ "(select count(*) as totalCount,"
|
|
|
+ "sum(case when produce_status in (5,6,7,8) then 1 else 0 end) as successCount,"
|
|
|
+ "sum(case when produce_status = 99 then 1 else 0 end) as failCount , "
|
|
|
+ "sum(case when produce_status in(0,1,2,3,4) then 1 else 0 end) as processingCount,"
|
|
|
+ "sum(case when produce_status in(0,1,2,3,4) and (rate < 1 or rate is null) then 1 else 0 end) processingCount1,"
|
|
|
+ "sum(case when produce_status in(0,1,2,3,4) and rate >= 1 then 1 else 0 end) processingCount2 from "
|
|
|
+ "(select t1.project_id, t1.produce_status, round((t2.last_connect_timestamp - t1.submit_timestamp) / (t1.video_duration/1000), 1) as rate from produce_video_project t1 "
|
|
|
+ "left join produce_video_project_connect_time t2 on t1.project_id = t2.project_id "
|
|
|
+ "where t1.project_id > %s and t1.project_id < %s and t1.app_type not in (1,13,15)) s1) ss1" %(start_time ,end_time)
|
|
|
+
|
|
|
+ )
|
|
|
+ res = db_query(query_sql)
|
|
|
+
|
|
|
# sql = "".format(start_time, end_time)
|
|
|
# res = db_query(sql)
|
|
|
-# if res[0] is not None:
|
|
|
-# produce_video_task_rate.labels("produce_video_task_rate").set(res[0])
|
|
|
-# else:
|
|
|
-# produce_video_task_rate.labels("produce_video_task_rate").set(100)
|
|
|
+ if res[0] is not None:
|
|
|
+ produce_video_task_rate.labels("produce_video_task_rate").set(res[0])
|
|
|
+ else:
|
|
|
+ produce_video_task_rate.labels("produce_video_task_rate").set(0)
|
|
|
#
|
|
|
# sql = "select v1 as 平均合成耗时,v2 as 平均视频时长, round(v2/v1,1) as 时长耗时比 from (select avg(produce_done_timestamp - submit_timestamp) as v1, avg(video_duration/1000) as v2 from produce_video_project where project_id > {} and project_id < {} and app_type not in (13,15) and produce_status in (5,6,7,8)) as t1".format(start_time, end_time)
|
|
|
# #tts
|