Prechádzať zdrojové kódy

增加error_code分布

panwang 3 rokov pred
rodič
commit
256ad8cee8
5 zmenil súbory, kde vykonal 328 pridanie a 167 odobranie
  1. BIN
      __pycache__/app.cpython-37.pyc
  2. BIN
      __pycache__/utils.cpython-37.pyc
  3. 39 9
      app.py
  4. 175 107
      test.py
  5. 114 51
      utils.py

BIN
__pycache__/app.cpython-37.pyc


BIN
__pycache__/utils.cpython-37.pyc


+ 39 - 9
app.py

@@ -21,11 +21,11 @@ app = Flask(__name__)
 registry = CollectorRegistry(auto_describe=False)
 
 
-# # 定义后台执行调度器
-# scheduler = BackgroundScheduler()
-# scheduler.add_job(func=interface_info_count, trigger="interval", seconds=120)
-# scheduler.start()
-# atexit.register(lambda: scheduler.shutdown())
+# 定义后台执行调度器
+scheduler = BackgroundScheduler()
+scheduler.add_job(func=update_request_url_list(), trigger="interval", seconds=300)
+scheduler.start()
+atexit.register(lambda: scheduler.shutdown())
 
 client = AcsClient('LTAI4GBWbFvvXoXsSVBe1o9f', 'kRAikWitb4kDxaAyBqNrmLmllMEDO3', 'cn-hangzhou')
 
