有没有办法在Google DataProc作业失败时通过电子邮件发送该作业状态?

问题描述 投票:1回答:2

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

enter image description here

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

google-cloud-platform google-cloud-dataproc
2个回答
3
投票

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


0
投票

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

 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);
    }
}
© www.soinside.com 2019 - 2024. All rights reserved.