|
@@ -170,44 +170,23 @@ def slb_request_status_metric():
|
|
|
|
|
|
@app.route('/metrics')
|
|
|
def all_metric():
|
|
|
- with session_maker_longvideo() as session:
|
|
|
-
|
|
|
- # video_progress_count = session.query(produce_video_task).filter(produce_video_task.task_status == 1).count()
|
|
|
- # video_success_count = session.query(produce_video_task).filter(produce_video_task.task_status == 2).count()
|
|
|
- # video_fail_count = session.query(produce_video_task).filter(produce_video_task.task_status == 3).count()
|
|
|
- # video_produce_speed = session.query(produce_video_task).filter(produce_video_task.submit_timestamp)
|
|
|
- # #视频合成成功率
|
|
|
- # produce_video_task_count.labels("video_sucess").set(video_success_count)
|
|
|
- # produce_video_task_count.labels("video_fail").set(video_fail_count)
|
|
|
- # produce_video_task_count.labels("video_progress").set(video_progress_count)
|
|
|
- # #合成速度
|
|
|
- # end_time = int(time.time())
|
|
|
- # start_time = end_time - (end_time - time.timezone) % 86400
|
|
|
- # res = session.query(produce_video_task).filter(produce_video_task.task_status==2).order_by(produce_video_task.id.desc()).first()
|
|
|
- # if res:
|
|
|
- # duration = res.duration
|
|
|
- # submit_timestamp = res.submit_timestamp
|
|
|
- # complete_timestamp = res.complete_timestamp
|
|
|
- # rate = (duration / (complete_timestamp - submit_timestamp) / 1000)
|
|
|
- # produce_video_task_rate.labels("produce_video_task_rate").set(round(rate, 3))
|
|
|
- # else:
|
|
|
- # produce_video_task_rate.labels("produce_video_task_rate").set(0)
|
|
|
- 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
|
|
|
- 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)
|
|
|
-
|
|
|
- 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
|
|
|
- res = db_query(sql)
|
|
|
- if res[2] is not None:
|
|
|
- produce_video_task_count.labels("video_progress").set(res[2])
|
|
|
- else:
|
|
|
- produce_video_task_count.labels("video_progress").set(0)
|
|
|
+
|
|
|
+# 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
|
|
|
+# 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)
|
|
|
+#
|
|
|
+# 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
|
|
|
+# res = db_query(sql)
|
|
|
+# if res[2] is not None:
|
|
|
+# produce_video_task_count.labels("video_progress").set(res[2])
|
|
|
+# else:
|
|
|
+# produce_video_task_count.labels("video_progress").set(0)
|
|
|
|
|
|
res = logs_tts_count("aliyun",1)
|
|
|
if res is not None:
|
|
@@ -229,15 +208,6 @@ def all_metric():
|
|
|
produce_video_tts_count.labels("azure_fail").set(res[0]["count"])
|
|
|
else:
|
|
|
produce_video_tts_count.labels("azure_fail").set(0)
|
|
|
- #接口qps与返回时长
|
|
|
- # with session_maker() as session:
|
|
|
- # intface_infos = session.query(IntfaceList).filter(IntfaceList.app_type == "1").all()
|
|
|
- # for i in range(len(intface_infos)):
|
|
|
- # url = intface_infos[i].interface_url
|
|
|
- # url_qps = intface_infos[i].qps
|
|
|
- # url_avg_time = intface_infos[i].avg_time
|
|
|
- # url_http_avgtime.labels(url).set(url_avg_time)
|
|
|
- # url_http_qps.labels(url).set(url_qps)
|
|
|
|
|
|
#当日负载均衡http_code
|
|
|
svc_name = {'longvideoapi', 'clip', 'speed', 'commonapi'}
|