[英]In Google Cloud's Logs Explorer, how do you query for a key's existence in the jsonPayload dict?
In Google's Cloud Logging query language, is it possible to query for the existence of a particular key in the jsonPayload
dict?在 Google 的 Cloud Logging 查询语言中,是否可以查询
jsonPayload
dict 中特定键的存在?
Eg, suppose I know the jsonPayload
will either be例如,假设我知道
jsonPayload
要么是
{'keyA':'<some string>'}
or要么
{'keyB':'<some string'}
But I don't know what the <some string>
will be.但我不知道
<some string>
会是什么。 I want all logs that have the keyB
key.我想要所有具有
keyB
密钥的日志。 I suppose I could test that for that key having a regex that includes everything, but is that the best/only way?我想我可以测试那个具有包含所有内容的正则表达式的密钥,但这是最好/唯一的方法吗?
I want all logs that have the keyB key.
我想要所有具有 keyB 密钥的日志。 I suppose I could test that for that key having a regex that includes everything, but is that the best/only way?
我想我可以测试那个具有包含所有内容的正则表达式的密钥,但这是最好/唯一的方法吗?
I could think of using Regex for this use case:我可以考虑在这个用例中使用Regex :
Example:例子:
jsonPayload.message =~"Job status: *"
In your case keyB
在你的情况下
keyB
jsonPayload.keyB =~"regex-query"
For my example, when the expression matches, getting output as below:对于我的例子,当表达式匹配时,得到 output 如下:
Use the "has" operator with a *, like使用带有 * 的“has”运算符,例如
jsonPayload.keyB:*
See the end of https://cloud.google.com/logging/docs/view/logging-query-language#comparisons见末尾https://cloud.google.com/logging/docs/view/logging-query-language#comparisons
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.