fluent-plugin-json-by-name
what does this plugin do
With this plugin you can add json fields as fluent field by the name of the json field
Configuration
For just indexing, provide the fields with value null in json:
<filter **>
@type json_by_name
fields_to_index {
"test1": null,
"test2": null,
"test3": null
}
</filter>
If you also want to rename the field, provide a new name as string instead of null. All this also works for nested fields:
<filter **>
@type json_by_name
fields_to_index {
"test1": null,
"test2": "this_was_field_test2",
"nested": {
"test3": null,
"test4": "this_was_nested_field_test4"
}
}
</filter>
Assuming the above config, then the plugin would act as follows:
Inputs
{"message": "{\"test1\": true}"}
{"message": "{\"test2\": true}"}
{"message": "{\"nested\": {\"test3\": true}}"}
{"message": "{\"nested\": {\"test4\": true}}"}
Outputs
{"message": "{\"test1\": true}", "test1": true}
{"message": "{\"test2\": true}", "this_was_field_test2": true}
{"message": "{\"nested\": {\"test3\": true}}", "nested.test3": true}
{"message": "{\"nested\": {\"test4\": true}}", "this_was_nested_field_test4": true}
More examples can be found in test/plugin/test_filter_json_by_name.rb
Testing
bundle install
rake