浏览代码

feat:添加分析任务

zhaohaipeng 1 年之前
父节点
当前提交
299e4ef6fb
共有 1 个文件被更改,包括 5 次插入0 次删除
  1. 5 0
      feature_spark_monitor.py

+ 5 - 0
feature_spark_monitor.py

@@ -119,6 +119,11 @@ def _main():
     # 获取最近七小时的Spark任务
     hours_7_early = int((datetime.now() - timedelta(hours=7)).timestamp()) * 1000
     result = yarn_client.get_apps(finished_time_begin=hours_7_early)
+
+    if len(result) == 0:
+        print("未获取到数据,跳过本次告警")
+        return
+
     result = [
         {**item, 'name': item['name'].split(":")[1].strip()}
         for item in result