【问题标题】:Is there any way to email the job status of a Google DataProc job when it fails?有什么方法可以在 Google DataProc 作业失败时通过电子邮件发送作业状态?
【发布时间】:2019-02-21 10:58:35
【问题描述】:

在使用 Google Composer 和 DataProc 时,我被要求找到一种方法,以最少的点击次数将失败作业的详细信息提供给 Ops 用户。我在 DataProc Jobs 页面上找到了这个屏幕:

我想知道是否有办法在作业失败时通过电子邮件发送内容(包括完整日志文件的链接)?

【问题讨论】:

    标签: google-cloud-platform google-cloud-dataproc


    【解决方案1】:

    您需要在DataProcSparkOperator 中设置email_on_failure = True 参数。

    【讨论】:

    • 谢谢 - 我希望有一些东西可以通过电子邮件发送错误的实际正文(如上所附),但我认为没有,所以你的解决方案对我有用。
    【解决方案2】:

    您可以在捕获错误时编写自己的电子邮件功能。这是我在作业失败时发送的松弛消息的示例。

     private void runCommand(String commandName,
                            String[] commandArgs) {
    
        try (CommandContext commandContext = createCommandContext()) {
            // find and run the command
            SparkCommand command = commandContext.findCommand(commandName);
    
            checkSparkResource(command.context.sc());
            command.main(commandArgs);
    
        } catch (Exception e) {
            logger.error(e.getMessage(), e);
    
            String message = "Something wrong~";
            String title = "Run Job on Dataproc:" + commandName + " Fail";
            String text = e.getMessage();
    
            SlackNotifier.instance()
                         .error(message, title, text);
        }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-14
      • 1970-01-01
      • 2015-10-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多