2

We have a service which logs empty line. However, in GCP logs it is coming as empty jsonPayload

insertId: jksj3z7vr05sj
jsonPayload: {
}

I want to exclude such logs. Tried following queries individully

jsonPayload.field = NULL_VALUE
NOT jsonPayload.message = ""
NOT jsonPayload.message = "\n"

None of above worked.

Official docs:

  1. https://cloud.google.com/logging/docs/view/logging-query-language
kartikmaji
  • 946
  • 7
  • 22
  • I can think of only one (limited) way that you could do this and that would be to check for the existence of a `jsonPayload` field that is guaranteed to always be present in every other log (perhaps timestamp|ts?). `{}` isn't null, it's the empty object. – DazWilkin Aug 22 '22 at 17:47
  • @DazWilkin tried `jsonPayload.message: {}` one as well, this wasn't working – kartikmaji Aug 23 '22 at 03:57
  • Yes, apologies if I was unclear, you can't test for `{}`. It's an empty object and there's no syntax to support it. What I meant was something of the form `jsonPayload:* NOT jsonPayload.ts:*` (contains a `jsonPayload` but doesn't include a `jsonPayload.ts`). The challenge with this is (a) I don't know whether that supports `jsonPayload: {}` as I have none; (b) it requires that any non-empty `jsonPayload` contains `ts` field. You could also use `msg` or `message` if you are strict about including those fields. – DazWilkin Aug 23 '22 at 18:45
  • Did the comment of DazWilkin help you with your issue? Did you try another way to resolve the issue? – Ismael Clemente Aguirre Aug 29 '22 at 16:15

1 Answers1

1

As per dazwilkin's comment, this worked for me:

NOT jsonPayload.message:*