Commit 45b6863d authored by Xiaowu Zhang's avatar Xiaowu Zhang

add example

parent 412eead0
#include <fluent-bit.h>
#define JSON_1 "[1449505010, {\"key1\": \"some value\"}]"
#define JSON_2 "[1449505620, {\"key1\": \"some new value\"}]"
int main()
{
int ret;
int in_ffd;
int out_ffd;
flb_ctx_t *ctx;
/* Create library context */
ctx = flb_create();
if (!ctx) {
return -1;
}
/* Enable the input plugin for manual data ingestion */
in_ffd = flb_input(ctx, "lib", NULL);
if (in_ffd == -1) {
flb_destroy(ctx);
return -1;
}
/* Enable output plugin 'stdout' (print records to the standard output) */
out_ffd = flb_output(ctx, "stdout", NULL);
if (out_ffd == -1) {
flb_destroy(ctx);
return -1;
}
/* Start the engine */
ret = flb_start(ctx);
if (ret == -1) {
flb_destroy(ctx);
return -1;
}
/* Ingest data manually */
flb_lib_push(ctx, in_ffd, JSON_1, sizeof(JSON_1) - 1);
flb_lib_push(ctx, in_ffd, JSON_2, sizeof(JSON_2) - 1);
/* Stop the engine (5 seconds to flush remaining data) */
flb_stop(ctx);
/* Destroy library context, release all resources */
flb_destroy(ctx);
return 0;
}
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment