Skip to content

Instantly share code, notes, and snippets.

@nokute78
Created February 6, 2017 13:44
Show Gist options
  • Save nokute78/40529577fffdaa93c0af4dabf75fe933 to your computer and use it in GitHub Desktop.
Save nokute78/40529577fffdaa93c0af4dabf75fe933 to your computer and use it in GitHub Desktop.
in_lib: filter support
#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