panwang %!s(int64=3) %!d(string=hai) anos
pai
achega
359f1a62a0
Modificáronse 3 ficheiros con 29 adicións e 10 borrados
  1. BIN=BIN
      __pycache__/app.cpython-37.pyc
  2. BIN=BIN
      __pycache__/utils.cpython-37.pyc
  3. 29 10
      app.py

BIN=BIN
__pycache__/app.cpython-37.pyc


BIN=BIN
__pycache__/utils.cpython-37.pyc


+ 29 - 10
app.py

@@ -50,7 +50,8 @@ produce_video_task_total = Gauge("produce_video_task_total", 'total', ['total_cn
 produce_video_task_sucess = Gauge("produce_video_task_sucess", 'sucess', ['sucess_cnt'], registry=registry)
 produce_video_task_ratio = Gauge("produce_video_task_ratio", 'produce_video_ratio', ['ratio'], registry=registry)
 
-produce_video_tts_count = Gauge("tts_aliyun_azure", 'success', ['tts_channel'], registry=registry)
+produce_video_tts_count = Gauge("produce_video_tts_count", 'success', ['tts_channel'], registry=registry)
+produce_video_tts_ratio = Gauge("produce_video_tts_ratio", 'ratio', ['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)
 
@@ -281,24 +282,42 @@ def all_metric():
 
     res = logs_tts_count("aliyun",1)
     if res is not None:
-        produce_video_tts_count.labels("aliyun_success").set(res[0]["count"])
+        aliyun_success = int(res[0]["count"])
     else:
-        produce_video_tts_count.labels("aliyun_success").set(0)
+        aliyun_success = 0
+    produce_video_tts_count.labels("aliyun_success").set(aliyun_success)
+
     res = logs_tts_count("aliyun", 0)
     if res is not None:
-        produce_video_tts_count.labels("aliyun_fail").set(res[0]["count"])
+        aliyun_fail = int(res[0]["count"])
     else:
-        produce_video_tts_count.labels("aliyun_fail").set(0)
+        aliyun_fail = 0
+    produce_video_tts_count.labels("aliyun_fail").set(aliyun_fail)
+
     res = logs_tts_count("azure", 1)
     if res is not None:
-        produce_video_tts_count.labels("azure_success").set(res[0]["count"])
+        azure_success = int(res[0]["count"])
     else:
-        produce_video_tts_count.labels("azure_success").set(0)
+        azure_success = 0
+    produce_video_tts_count.labels("azure_success").set(azure_success)
+
+
     res = logs_tts_count("azure", 0)
     if res is not None:
-        produce_video_tts_count.labels("azure_fail").set(res[0]["count"])
+        azure_fail = int(res[0]["count"])
     else:
-        produce_video_tts_count.labels("azure_fail").set(0)
+        azure_fail = 0
+    produce_video_tts_count.labels("azure_fail").set(azure_fail)
+
+    aliyun_cnt = aliyun_success + aliyun_fail
+    azure_cnt =  azure_success + azure_fail
+    aliyun_ratio = round(aliyun_success/aliyun_cnt,4)
+    azure_ratio = round(azure_success/azure_cnt, 4)
+    produce_video_tts_ratio.labels("aliyun").set(aliyun_ratio)
+    produce_video_tts_ratio.labels("azure").set(azure_ratio)
+
+
+
 
     #当日负载均衡http_code
     svc_name = {'longvideoapi', 'clip', 'speed', 'commonapi'}
@@ -417,7 +436,7 @@ def svc_healthcheck():
             print(ipaddr, svc_name)
             http_code = healthcheck(ipaddr, svc_name)
             print(http_code)
-            healthcheck_status.labels(svc_name, ipaddr).set(http_code)
+            healthcheck_status.labels(svc_name, ipaddr ).set(http_code)
 
 
     return Response(generate_latest(registry), mimetype="text/plain")