Skip to content

Instantly share code, notes, and snippets.

@nokute78
Created February 8, 2017 12:23
Show Gist options
  • Save nokute78/ac22e0244f03867c5d90b7a0a118655d to your computer and use it in GitHub Desktop.
Save nokute78/ac22e0244f03867c5d90b7a0a118655d to your computer and use it in GitHub Desktop.
out_flowcounter hang up
#include <unistd.h>
#include <fluent-bit.h>
int main()
{
int i;
int n;
char tmp[256];
flb_ctx_t *ctx;
int in_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);
out_ffd = flb_output(ctx, "flowcounter", NULL);
flb_output_set(ctx, out_ffd, "match", "test", "unit", "second", 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\"}]",
1, 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