如何监控胶水爬虫执行统计信息?

How can I monitor glue crawler execution stats?

我正在使用 AWS Glue 进行数据 ETL。我找不到在 AWS 上监控 glue crawler 执行统计数据的方法。我知道如何像这个文档一样监控胶水作业:https://docs.aws.amazon.com/glue/latest/dg/monitoring-awsglue-with-cloudwatch-metrics.html。但是我想知道是否有类似的方法来检查 glue crawler 执行情况?

我可以在Cloudwatch中查看爬虫的日志,但它的可读性不是很好。我很难弄清楚在指定时间段内发生了多少次调用。

我问过 AWS 支持中心同样的问题。答案如下:

据我了解,Glue 爬虫不会发布执行的 CloudWatch 指标和您要监视的统计数据,但是 Glue 爬虫能够将日志发布到 CloudWatch 日志组和日志流。根据这些日志事件消息,您可以创建一个指标过滤器 [1] 来匹配特定的过滤器模式,并生成您自己的指标以进行监控和警报。例如,如果指标过滤器检测到过滤器模式 "Crawler has finished running and is in state READY",它将向您的自定义命名空间指标发布一个值。以下是创建指标过滤器的一些步骤:

1) Open the CloudWatch Log Groups console
2) Select the Glue crawler log group
3) Select Metric filters, choose Create metric filter
4) In Filter pattern, enter a pattern that you want to match in the log streams, ie: "Crawler has finished running and is in state READY", then choose Next
    4a) You can test your filter pattern against a log stream or by manually specifying log event messages
5) Enter a filter name, enter a customer metric namespace, metric name, metric value. The metric value while be published on the metric, ie: 1, then choose Next
6) Review the metric filter configuration and choose Create metric filter

CloudWatch Events 能够根据 Glue 爬虫状态变化调用目标,例如,如果爬虫状态变为失败,这可以调用 SNS 主题目标并向您发送电子邮件。以下是创建 CloudWatch 事件的一些步骤:

1) Open the CloudWatch Rules console
2) Choose Create rule
3) In Service Name, select Glue, in Event Type select Glue Crawler State Change
4) Choose Specific state(s) and choose Failed
5) Add a Target, for example SNS Topic, choose Configure details
6) Enter a Rule name and choose Create rule

享受剩下的一天。