Skip to content

removing multiple fields #13349

Answered by spencergilbert
Wilderone asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @Wilderone, sorry we missed this question!

You actually got pretty close, this is what I ended up using:

for_each(.kubernetes.pod_annotations) -> |key, _val| {
  if starts_with(key, "checksum") {
    . = remove!(., path: ["kubernetes", "pod_annotations", key])
  }
}

The event has a top level key of kubernetes which contains pod_annotations an object of string values. Paths have a few invalid characters so the leaf keys you're working with are actually "checksum/...".

I removed the error handling for brevity, and switched to starts_with() since we just needed to match substrings, not anything complex. Finally, when using remove I rebuilt the complete path we needed to delete as we were …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Wilderone
Comment options

Answer selected by Wilderone
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants