Skip to content

Commit

Permalink
[fluentGH-4260] Resolve domain name not found in conjunction with por…
Browse files Browse the repository at this point in the history
…t using cloud_id.
  • Loading branch information
030 committed May 16, 2022
1 parent 39d4ddf commit 94b58b0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
1 change: 1 addition & 0 deletions plugins/out_es/es.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#define FLB_ES_DEFAULT_TIME_KEYF "%Y-%m-%dT%H:%M:%S"
#define FLB_ES_DEFAULT_TAG_KEY "flb-key"
#define FLB_ES_DEFAULT_HTTP_MAX "512k"
#define FLB_ES_DEFAULT_HTTPS_PORT 443
#define FLB_ES_WRITE_OP_INDEX "index"
#define FLB_ES_WRITE_OP_CREATE "create"
#define FLB_ES_WRITE_OP_UPDATE "update"
Expand Down
23 changes: 22 additions & 1 deletion plugins/out_es/es_conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ struct flb_elasticsearch *flb_es_conf_create(struct flb_output_instance *ins,
char *aws_session_name = NULL;
#endif
char *cloud_host = NULL;
int cloud_port = FLB_ES_DEFAULT_HTTPS_PORT;
struct flb_uri *uri = ins->host.uri;
struct flb_uri_field *f_index = NULL;
struct flb_uri_field *f_type = NULL;
Expand Down Expand Up @@ -153,8 +154,28 @@ struct flb_elasticsearch *flb_es_conf_create(struct flb_output_instance *ins,
flb_es_conf_destroy(ctx);
return NULL;
}
flb_plg_debug(ctx->ins, "extacted cloud_host: '%s'", cloud_host);

flb_plg_debug(ctx->ins,
"check whether extracted cloud_host '%s' contains a port",
cloud_host);
cloud_host = strtok(cloud_host, ":");
flb_plg_debug(ctx->ins, "cloud_host without port: '%s'", cloud_host);

char *portChar = strtok(NULL, ":");
flb_plg_debug(ctx->ins, "extracted portChar: '%s'", portChar);
int port = (int)strtol(portChar, (char **)NULL, 10);
flb_plg_debug(ctx->ins, "converted portChart to port int: '%i'", port);
if (port == NULL) {
port = cloud_port;
}
flb_plg_debug(ctx->ins,
"checked whether extracted port was null and set it to "
"default https port or not. Outcome: '%i'",
port);

ins->host.name = cloud_host;
ins->host.port = 443;
ins->host.port = port;
}

/* Set default network configuration */
Expand Down

0 comments on commit 94b58b0

Please sign in to comment.