Skip to content

Commit 8b5e517

Browse files
cosmo0920edsiper
authored andcommitted
in_splunk: Extract x-forwarded-for as a remote_addr record
Signed-off-by: Hiroshi Hatake <hiroshi@chronosphere.io>
1 parent 09e3780 commit 8b5e517

5 files changed

Lines changed: 273 additions & 26 deletions

File tree

plugins/in_splunk/splunk.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,16 @@ static struct flb_config_map config_map[] = {
261261
0, FLB_TRUE, offsetof(struct flb_splunk, tag_key),
262262
""
263263
},
264+
{
265+
FLB_CONFIG_MAP_BOOL, "add_remote_addr", "false",
266+
0, FLB_TRUE, offsetof(struct flb_splunk, add_remote_addr),
267+
"Inject a remote address using the X-Forwarded-For header or connection address"
268+
},
269+
{
270+
FLB_CONFIG_MAP_STR, "remote_addr_key", "remote_addr",
271+
0, FLB_TRUE, offsetof(struct flb_splunk, remote_addr_key),
272+
"Set a record key for storing the remote address"
273+
},
264274

265275

266276
/* EOF */

plugins/in_splunk/splunk.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ struct flb_splunk {
5454
size_t ingested_auth_header_len;
5555
int store_token_in_metadata;
5656
flb_sds_t store_token_key;
57+
int add_remote_addr;
58+
flb_sds_t remote_addr_key;
5759

5860
struct flb_log_event_encoder log_encoder;
5961

@@ -71,6 +73,10 @@ struct flb_splunk {
7173
struct flb_downstream *downstream; /* Client manager */
7274
struct mk_list connections; /* linked list of connections */
7375
struct mk_server *server;
76+
77+
/* Remote address */
78+
flb_sds_t current_remote_addr;
79+
size_t current_remote_addr_len;
7480
};
7581

7682

plugins/in_splunk/splunk_config.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ struct flb_splunk *splunk_config_create(struct flb_input_instance *ins)
146146

147147
ctx->ingested_auth_header = NULL;
148148

149+
ctx->current_remote_addr = NULL;
150+
ctx->current_remote_addr_len = 0;
151+
149152
ret = setup_hec_tokens(ctx);
150153
if (ret != 0) {
151154
splunk_config_destroy(ctx);

0 commit comments

Comments
 (0)