Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhancement(regex_parser transform): Add support for target_field #2023

Merged
merged 11 commits into from
Apr 1, 2020
31 changes: 29 additions & 2 deletions .meta/transforms/regex_parser.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ input_types = ["log"]
output_types = ["log"]
requirements = {}

<%= render("_partials/fields/_component_options.toml", type: "transform", name: "regex_parser") %>
<%= render(
"_partials/fields/_component_options.toml",
type: "transform",
name: "regex_parser"
) %>

[transforms.regex_parser.options.drop_field]
type = "bool"
Expand All @@ -26,6 +30,14 @@ examples = ["message", "parent.child"]
field_path_notation = true
description = "The log field to parse."

[transforms.regex_parser.options.overwrite_target]
type = "bool"
default = true
description = """\
If `target_field` is set and the log contains a field of the same name \
as the target, it will only be overwritten if this is set to `true`.\
"""

[transforms.regex_parser.options.regex]
type = "string"
common = true
Expand All @@ -39,4 +51,19 @@ description = """\
The Regular Expression to apply. Do not include the leading or trailing `/`.\
"""

<%= render("_partials/fields/_types_options.toml", namespace: "transforms.regex_parser.options", common: true) %>
[transforms.regex_parser.options.target_field]
type = "string"
examples = ["root_field", "parent.child"]
field_path_notation = true
description = """\
If this setting is present, the parsed fields will be inserted into the \
log as a sub-object with this name. \
If a field with the same name already exists, the parser will fail and \
produce an error.\
"""

<%= render(
"_partials/fields/_types_options.toml",
namespace: "transforms.regex_parser.options",
common: true
) %>
19 changes: 19 additions & 0 deletions config/vector.spec.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2103,6 +2103,25 @@ end
field = "message"
field = "parent.child"

# If `target_field` is set and the log contains a field of the same name as the
# target, it will only be overwritten if this is set to `true`.
#
# * optional
# * default: true
# * type: bool
overwrite_target = true
overwrite_target = false

# If this setting is present, the parsed fields will be inserted into the log
# as a sub-object with this name. If a field with the same name already exists,
# the parser will fail and produce an error.
#
# * optional
# * no default
# * type: string
target_field = "root_field"
target_field = "parent.child"

#
# Types
#
Expand Down
Loading