如何在Stackdriver警报文档中获取Bigquery表的名称

编程入门 行业动态 更新时间:2024-10-11 13:21:27
本文介绍了如何在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可以是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表的名称

本文发布于:2023-11-27 22:19:02,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1639817.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:警报   名称   文档   如何在   Stackdriver

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!