简体   繁体   English

在 Google Cloud 的日志资源管理器中,您如何查询 jsonPayload 字典中是否存在某个键?

[英]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.

相关问题 如何通过 log4js-node 将标签传递给 Google Cloud Logs Explorer? - How do you pass labels to Google Cloud Logs Explorer through log4js-node? 谷歌云数据存储查询 - Google Cloud Datastore Query's 如何使用带有 jsonPayload 的 StructuredLogHandler 将日志发送到 GCP? - How to send logs to GCP using StructuredLogHandler with jsonPayload? 如何在 python 程序中定义我的 Google Cloud Platform 服务帐户的密钥? - How do I define my Google Cloud Platform service account's key in a python program? 使用 Google 的 API Explorer 发送 Firebase 云消息时,如何解决“THIRD_PARTY_AUTH_ERROR”背后的问题? - How do I fix the problem behind "THIRD_PARTY_AUTH_ERROR" when using Google's API Explorer to send a Firebase Cloud Messaging message? 如何让 Google Cloud Logging 以正确的警报级别显示我的 flask + gunicorn 应用程序的日志? - How can I get Google Cloud Logging to show my flask + gunicorn app's logs with the correct alert level? 如何使用 logback 从 google app engine 以 jsonPayload 的形式登录到 stackdriver? - How to log as jsonPayload to stackdriver from google app engine using logback? “HttpError”是否会导致 Google Cloud 可调用函数中的冷启动? - Do "HttpError"s cause cold starts in Google Cloud callable functions? 如何在 Google Cloud 的 SDK 中记录应用程序使用的所有权限 - How to log all permissions an application is using in Google Cloud's SDK 我们如何查看由 Google Cloud BigQuery 执行的查询计划? - How do we see a query plan executed by Google Cloud BigQuery?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM