我创建了一个Stackdriver Monitoring警报,当我的BigQuery表之一的大小在一天中增加了5%以上时,向我发送了一封电子邮件.警报工作正常,但我想接收有关触发警报的表是什么的信息.
I've created a Stackdriver Monitoring alert to send me an email when one of my BigQuery tables increases its size more than 5% during the day. The alert is working fine, but I would like to receive information on what is the table that is triggering the alert.
我尝试了在 GCP文档中找到的几种组合,但没有一个对我有用.现在我的文档模板看起来像这样:
I have tried several combinations that I have found in the GCP docs but none of them work for me. Right now my documentation template looks like this:
resource.label.table: ${resource.label.table} --> Returns null condition.name: ${condition.name} condition.display_name: ${condition.display_name} metric.type: ${metric.type} metric.display_name: ${metric.display_name} policy.name: ${policy.name} policy.display_name: ${policy.display_name} project: ${project} resource.type: ${resource.type}有人知道如何检索表名吗?
Does anyone know how to retrieve the table name?
推荐答案您可以在 BigQuery指标,resource.type可以是global,bigquery_project或bigquery_dataset.指标可以包括其他标签,可以通过 metric.labels.[KEY] .例如,storage/uploaded_row_count指标报告api和table:
As you can see in the list of BigQuery metrics, the resource.type can be global, bigquery_project or bigquery_dataset. Metrics can include additional labels that can be accessed through metric.labels.[KEY]. For example, the storage/uploaded_row_count metric reports api and table:
为了对此进行测试,我们创建了一个警报策略,该策略检查何时将行上载到表中:
To test this we create an alerting policy that checks whenever rows are uploaded to a table:
在${metric.labels.table}中使用以下文档模板:
Using the following documentation template with ${metric.labels.table}:
## BigQuery uploaded rows alert metric.labels.table: ${metric.labels.table} --- condition.name: ${condition.name} condition.display_name: ${condition.display_name} metric.type: ${metric.type} metric.display_name: ${metric.display_name} policy.name: ${policy.name} policy.display_name: ${policy.display_name} project: REDACTED resource.type: ${resource.type}然后,我们将一些行加载到BigQuery表中,当指标数据在约6小时后可用时,我们将获得具有正确表名(在本例中为cloudaudit_googleapis_com_data_access_20191223)的警报邮件:
Then we load some rows to a BigQuery table and, when the metric data is available after ~6 hours, we should get the alert mail with the correct table name (cloudaudit_googleapis_com_data_access_20191223 in this case):
编辑:它也可以与bigquery.googleapis/storage/stored_bytes指标配合使用:
EDIT: it also works fine with the bigquery.googleapis/storage/stored_bytes metric:
更多推荐
如何在Stackdriver警报文档中获取Bigquery表的名称
发布评论