@@ -34,6 +34,7 @@ healthcheck_status = Gauge("healthcheck_status", "ipaddress", ['instance_id','se
 url_http_avgtime = Gauge("url_http_times_avgs", "url  of avgs", ['appType', 'url'], registry=registry)
 url_http_qps = Gauge("url_http_qps", "url  of qps", ['appType','url'], registry=registry)
 url_http_expendtime_summary =  Gauge("url_http_expendtime_summary", "expendtime   summary", ['appType', 'url', 'duration'], registry=registry)
+url_http_error_code_cnt = Gauge("url_http_error_code_cnt", "error code", ['appType', 'error_code'], registry=registry)
 probe_http_status_code = Gauge("http_status_code", 'h5',['server_name'], registry=registry)
 probe_http_total_time = Gauge("http_total_time", 'h5',['server_name'], registry=registry)
 probe_http_dns_time = Gauge("http_dns_time", 'h5',['server_name'], registry=registry)
@@ -41,8 +42,10 @@ probe_http_connect_time = Gauge("http_connect_time", 'h5',['server_name'], regis
 probe_http_pretransfer_time = Gauge("http_pretransfer_time", 'h5',['server_name'], registry=registry)
 probe_http_first_byte_time = Gauge("http_first_byte_time", 'h5',['server_name'], registry=registry)
 slb_http_status_code = Gauge("slb_http_status_code", 'slb', ['server_name', 'status'], registry=registry)
-produce_video_task_count = Gauge("produce_video_task_count", 'success_status_count', ['status_count'], registry=registry)
+#视频合成
+produce_video_task_count = Gauge("produce_video_task_count", 'task_count', ['task_count'], registry=registry)
 produce_video_task_rate = Gauge("produce_video_task_rate", 'produce_video_rate', ['produce_video_rate'], registry=registry)
+
 produce_video_tts_count = Gauge("tts_aliyun_azure", 'success', ['tts_channel'], registry=registry)
 logs_app_recommend_log_cnt_300 = Gauge("logs_app_recommend_log_null_cnt_300", "null cnt", ['cnt'], registry=registry)
 logs_app_recommend_log_cnt_all = Counter("logs_app_recommend_log_null_cnt_all", "all cnt", ['cnt'], registry=registry)
@@ -170,7 +173,9 @@ def  slb_request_status_metric():
 
 @app.route('/metrics')
 def all_metric():
+    """视频合成类metrics"""
 
+    """视频合成成功率"""
     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  "
@@ -187,12 +192,20 @@ def all_metric():
                 )
     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(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
@@ -269,6 +282,7 @@ def all_metric():
     # # logs_app_recommend_log_cnt_all.labels("recommend").inc(1)
     # logs_app_recommend_log_cnt_all.inc(res_null_cnt)
 
+
     return Response(generate_latest(registry), mimetype="text/plain")
 @app.route('/qps_avgtime/metrics')
 def qps_avgtime_metrics():
@@ -313,12 +327,28 @@ def qps_avgtime_metrics():
             count = res.body[i]["cnt"]
             url_http_expendtime_summary.labels(appType, url, ">1000").set(count)
 
+        """接口error统计"""
+        res = error_cnt(appType)
+        for i in range(len(res)):
+            cnt = res.body[i]["cnt"]
+            error_code = res.body[i]["resultCode"]
+            url_http_error_code_cnt.labels(appType,error_code).set(cnt)
 
-
+            
     return Response(generate_latest(registry), mimetype="text/plain")
 
 
 
+def produce_video_data():
+    start_time = (int(time.strftime("%Y%m%d%H%M", time.localtime())) - 30) * 100000000000
+    end_time = (int(time.strftime("%Y%m%d%H%M", time.localtime()))) * 100000000000
+    sum_sql = ("select count(*) as totalCount from"              
+              "(select t1.project_id, t1.produce_status "
+              "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)
+               )
+
 
 if __name__ == '__main__':
     # app.run()

+ 175 - 107
test.py

@@ -26,6 +26,23 @@ def  h5_curl():
         info = c.getinfo(pycurl.INFO_FILETIME)
 
         print(info)
+def  requesl_url_list(apptype):
+    endpoint = 'cn-hangzhou.log.aliyuncs.com'
+    accessKeyId = 'LTAIWYUujJAm7CbH'
+    accessKey = 'RfSjdiWwED1sGFlsjXv0DlfTnZTG1P'
+    logstore = 'request-log'
+    client = LogClient(endpoint, accessKeyId, accessKey)
+    project = 'wqsd-longvideoapi'
+    topic = ""
+    start_time = int(time.time())
+    end_time = start_time - 86400
+    # url = '/longvideoapi/user/idolsUpdated'
+    req = GetLogsRequest(project, logstore, end_time, start_time, topic,
+                         "params.appType=%s | select requestUri  group by requestUri " %(apptype), 30, 0, False)
+    res = client.get_logs(req)
+
+
+    return  res
 if __name__ == '__main__':
     # with session_maker() as session:
     #     instance_info = session.query(InstanceList).filter(InstanceList.status==0).all()
@@ -33,111 +50,111 @@ if __name__ == '__main__':
     #         print( instance_info[index].ipadd)
 
     requestUri_list = [
-        'longvideoapi/sys/config',
-        'longvideoapi/video/played',
-        'longvideoapi/video/shared/weixin/friend',
-        'longvideoapi/user/login/v2',
-        'longvideoapi/user/info/getUserInfoExt',
-        'longvideoapi/user/token/check',
-        'longvideoapi/user/token/refresh',
-        'longvideoapi/user/info/homepageHead',
-        'longvideoapi/user/share/homepage/circle',
-        'longvideoapi/user/idols',
-        'longvideoapi/user/fans',
-        'longvideoapi/user/recommend/list/v4',
-        'longvideoapi/user/outside/subscribeBatch',
-        'longvideoapi/user/info/getBaseUserInfo',
-        'longvideoapi/user/info/getTargetBaseUserInfo',
-        'longvideoapi/user/getWxUserInfoByCode',
-        'longvideoapi/user/follow',
-        'longvideoapi/user/unfollow',
-        'longvideoapi/video/favorite',
-        'longvideoapi/video/unfavorite',
-        'longvideoapi/video/shared/weixin/circle',
-        'longvideoapi/videoCollection/loadUserVideoCollections',
-        'longvideoapi/video/v2/sharePage/queryVideosByCollectionId',
-        'longvideoapi/video/v2/detailPage/queryVideosByCollectionId',
-        'longvideoapi/videoCollection/loadUserVideoCollectionsForShareOrDetailPage',
-        'longvideoapi/video/distribute/getAppInfo',
-        'longvideoapi/video/distribute/category/videoList/v2',
-        'longvideoapi/video/v2/followed',
-        'longvideoapi/video/v2/loadHotVideosByCollectionId',
-        'longvideoapi/video/v2/loadLatelyVideosByCollectionId',
-        'longvideoapi/video/v2/detail',
-        'longvideoapi/video/v2/sharePageDetail',
-        'longvideoapi/video/send',
-        'longvideoapi/video/getCoverImagePaths',
-        'longvideoapi/video/updateVideo',
-        'longvideoapi/video/deleteVideo',
-        'longvideoapi/video/barrage/send',
-        'longvideoapi/video/barrage/switch',
-        'longvideoapi/video/videoActionReport',
-        'longvideoapi/video/barrage/v2/list',
-        'longvideoapi/video/shared/h5"',
-        'longvideoapi/user/share/report',
-        'longvideoapi/oss/signature',
-        'longvideoapi/oss/completeUpload',
-        'longvideoapi/oss/producevideo/getStsToken',
-        'longvideoapi/operate/message/list',
-        'longvideoapi/video/message/list',
-        'longvideoapi/sys/message/list',
-        'longvideoapi/user/station/message/statistics/info',
-        'longvideoapi/user/station/message/statistics/read',
-        'longvideoapi/user/station/message/totalCount/v2',
-        'longvideoapi/user/station/message/totalRead',
-        'longvideoapi/user/station/notice/list',
-        'longvideoapi/user/station/message/share/list',
-        'longvideoapi/user/station/message/prise/list',
-        'longvideoapi/user/station/message/favorite/list',
-        'longvideoapi/user/station/message/comment/list',
-        'longvideoapi/user/station/message/barrage/list',
-        'longvideoapi/operation/message/list',
-        'longvideoapi/search/userandvideo/list',
-        'longvideoapi/search/tips',
-        'longvideoapi/search/user/list',
-        'longvideoapi/search/video/list',
-        'longvideoapi/search/hot/words',
-        'longvideoapi/search/hot/videos',
-        'longvideoapi/video/distribute/search/recommendVideoes/v2',
-        'longvideoapi/comment/top/save',
-        'longvideoapi/comment/top/page',
-        'longvideoapi/comment/praise',
-        'longvideoapi/comment/second/save',
-        'longvideoapi/comment/second/page',
-        'longvideoapi/comment/delete',
-        'longvideoapi/comment/updelete',
-        'longvideoapi/comment/hots',
-        'longvideoapi/bank/withdraw/getBankWithdrawConfig',
-        'longvideoapi/bank/withdraw/getBankWithdrawRecordList',
-        'longvideoapi/bank/withdraw/wxSamllapp/requestWithdraw',
-        'longvideoapi/purchase/video/list',
-        'longvideoapi/profits/myself/head',
-        'longvideoapi/profits/myself/list',
-        'longvideoapi/profits/myself/recordList/v2',
-        'longvideoapi/profits/reward/recordListAccordingToUser',
-        'longvideoapi/profits/reward/recordListAccordingToVideo',
-        'longvideoapi/video/reward/getVideoRewardHeadInfo',
-        'longvideoapi/video/reward/getVideoRewardRecordList',
-        'longvideoapi/video/reward/getVideoRewardConfig',
-        'longvideoapi/video/reward/getVideoRewardConfig/v2',
-        'longvideoapi/order/updateClientPayStatus',
-        'longvideoapi/order/purchase',
-        'longvideoapi/profits/videoPay/head',
-        'longvideoapi/profits/videoPay/list',
-        'longvideoapi/video/getPayedVideoPath',
-        'longvideoapi/order/reward',
-        'longvideoapi/video/reward/getVideoDetailRewardInfo',
-        'longvideoapi/video/recommend/detailPage/list',
-        'longvideoapi/video/recommend/sharePage/list',
-        'longvideoapi/measure/report/view',
-        'longvideoapi/video/validatePwd"',
-        'longvideoapi/video/validatePwdAuth"',
-        'longvideoapi/video/v2/getCutVideo',
-        'longvideoapi/frontConfig/getWxFrontConfig',
-        'longvideoapi/frontConfig/getVideoPlayConfig',
-        'longvideoapi/frontConfig/getUserFrontConfig',
-        'longvideoapi/rhythmapp/homepage/getAllVideos',
-        'longvideoapi/ad/position/info'
+        '/longvideoapi/sys/config',
+        '/longvideoapi/video/played',
+        '/longvideoapi/video/shared/weixin/friend',
+        '/longvideoapi/user/login/v2',
+        '/longvideoapi/user/info/getUserInfoExt',
+        '/longvideoapi/user/token/check',
+        '/longvideoapi/user/token/refresh',
+        '/longvideoapi/user/info/homepageHead',
+        '/longvideoapi/user/share/homepage/circle',
+        '/longvideoapi/user/idols',
+        '/longvideoapi/user/fans',
+        '/longvideoapi/user/recommend/list/v4',
+        '/longvideoapi/user/outside/subscribeBatch',
+        '/longvideoapi/user/info/getBaseUserInfo',
+        '/longvideoapi/user/info/getTargetBaseUserInfo',
+        '/longvideoapi/user/getWxUserInfoByCode',
+        '/longvideoapi/user/follow',
+        '/longvideoapi/user/unfollow',
+        '/longvideoapi/video/favorite',
+        '/longvideoapi/video/unfavorite',
+        '/longvideoapi/video/shared/weixin/circle',
+        '/longvideoapi/videoCollection/loadUserVideoCollections',
+        '/longvideoapi/video/v2/sharePage/queryVideosByCollectionId',
+        '/longvideoapi/video/v2/detailPage/queryVideosByCollectionId',
+        '/longvideoapi/videoCollection/loadUserVideoCollectionsForShareOrDetailPage',
+        '/longvideoapi/video/distribute/getAppInfo',
+        '/longvideoapi/video/distribute/category/videoList/v2',
+        '/longvideoapi/video/v2/followed',
+        '/longvideoapi/video/v2/loadHotVideosByCollectionId',
+        '/longvideoapi/video/v2/loadLatelyVideosByCollectionId',
+        '/longvideoapi/video/v2/detail',
+        '/longvideoapi/video/v2/sharePageDetail',
+        '/longvideoapi/video/send',
+        '/longvideoapi/video/getCoverImagePaths',
+        '/longvideoapi/video/updateVideo',
+        '/longvideoapi/video/deleteVideo',
+        '/longvideoapi/video/barrage/send',
+        '/longvideoapi/video/barrage/switch',
+        '/longvideoapi/video/videoActionReport',
+        '/longvideoapi/video/barrage/v2/list',
+        '/longvideoapi/video/shared/h5"',
+        '/longvideoapi/user/share/report',
+        '/longvideoapi/oss/signature',
+        '/longvideoapi/oss/completeUpload',
+        '/longvideoapi/oss/producevideo/getStsToken',
+        '/longvideoapi/operate/message/list',
+        '/longvideoapi/video/message/list',
+        '/longvideoapi/sys/message/list',
+        '/longvideoapi/user/station/message/statistics/info',
+        '/longvideoapi/user/station/message/statistics/read',
+        '/longvideoapi/user/station/message/totalCount/v2',
+        '/longvideoapi/user/station/message/totalRead',
+        '/longvideoapi/user/station/notice/list',
+        '/longvideoapi/user/station/message/share/list',
+        '/longvideoapi/user/station/message/prise/list',
+        '/longvideoapi/user/station/message/favorite/list',
+        '/longvideoapi/user/station/message/comment/list',
+        '/longvideoapi/user/station/message/barrage/list',
+        '/longvideoapi/operation/message/list',
+        '/longvideoapi/search/userandvideo/list',
+        '/longvideoapi/search/tips',
+        '/longvideoapi/search/user/list',
+        '/longvideoapi/search/video/list',
+        '/longvideoapi/search/hot/words',
+        '/longvideoapi/search/hot/videos',
+        '/longvideoapi/video/distribute/search/recommendVideoes/v2',
+        '/longvideoapi/comment/top/save',
+        '/longvideoapi/comment/top/page',
+        '/longvideoapi/comment/praise',
+        '/longvideoapi/comment/second/save',
+        '/longvideoapi/comment/second/page',
+        '/longvideoapi/comment/delete',
+        '/longvideoapi/comment/updelete',
+        '/longvideoapi/comment/hots',
+        '/longvideoapi/bank/withdraw/getBankWithdrawConfig',
+        '/longvideoapi/bank/withdraw/getBankWithdrawRecordList',
+        '/longvideoapi/bank/withdraw/wxSamllapp/requestWithdraw',
+        '/longvideoapi/purchase/video/list',
+        '/longvideoapi/profits/myself/head',
+        '/longvideoapi/profits/myself/list',
+        '/longvideoapi/profits/myself/recordList/v2',
+        '/longvideoapi/profits/reward/recordListAccordingToUser',
+        '/longvideoapi/profits/reward/recordListAccordingToVideo',
+        '/longvideoapi/video/reward/getVideoRewardHeadInfo',
+        '/longvideoapi/video/reward/getVideoRewardRecordList',
+        '/longvideoapi/video/reward/getVideoRewardConfig',
+        '/longvideoapi/video/reward/getVideoRewardConfig/v2',
+        '/longvideoapi/order/updateClientPayStatus',
+        '/longvideoapi/order/purchase',
+        '/longvideoapi/profits/videoPay/head',
+        '/longvideoapi/profits/videoPay/list',
+        '/longvideoapi/video/getPayedVideoPath',
+        '/longvideoapi/order/reward',
+        '/longvideoapi/video/reward/getVideoDetailRewardInfo',
+        '/longvideoapi/video/recommend/detailPage/list',
+        '/longvideoapi/video/recommend/sharePage/list',
+        '/longvideoapi/measure/report/view',
+        '/longvideoapi/video/validatePwd"',
+        '/longvideoapi/video/validatePwdAuth"',
+        '/longvideoapi/video/v2/getCutVideo',
+        '/longvideoapi/frontConfig/getWxFrontConfig',
+        '/longvideoapi/frontConfig/getVideoPlayConfig',
+        '/longvideoapi/frontConfig/getUserFrontConfig',
+        '/longvideoapi/rhythmapp/homepage/getAllVideos',
+        '/longvideoapi/ad/position/info'
         ]
 
     # for i in range(len(instance_info["Instances"]["Instance"])):
@@ -178,7 +195,58 @@ if __name__ == '__main__':
     # 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
     # print(start_time , end_time)
+
+    HOST = 'rm-bp1k5853td1r25g3n690.mysql.rds.aliyuncs.com'
+    PORT = '3306'
+    DATABASE = 'devops'
+    USERNAME = 'devops'
+    PASSWORD = 'devops@123456'
+    conn = pymysql.connect(host=HOST, user=USERNAME, password=PASSWORD, database=DATABASE, charset="utf8")
+    cursor = conn.cursor()
+
     appType = ['0', '4', '5', '6', '12' ,'15']
     for index in range(len(appType)):
-        # qps = count_qps(url, appType[index])
-        print(appType[index])
+        type = appType[index]
+        res = count_avg_max(type)
+        for i in range(len(res.body)):
+            url = res.body[i]["requestUri"]
+            cnt = res.body[i]["cnt"]
+            max_time = res.body[i]["max_time"]
+            avg_time = res.body[i]["avg_time"]
+            sql = "UPDATE `reuqest_url_list`  set `qps`=%s, `max_time`=%s, `avg_time`=%s WHERE `request_url` ='%s' and `apptype`=%s"%(cnt, max_time, avg_time, url, type)
+            cursor.execute(sql)
+            conn.commit()
+        for i in range(len(res.body)):
+            url = res.body[i]["requestUri"]
+            cnt = res.body[i]["cnt"]
+            sql = "UPDATE `reuqest_url_list`  set `rt_1`=%s WHERE `request_url` ='%s' and `apptype`=%s"%(cnt, url, type)
+            cursor.execute(sql)
+            conn.commit()
+
+        res = count_rt_less_time_count(type, 200, 500)
+        for i in range(len(res.body)):
+            url = res.body[i]["requestUri"]
+            cnt = res.body[i]["cnt"]
+            sql = "UPDATE `reuqest_url_list`  set `rt_2`=%s WHERE `request_url` ='%s' and `apptype`=%s" % (cnt, url, type)
+            cursor.execute(sql)
+            conn.commit()
+
+        res = count_rt_less_time_count(type, 500, 1000)
+        for i in range(len(res.body)):
+            url = res.body[i]["requestUri"]
+            cnt = res.body[i]["cnt"]
+            sql = "UPDATE `reuqest_url_list`  set `rt_3`=%s WHERE `request_url` ='%s' and `apptype`=%s" % (cnt, url, type)
+            cursor.execute(sql)
+            conn.commit()
+
+        res = count_rt_less_time_count(type, 1000, 10000)
+        for i in range(len(res.body)):
+            url = res.body[i]["requestUri"]
+            cnt = res.body[i]["cnt"]
+            sql = "UPDATE `reuqest_url_list`  set `rt_4`=%s WHERE `request_url` ='%s' and `apptype`=%s" % (cnt, url, type)
+            cursor.execute(sql)
+            conn.commit()
+
+
+
+

+ 114 - 51
utils.py

@@ -11,6 +11,7 @@ from aliyun.log.logclient import LogClient
 from aliyun.log.getlogsrequest import GetLogsRequest
 import  requests
 import  time
+import  datetime
 import  pymysql
 from sqlalchemy.sql import func
 from model_longvideo import produce_video_project
@@ -288,7 +289,7 @@ def  count_qps_avgtime(appType):
     end_time = start_time - 60
     # url = '/longvideoapi/user/idolsUpdated'
     req = GetLogsRequest(project, logstore, end_time, start_time, topic,
-                         "params.appType=%s | select requestUri,count(1) as cnt  , avg(expendTime)  as avg_time group by requestUri  order by requestUri,cnt desc limit  1000" %(appType), 30, 0, False)
+                         "params.appType=%s | select requestUri,count(1) as cnt  , avg(expendTime)   as avg_time  group by requestUri  order by requestUri,cnt desc limit  1000" %(appType), 30, 0, False)
     try:
         res = client.get_logs(req)
     except Exception as e:
@@ -296,6 +297,27 @@ def  count_qps_avgtime(appType):
 
     return  res
 
+def  count_avg_max(appType):
+    endpoint = 'cn-hangzhou.log.aliyuncs.com'
+    accessKeyId = 'LTAIWYUujJAm7CbH'
+    accessKey = 'RfSjdiWwED1sGFlsjXv0DlfTnZTG1P'
+    logstore = 'request-log'
+    client = LogClient(endpoint, accessKeyId, accessKey)
+    project = 'wqsd-longvideoapi'
+    topic = ""
+    start_time = int(time.time())
+    end_time = start_time - (60*15)
+    # url = '/longvideoapi/user/idolsUpdated'
+    req = GetLogsRequest(project, logstore, end_time, start_time, topic,
+                         "params.appType=%s | select requestUri,count(1) as cnt  , max(expendTime)  as max_time ,round(avg(expendTime),2) as avg_time group by requestUri  order by requestUri,cnt desc limit  1000" %(appType), 30, 0, False)
+    try:
+        res = client.get_logs(req)
+    except Exception as e:
+        avgs = 0
+
+    return  res
+
+
 def  count_rt_less_time_count(appType, than, less):
     endpoint = 'cn-hangzhou.log.aliyuncs.com'
     accessKeyId = 'LTAIWYUujJAm7CbH'
@@ -312,7 +334,25 @@ def  count_rt_less_time_count(appType, than, less):
     try:
         res = client.get_logs(req)
     except Exception as e:
-        avgs = 0
+        print(e)
+    return  res
+
+def  error_cnt(appType):
+    endpoint = 'cn-hangzhou.log.aliyuncs.com'
+    accessKeyId = 'LTAIWYUujJAm7CbH'
+    accessKey = 'RfSjdiWwED1sGFlsjXv0DlfTnZTG1P'
+    logstore = 'request-log'
+    client = LogClient(endpoint, accessKeyId, accessKey)
+    project = 'wqsd-longvideoapi'
+    topic = ""
+    start_time = int(time.time())
+    end_time = start_time - 60
+    req = GetLogsRequest(project, logstore, end_time, start_time, topic,
+                         "params.appType=%s and (resultCode:-111 or resultCode:-990  or resultCode:-994 or resultCode:-666 or resultCode:-222)| SELECT COUNT(*) as cnt, resultCode group by  resultCode" %(appType), 30, 0, False)
+    try:
+        res = client.get_logs(req)
+    except Exception as e:
+        print(e)
 
     return  res
 
@@ -338,52 +378,75 @@ def app_openapi_qps_avgtime_count():
 
 
 
-if __name__ == '__main__':
-    # slb_status_code_count("clip")
-    # healthcheck_result = []
-    # with session_maker() as session:
-    #     instance_infos = session.query(InstanceList).filter(InstanceList.status==0).all()
-    #     for index in range(len(instance_infos)):
-    #         ipaddr = instance_infos[index].ipadd
-    #         server_name = instance_infos[index].server_name
-    #         http_code = healthcheck(ipaddr,server_name)
-    #         result = {"ipaddr": ipaddr, "server_name": server_name, "http_code": http_code}
-    #         healthcheck_result.append(result)
-    # print(healthcheck_result)
-    # produce_video_task_status_count()
-    # res = logs_tts_count("aliyun",1)
-    # if res[0]["count"]:
-    #     print(res[0]["count"])
-    # res = logs_tts_count("aliyun", 0)
-    # if res[0]["count"]:
-    #     print(res[0]["count"])
-    # res = logs_tts_count("azure", 1)
-    # if res[0]["count"]:
-    #     print(res[0]["count"])
-    # res = logs_tts_count("aliyun", 0)
-    # if res[0]["count"]:
-    #     print(res[0]["count"])
-    # res = count_recommend_nu
-    # res = count_qps_avgtime(appType=0)
-    # print(res.body)
-    # for i in range(len(res.body)):
-    #     url = res.body[i]["requestUri"]
-    #
-    #     qps = res.body[i]["cnt"]
-    #     avgtime = round(float(res.body[i]["avg_time"]), 2)
-    #     print(url,qps ,avgtime)
-
-    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 > '20210804000000000111111' and t1.project_id < '20210805000000000111111' and t1.app_type not in (1,13,15)) s1) ss1"
-
-                )
-    res = db_query(query_sql)
-    print(res)
+
+def produce_video_data():
+    start_time = (int(time.strftime("%Y%m%d", time.localtime()))) * 1000000000000000
+
+    end_time = (int(time.strftime("%Y%m%d", time.localtime())) + 1) * 1000000000000000
+    # start_time = (int(datetime.strftime("%Y%m%d",datetime.date.today()))
+    print(start_time, end_time)
+    sum_sql = ("select count(*) as totalCount "              
+              "from produce_video_project t1 "
+              " where t1.project_id > %s and t1.project_id < %s and t1.app_type not in (1,13,15) "% (start_time,end_time)
+               )
+    res = db_query(sum_sql)
+
+    return
+
+def  update_request_url_list():
+    HOST = 'rm-bp1k5853td1r25g3n690.mysql.rds.aliyuncs.com'
+    PORT = '3306'
+    DATABASE = 'devops'
+    USERNAME = 'devops'
+    PASSWORD = 'devops@123456'
+    conn = pymysql.connect(host=HOST, user=USERNAME, password=PASSWORD, database=DATABASE, charset="utf8")
+    cursor = conn.cursor()
+    print("5m定时任务开始")
+    appType = ['0', '4', '5', '6', '12', '15']
+    for index in range(len(appType)):
+        type = appType[index]
+        res = count_avg_max(type)
+        for i in range(len(res.body)):
+            url = res.body[i]["requestUri"]
+            cnt = res.body[i]["cnt"]
+            max_time = res.body[i]["max_time"]
+            avg_time = res.body[i]["avg_time"]
+            sql = "UPDATE `reuqest_url_list`  set `qps`=%s, `max_time`=%s, `avg_time`=%s WHERE `request_url` ='%s' and `apptype`=%s" % (
+            cnt, max_time, avg_time, url, type)
+            cursor.execute(sql)
+            conn.commit()
+        for i in range(len(res.body)):
+            url = res.body[i]["requestUri"]
+            cnt = res.body[i]["cnt"]
+            sql = "UPDATE `reuqest_url_list`  set `rt_1`=%s WHERE `request_url` ='%s' and `apptype`=%s" % (
+            cnt, url, type)
+            cursor.execute(sql)
+            conn.commit()
+
+        res = count_rt_less_time_count(type, 200, 500)
+        for i in range(len(res.body)):
+            url = res.body[i]["requestUri"]
+            cnt = res.body[i]["cnt"]
+            sql = "UPDATE `reuqest_url_list`  set `rt_2`=%s WHERE `request_url` ='%s' and `apptype`=%s" % (
+            cnt, url, type)
+            cursor.execute(sql)
+            conn.commit()
+
+        res = count_rt_less_time_count(type, 500, 1000)
+        for i in range(len(res.body)):
+            url = res.body[i]["requestUri"]
+            cnt = res.body[i]["cnt"]
+            sql = "UPDATE `reuqest_url_list`  set `rt_3`=%s WHERE `request_url` ='%s' and `apptype`=%s" % (
+            cnt, url, type)
+            cursor.execute(sql)
+            conn.commit()
+
+        res = count_rt_less_time_count(type, 1000, 10000)
+        for i in range(len(res.body)):
+            url = res.body[i]["requestUri"]
+            cnt = res.body[i]["cnt"]
+            sql = "UPDATE `reuqest_url_list`  set `rt_4`=%s WHERE `request_url` ='%s' and `apptype`=%s" % (
+            cnt, url, type)
+            cursor.execute(sql)
+            conn.commit()
+# if __name__ == '__main__':