瀏覽代碼

monitor key

丁云鹏 1 月之前
父節點
當前提交
650ad6a90e
共有 1 個文件被更改,包括 6 次插入3 次删除
  1. 6 3
      recommend-feature-produce/src/main/python/monitor.py

+ 6 - 3
recommend-feature-produce/src/main/python/monitor.py

@@ -17,6 +17,9 @@ APOLLO_SERVER = "http://apolloconfig-internal.piaoquantv.com"
 APP_ID = "recommend-feature"
 NAMESPACE = "application"  # 或 "application"
 
+THRESHOLD=3000
+
+
 
 def get_apollo_config(
     config_server_url: str,
@@ -153,16 +156,16 @@ def main():
         table_name = item['odps']['table']
         
         try:
-            ttl,check=check_redis_ttl(redis_conn, table_name)
+            ttl,check=check_redis_ttl(redis_conn, table_name, THRESHOLD)
             if check:
-                alert_msg.append(f"Table: {table_name} Prefix: {prefix} TTL: {ttl}")
+                alert_msg.append(f"Table: {table_name} Expire: {ttl}")
         except redis.RedisError as e:
             print(f"Error checking Redis TTL for table {table_name}: {e}")
 
         # 5. 发送飞书报警
     if alert_msg:  # 如果有报警消息才发送
         alert_msg_str = "\n".join(alert_msg)  # 用换行符连接所有消息
-        if not send_feishu_alert(f"Redis TTL Alert: TTL is less than 3600s!\n{alert_msg_str}"):
+        if not send_feishu_alert(f"Redis TTL Alert: TTL is less than {THRESHOLD}s!\n{alert_msg_str}"):
             print("Failed to send Feishu alert")
     else:
         print("No Redis TTL alerts found.")