简体   繁体   English

列表项计数超过 1 的 GCP 日志浏览器过滤器

[英]GCP log explorer filter for list item count more than 1

I am trying to write a filter in GCP log explorer, which can look for a count of the values of an attribute.我正在尝试在 GCP 日志资源管理器中编写一个过滤器,它可以查找属性值的计数。

Example: I am trying to find the logs like below, which has two items for "referencedTables" attribute.示例:我正在尝试查找如下所示的日志,其中包含两个“referencedTables”属性项。 GCP Log Explorer Screenshot GCP 日志浏览器屏幕截图

I have tried below options which doesn't work -我尝试了以下不起作用的选项 -

protoPayload.metadata.jobChange.job.jobStats.queryStats.referencedTables.*.count>1 protoPayload.metadata.jobChange.job.jobStats.queryStats.referencedTables.*.count>1

protoPayload.metadata.jobChange.job.jobStats.queryStats.referencedTables.count>1 protoPayload.metadata.jobChange.job.jobStats.queryStats.referencedTables.count>1

Also tried Regex looking for "tables" keyword occurrence twice -还尝试了两次寻找“表格”关键字出现的正则表达式 -

protoPayload.metadata.jobChange.job.jobStats.queryStats.referencedTable=~"(\tables+::\tables+))" protoPayload.metadata.jobChange.job.jobStats.queryStats.referencedTable=~"(\tables+::\tables+))"

Also tried Regex querying second item, which means there are more than one items -还尝试了 Regex 查询第二个项目,这意味着有多个项目 -

protoPayload.metadata.jobChange.job.jobStats.queryStats.referencedTables 1 =~"^[A-Za-z0-9_.]+$" protoPayload.metadata.jobChange.job.jobStats.queryStats.referencedTables 1 =~"^[A-Za-z0-9_.]+$"

Note that - these types of logs are BigQuery audit logs, that are logged in GCP logging service, when you run "insert into.. select" type of queries in BigQuery.请注意,当您在 BigQuery 中运行“插入到..选择”类型的查询时,这些类型的日志是 BigQuery 审核日志,它们会记录在 GCP 日志服务中。

I think you can't use logging filters to filter across log entries only within a log entry.我认为您不能仅日志条目使用日志过滤器来过滤日志条目。

One solution to your problem is log-based metrics where you'd create a metric by extracting values from logs but you'd then have to use MQL to query (eg count) the metric.您的问题的一种解决方案是基于日志的指标,您可以通过从日志中提取值来创建指标,随后您必须使用MQL来查询(例如计数)指标。

A more simple (albeit ad hoc) solution is to use use gcloud logging read to --filter the logs (possibly --format the results in JSON for easier processing) and then pipeline the results into a tool like jq where you could count the results.一个更简单(尽管是临时)的解决方案是使用gcloud logging read--filter日志(可能--format JSON 中的结果以便于处理),然后将结果传输到jq这样的工具中,您可以在其中计算结果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM