New replace_keys
Remap function
#5377
Labels
domain: vrl
Anything related to the Vector Remap Language
needs: approval
Needs review & approval before work can begin.
sink: elasticsearch
Anything `elasticsearch` sink related
type: enhancement
A value-adding code change that enhances its existing functionality.
Blocked in #5785. The remap language has support for manipulating strings in event values, for example with the
replace
function. To do the equivalent with keys is not possible.The use case is described in #3588, where keys containing dots can lead to broken indexing. A trivial solution would be to replace all dots with underscores, as is done by the
de_dot
filter in both Elasticsearch and Logstash. Better would be to support fully parameterized replacement just like thereplace
function does for values.Suggested function:
replace_keys(map, regex | string, string, count = integer, depth = boolean) :: map
Parameters are the same as for
replace
except for the first and the return type, both of which are maps instead of strings, and the additionaldepth
options, which will cause it to recurse into maps and replace all their keys as well.Usage for the scenario above would be something like:
. = replace_keys(., ".", "_", depth = true)
The text was updated successfully, but these errors were encountered: