Created
February 6, 2017 13:44
-
-
Save nokute78/40529577fffdaa93c0af4dabf75fe933 to your computer and use it in GitHub Desktop.
in_lib: filter support
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <unistd.h> | |
#include <fluent-bit.h> | |
int main() | |
{ | |
int i; | |
int n; | |
char tmp[256]; | |
flb_ctx_t *ctx; | |
int in_ffd; | |
int filter_ffd; | |
int out_ffd; | |
/* Initialize library */ | |
ctx = flb_create(); | |
if (!ctx) { | |
exit(EXIT_FAILURE); | |
} | |
in_ffd = flb_input(ctx, "lib", NULL); | |
flb_input_set(ctx, in_ffd, "tag", "test", NULL); | |
filter_ffd = flb_filter(ctx, "stdout", NULL); | |
flb_filter_set(ctx, filter_ffd, "match", "test", NULL); | |
out_ffd = flb_output(ctx, "null", NULL); | |
/* Start the background worker */ | |
flb_start(ctx); | |
/* Push some data */ | |
for (i = 0; i < 100; i++) { | |
n = snprintf(tmp, sizeof(tmp) - 1, | |
"[%lu, {\"key\": \"val %i\"}]", | |
time(NULL), i); | |
flb_lib_push(ctx, in_ffd, tmp, n); | |
} | |
sleep(10); | |
flb_stop(ctx); | |
/* Release Resources */ | |
flb_destroy(ctx); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment