首页 > 解决方案 > 在 Cloud Logging 中具有现有过滤器的同时在所有字段中搜索值

问题描述

我在 Cloud Logging 中有以下过滤器,可显示来自特定实例的所有日志:

(resource.type="gce_instance" AND resource.labels.instance_id="***") OR (resource.type="global" AND jsonPayload.instance.id="***")

在这个集合中,我想在所有字段中搜索一个值。通过查看文档https://cloud.google.com/logging/docs/view/advanced-queries#searching-examples,我发现我可以unicorn在查询字段中写一个简单的单词,它会在所有字段中进行搜索。它可以工作,但它会搜索我的所有日​​志。但我只想在过滤后的日志集中搜索,而不是在 Cloud Logging 中的所有日志中搜索。我想获取包含该单词的所有行failed并尝试了以下操作:

((resource.type="gce_instance" AND resource.labels.instance_id="***") OR (resource.type="global" AND jsonPayload.instance.id="***")) and failed

但身份证不起作用。如何在已有过滤器的情况下搜索所有字段?

标签: google-cloud-logging

解决方案


尝试以这种方式运行查询格式的最后一部分:

((resource.type="gce_instance" AND resource.labels.instance_id="***") OR 
(resource.type="global" AND jsonPayload.instance.id="***")) AND "failed"

干杯,


推荐阅读