removing multiple fields #13349
-
Hi!
so first i was tried to use del function with mask
But still got messages with this fields |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
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 I removed the error handling for brevity, and switched to Ex: $ .
{ "kubernetes": { "pod_annotations": { "checksum/result-backend-secret": "foo", "checksum/webserver-secret-key": "bar", "safe/key": "value" } } }
$ for_each(.kubernetes.pod_annotations) -> |key, _val| {
if starts_with(key, "checksum") {
. = remove!(., path: ["kubernetes", "pod_annotations", key])
}
}
null
$ .
{ "kubernetes": { "pod_annotations": { "safe/key": "value" } } } I was hoping Please let me know if this helped, and sorry again for the delayed reply! |
Beta Was this translation helpful? Give feedback.
Hi @Wilderone, sorry we missed this question!
You actually got pretty close, this is what I ended up using:
The event has a top level key of
kubernetes
which containspod_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 usingremove
I rebuilt the complete path we needed to delete as we were …