【发布时间】:2019-02-21 10:58:35
【问题描述】:
在使用 Google Composer 和 DataProc 时,我被要求找到一种方法,以最少的点击次数将失败作业的详细信息提供给 Ops 用户。我在 DataProc Jobs 页面上找到了这个屏幕:
我想知道是否有办法在作业失败时通过电子邮件发送内容(包括完整日志文件的链接)?
【问题讨论】:
标签: google-cloud-platform google-cloud-dataproc
在使用 Google Composer 和 DataProc 时,我被要求找到一种方法,以最少的点击次数将失败作业的详细信息提供给 Ops 用户。我在 DataProc Jobs 页面上找到了这个屏幕:
我想知道是否有办法在作业失败时通过电子邮件发送内容(包括完整日志文件的链接)?
【问题讨论】:
标签: google-cloud-platform google-cloud-dataproc
您需要在DataProcSparkOperator 中设置email_on_failure = True 参数。
【讨论】:
您可以在捕获错误时编写自己的电子邮件功能。这是我在作业失败时发送的松弛消息的示例。
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);
}
}
【讨论】: