如何在Stackdriver警报文档中获取Bigquery表的名称 [英] How to get Bigquery table's name inside a Stackdriver alert documentation

本文介绍了如何在Stackdriver警报文档中获取Bigquery表的名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个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可以是globalbigquery_projectbigquery_dataset.指标可以包括其他标签,可以通过 metric.labels.[KEY] .例如,storage/uploaded_row_count指标报告apitable:

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.com/storage/stored_bytes指标配合使用:

EDIT: it also works fine with the bigquery.googleapis.com/storage/stored_bytes metric:

这篇关于如何在Stackdriver警报文档中获取Bigquery表的名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