我需要在没有数据插入我的 BigQuery 表时发送电子邮件通知。为此,我正在使用日志记录和警报机制但是,我仍然无法收到任何电子邮件。以下是我遵循的步骤:
- 我在日志资源管理器中编写了如下查询:
现在我已经为那些指标类型为 COUNTER 的日志创建了一个指标,并且在过滤器部分显然我已经给出了上述查询。
现在我在 MONITORING 域下的 ALERTING 中创建了一个策略。这是随附的屏幕截图。我选择的警报策略是针对我之前创建的日志记录指标。
- 然后触发如下:
并在通知 channel 中添加了我的电子邮件 ID。
如果我遗漏了什么,有人可以帮助我吗?我的要求是在超过一天没有数据插入 Bigquery 表时收到警报。
而且,我可以在 Metrics Explorer 中看到,我创建的指标不是 ACTIVE。为什么会这样?
最佳答案
如 GCP docs 中所述:
Metric absence conditions require at least one successful measurement — one that retrieves data — within the maximum duration window after the policy was installed or modified.
For example, suppose you set the duration window in a metric-absence policy to 30 minutes. The condition isn't met if the subsystem that writes metric data has never written a data point. The subsystem needs to output at least one data point and then fail to output additional data points for 30 minutes.
意思是,您至少需要 1 个数据点(插入作业)才能为缺少的指标创建事件。
有两种选择:
- 创建一个人工日志条目以启动指标并至少有一个时间序列和数据点。
- 运行与创建的基于日志的指标相匹配的插入作业,以启动该指标。
关于您的最后一个问题,您创建的指标未激活,因为在过去 24 小时内没有任何写入数据指向它。如上所述,指标必须至少写入 1 个数据点。
引用custom metrics quota了解更多信息。
关于google-cloud-platform - 当没有数据上传到 GCP 中的 BigQuery 表时创建警报,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68673147/