-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Add a field mapping transformer #851
Comments
I made a simple attempt to implement this idea, not hard to implement |
I added config file parser for this
[transforms.map_fields]
type = "fieldmapper"
inputs = ["transform_timestamp"]
[transforms.map_fields.fields]
status = "http_status"
[sinks.my_sink1]
type = "console"
inputs = ["map_fields"]
target = "stdout"
encoding = "json"
[sinks.my_sink2]
type = "console"
inputs = ["transform_timestamp"]
target = "stdout"
encoding = "json" Using this transformer I filtered |
Thanks for opening this @xcaptain! You're right that there is a gap in those transforms around renaming fields. This is a good example of a situation where I'd recommend using the lua transform. Here's the equivalent of your example config: [transforms.map_fields]
type = "lua"
inputs = ["transform_timestamp"]
source = """
event["http_status"] = event["status"]
"""
[sinks.my_sink1]
type = "console"
inputs = ["map_fields"]
target = "stdout"
encoding = "json"
[sinks.my_sink2]
type = "console"
inputs = ["transform_timestamp"]
target = "stdout"
encoding = "json" If you want to remove the old We are also in the process of planning a more general transform that will consolidate adding, removing, renaming, coercing, etc into a single more powerful transform (see #750). |
Closing in favor of #750 |
The lua transform is modify |
A raw log may contain many fields but at last we may only care some of them and want them to have a different name, For example, a transformer produces log like
we may want to rename field
a
tob
and remove fieldc
and get a result likecurrently the
add_fields
andremove_fields
transformer can not achieve this goal.The text was updated successfully, but these errors were encountered: