Skip to content

[incomplete] modify filter API to be able to rename tag#291

Closed
nokute78 wants to merge 5 commits intofluent:masterfrom
nokute78:rename_tag
Closed

[incomplete] modify filter API to be able to rename tag#291
nokute78 wants to merge 5 commits intofluent:masterfrom
nokute78:rename_tag

Conversation

@nokute78
Copy link
Copy Markdown
Contributor

@nokute78 nokute78 commented Jun 9, 2017

To edit tag with filter plugin like fluentd, I modified filter API.
Then we can edit tag at filter plugin side.

This is a diff to rename tag with out_stdout.(just a sample)

diff --git a/plugins/filter_stdout/stdout.c b/plugins/filter_stdout/stdout.c
index 8289f4b..bfd3b7c 100644
--- a/plugins/filter_stdout/stdout.c
+++ b/plugins/filter_stdout/stdout.c
@@ -22,6 +22,8 @@
 #include <fluent-bit/flb_filter.h>
 #include <fluent-bit/flb_utils.h>
 #include <fluent-bit/flb_time.h>
+#include <fluent-bit/flb_mem.h>
+#include <fluent-bit/flb_str.h>
 
 #include <msgpack.h>
 
@@ -53,6 +55,10 @@ static int cb_stdout_filter(void *data, size_t bytes,
     struct flb_time tmp;
     msgpack_object *p;
 
+    flb_free(*tag);
+    *tag = flb_strdup("hoge");
+    *tag_len = 4;
+
     msgpack_unpacked_init(&result);
     while (msgpack_unpack_next(&result, data, bytes, &off)) {
         printf("[%zd] %s: [", cnt++, *tag);

nokute78 added 5 commits June 9, 2017 21:46
Signed-off-by: Takahiro YAMASHITA <nokute78@gmail.com>
Signed-off-by: Takahiro YAMASHITA <nokute78@gmail.com>
Signed-off-by: Takahiro YAMASHITA <nokute78@gmail.com>
Signed-off-by: Takahiro YAMASHITA <nokute78@gmail.com>
Signed-off-by: Takahiro YAMASHITA <nokute78@gmail.com>
@dawidmalina
Copy link
Copy Markdown

How this will work? Is it simillar like this fluentd plugin: rewrite_tag_filter?

@edsiper
Copy link
Copy Markdown
Member

edsiper commented Jun 13, 2017

@nokute78 is this tested with static and dynamic tags plugins ? (e.g: in_tail ) ?

@nokute78
Copy link
Copy Markdown
Contributor Author

@dawidmalina The PR doesn't add new function, but it will be ready to write the plugin to rewrite a tag.

@nokute78
Copy link
Copy Markdown
Contributor Author

@edsiper Yes, this PR makes to rewrite static and dynamic tags, but I forgot to take care routing.
So, tag will be able to rewrite, but record isn't delivered...

I think dyntag helps to routing. Is there any idea ?

@nokute78 nokute78 changed the title modify filter API to be able to rename tag [incomplete] modify filter API to be able to rename tag Jun 14, 2017
@repeatedly
Copy link
Copy Markdown
Member

To edit tag with filter plugin like fluentd

Fluentd's filter doesn't allow rewriting tag.

@nokute78
Copy link
Copy Markdown
Contributor Author

Oops, I had misunderstood. rewrite-tag-filter is output plugin..
Thank you for your comment. @repeatedly

This scheme makes routing more complex and worse performance.
I will discard this PR.

So, what we need is the way to re-emit.
It is helpful for out_flowcounter, too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants