Skip to content

Commit

Permalink
filter_ecs: make metadata API host and port configurable
Browse files Browse the repository at this point in the history
Signed-off-by: Wesley Pettit <[email protected]>
  • Loading branch information
PettitWesley committed Nov 1, 2022
1 parent be080bd commit ddcd65b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
22 changes: 18 additions & 4 deletions plugins/filter_ecs/ecs.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ static int cb_ecs_init(struct flb_filter_instance *f_ins,
}

ctx->ecs_upstream = flb_upstream_create(config,
FLB_ECS_FILTER_HOST,
FLB_ECS_FILTER_PORT,
ctx->ecs_host,
ctx->ecs_port,
FLB_IO_TCP,
NULL);

Expand Down Expand Up @@ -398,7 +398,7 @@ static int get_ecs_cluster_metadata(struct flb_filter_ecs *ctx)
c = flb_http_client(u_conn, FLB_HTTP_GET,
FLB_ECS_FILTER_CLUSTER_PATH,
NULL, 0,
FLB_ECS_FILTER_HOST, FLB_ECS_FILTER_PORT,
ctx->ecs_host, ctx->ecs_port,
NULL, 0);
flb_http_buffer_size(c, 0); /* 0 means unlimited */

Expand Down Expand Up @@ -998,7 +998,7 @@ static int get_task_metadata(struct flb_filter_ecs *ctx, char* short_id)
c = flb_http_client(u_conn, FLB_HTTP_GET,
http_path,
NULL, 0,
FLB_ECS_FILTER_HOST, FLB_ECS_FILTER_PORT,
ctx->ecs_host, ctx->ecs_port,
NULL, 0);
flb_http_buffer_size(c, 0); /* 0 means unlimited */

Expand Down Expand Up @@ -1600,6 +1600,20 @@ static struct flb_config_map config_map[] = {
"have been stopped."
},

{
FLB_CONFIG_MAP_STR, "ecs_meta_host", FLB_ECS_FILTER_HOST,
0, FLB_TRUE, offsetof(struct flb_filter_ecs, ecs_host),
"The host name at which the ECS Agent Introspection endpoint is reachable. "
"Defaults to 127.0.0.1"
},

{
FLB_CONFIG_MAP_INT, "ecs_meta_port", FLB_ECS_FILTER_PORT,
0, FLB_TRUE, offsetof(struct flb_filter_ecs, ecs_port),
"The port at which the ECS Agent Introspection endpoint is reachable. "
"Defaults to 51678"
},

{0}
};

Expand Down
5 changes: 4 additions & 1 deletion plugins/filter_ecs/ecs.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#include <fluent-bit/record_accessor/flb_ra_parser.h>

#define FLB_ECS_FILTER_HOST "127.0.0.1"
#define FLB_ECS_FILTER_PORT 51678
#define FLB_ECS_FILTER_PORT "51678"
#define FLB_ECS_FILTER_CLUSTER_PATH "/v1/metadata"
#define FLB_ECS_FILTER_TASK_PATH_FORMAT "/v1/tasks?dockerid=%s"

Expand Down Expand Up @@ -105,6 +105,9 @@ struct flb_filter_ecs {
struct mk_list metadata_keys;
int metadata_keys_len;

flb_sds_t ecs_host;
int ecs_port;

/*
* This field is used when we build new container metadata objects
*/
Expand Down

0 comments on commit ddcd65b

Please sign in to comment.