filter_record_modifier: use kv interface to query properties
#include <fluent-bit/flb_str.h>
#include <fluent-bit/flb_utils.h>
#include <fluent-bit/flb_mem.h>
+#include <fluent-bit/flb_kv.h>
#include <fluent-bit/flb_time.h>
#include <msgpack.h>
static int configure(struct record_modifier_ctx *ctx,
struct flb_filter_instance *f_ins)
{
+ struct flb_kv *kv = NULL;
struct mk_list *head = NULL;
struct mk_list *split;
- struct flb_config_prop *prop = NULL;
struct modifier_key *mod_key;
struct modifier_record *mod_record;
struct flb_split_entry *sentry;
@@ -46,16 +47,16 @@ static int configure(struct record_modifier_ctx *ctx,
/* Iterate all filter properties */
mk_list_foreach(head, &f_ins->properties) {
- prop = mk_list_entry(head, struct flb_config_prop, _head);
+ kv = mk_list_entry(head, struct flb_kv, _head);
- if (!strcasecmp(prop->key, "remove_key")) {
+ if (!strcasecmp(kv->key, "remove_key")) {
mod_key = flb_malloc(sizeof(struct modifier_key));
if (!mod_key) {
flb_errno();
continue;
}
- mod_key->key = prop->val;
- mod_key->key_len = strlen(prop->val);
+ mod_key->key = kv->val;
+ mod_key->key_len = flb_sds_len(kv->val);
if (mod_key->key[mod_key->key_len - 1] == '*') {
mod_key->dynamic_key = FLB_TRUE;
mod_key->key_len--;
@@ -66,14 +67,14 @@ static int configure(struct record_modifier_ctx *ctx,
mk_list_add(&mod_key->_head, &ctx->remove_keys);
ctx->remove_keys_num++;
}
- else if (!strcasecmp(prop->key, "whitelist_key")) {
+ else if (!strcasecmp(kv->key, "whitelist_key")) {
mod_key = flb_malloc(sizeof(struct modifier_key));
if (!mod_key) {
flb_errno();
continue;
}
- mod_key->key = prop->val;
- mod_key->key_len = strlen(prop->val);
+ mod_key->key = kv->val;
+ mod_key->key_len = flb_sds_len(kv->val);
if (mod_key->key[mod_key->key_len - 1] == '*') {
mod_key->dynamic_key = FLB_TRUE;
mod_key->key_len--;
@@ -84,13 +85,13 @@ static int configure(struct record_modifier_ctx *ctx,
mk_list_add(&mod_key->_head, &ctx->whitelist_keys);
ctx->whitelist_keys_num++;
}
- else if (!strcasecmp(prop->key, "record")) {
+ else if (!strcasecmp(kv->key, "record")) {
mod_record = flb_malloc(sizeof(struct modifier_record));
if (!mod_record) {
flb_errno();
continue;
}
- split = flb_utils_split(prop->val, ' ', 1);
+ split = flb_utils_split(kv->val, ' ', 1);
if (mk_list_size(split) != 2) {
flb_error("[%s] invalid record parameters, expects 'KEY VALUE'",
PLUGIN_NAME);
