int cb_forward_init(struct flb_output_instance *ins, struct flb_config *config, void *data) { struct flb_out_forward_config *ctx; struct flb_upstream *upstream; struct flb_uri_field *f_tag = NULL; (void) data; ctx = flb_calloc(1, sizeof(struct flb_out_forward_config)); if (!ctx) { perror("calloc"); return -1; } /* Set default network configuration */ if (!ins->host.name) { ins->host.name = flb_strdup("127.0.0.1"); } if (ins->host.port == 0) { ins->host.port = 24224; } /* Prepare an upstream handler */ upstream = flb_upstream_create(config, ins->host.name, ins->host.port, FLB_IO_TCP, NULL); if (!upstream) { flb_free(ctx); return -1; } ctx->u = upstream; ctx->tag = FLB_CONFIG_DEFAULT_TAG; ctx->tag_len = sizeof(FLB_CONFIG_DEFAULT_TAG) - 1; if (ins->host.uri) { if (ins->host.uri->count > 0) { f_tag = flb_uri_get(ins->host.uri, 0); ctx->tag = f_tag->value; ctx->tag_len = f_tag->length; } } flb_output_set_context(ins, ctx); return 0; }
int cb_fluentd_init(struct flb_config *config) { int ret; struct flb_out_fluentd_config *ctx; ctx = calloc(1, sizeof(struct flb_out_fluentd_config)); if (!ctx) { perror("calloc"); return -1; } ret = flb_output_set_context("fluentd", ctx, config); if (ret == -1) { flb_utils_error_c("Could not set configuration for fluentd output plugin"); } return 0; }
int cb_td_init(struct flb_config *config) { int ret; struct flb_out_td_config *ctx; if (!config->file) { flb_utils_error_c("TD output requires a configuration file"); } ctx = td_config_init(config->file); if (!ctx) { return -1; } ret = flb_output_set_context("td", ctx, config); if (ret == -1) { flb_utils_error_c("Could not set configuration for td output plugin"); } return 0; }
int cb_td_init(struct flb_output_plugin *plugin, struct flb_config *config) { int ret; struct flb_out_td_config *ctx; struct flb_io_upstream *upstream; if (!config->file) { flb_utils_error_c("TD output requires a configuration file"); } ctx = td_config_init(config->file); if (!ctx) { return -1; } /* Default server */ plugin->net_host = strdup("api.treasuredata.com"); plugin->net_port = 443; upstream = flb_io_upstream_new(config, plugin->net_host, plugin->net_port, FLB_IO_TLS, (void *) &plugin->tls); if (!upstream) { free(ctx); return -1; } ctx->u = upstream; ret = flb_output_set_context("td", ctx, config); if (ret == -1) { flb_utils_error_c("Could not set configuration for td output plugin"); } return 0; }
int cb_es_init(struct flb_output_instance *ins, struct flb_config *config, void *data) { int io_type; char *tmp; struct flb_uri *uri = ins->host.uri; struct flb_uri_field *f_index = NULL; struct flb_uri_field *f_type = NULL; struct flb_out_es_config *ctx = NULL; struct flb_upstream *upstream; (void) data; if (uri) { if (uri->count >= 2) { f_index = flb_uri_get(uri, 0); f_type = flb_uri_get(uri, 1); } } /* Get network configuration */ if (!ins->host.name) { ins->host.name = flb_strdup("127.0.0.1"); } if (ins->host.port == 0) { ins->host.port = 9200; } /* Allocate plugin context */ ctx = flb_malloc(sizeof(struct flb_out_es_config)); if (!ctx) { perror("malloc"); return -1; } if (ins->use_tls == FLB_TRUE) { io_type = FLB_IO_TLS; } else { io_type = FLB_IO_TCP; } /* Prepare an upstream handler */ upstream = flb_upstream_create(config, ins->host.name, ins->host.port, io_type, &ins->tls); if (!upstream) { flb_free(ctx); return -1; } /* Set the context */ ctx->u = upstream; if (f_index) { ctx->index = f_index->value; } else { tmp = flb_output_get_property("index", ins); if (!tmp) { ctx->index = "fluentbit"; } else { ctx->index = tmp; } } if (f_type) { ctx->type = f_type->value; } else { tmp = flb_output_get_property("type", ins); if (!tmp) { ctx->type = "test"; } else { ctx->type = tmp; } } flb_debug("[es] host=%s port=%i index=%s type=%s", ins->host.name, ins->host.port, ctx->index, ctx->type); flb_output_set_context(ins, ctx); return 0; }