1

In Google's Cloud Logging query language, is it possible to query for the existence of a particular key in the jsonPayload dict?

E.g., suppose I know the jsonPayload will either be

{'keyA':'<some string>'}

or

{'keyB':'<some string'}

But I don't know what the <some string> will be. I want all logs that have the keyB key. I suppose I could test that for that key having a regex that includes everything, but is that the best/only way?

BobMilton
  • 594
  • 5
  • 9

2 Answers2

2

I want all logs that have the keyB key. 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:

Example:

jsonPayload.message =~"Job status: *"  

In your case keyB

jsonPayload.keyB =~"regex-query"

For my example, when the expression matches, getting output as below:

enter image description here

Rathish Kumar B
  • 1,271
  • 10
  • 21
0

Use the "has" operator with a *, like

jsonPayload.keyB:*

See the end of https://cloud.google.com/logging/docs/view/logging-query-language#comparisons

Kirk Kelsey
  • 4,259
  • 1
  • 23
  • 26