-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
in_splunk: Add switch for storing in metadata or records and handle multiple tokens on in splunk #8900
Conversation
Note that this PR is built on top of #8883 commit. Because raw endpoint unit testing should fail without that PR's change. |
c08585c
to
4c2493e
Compare
FYI: #8883 has been merged. |
Signed-off-by: Hiroshi Hatake <[email protected]>
In metadata case, we didn't support for formatting metadata in out_lib. So, we didn't write down the tests for them. Signed-off-by: Hiroshi Hatake <[email protected]>
Signed-off-by: Hiroshi Hatake <[email protected]>
4c2493e
to
8e004d4
Compare
plugins/in_splunk/splunk_config.c
Outdated
/* Link to parent list */ | ||
mk_list_add(&splunk_token->_head, &ctx->auth_tokens); | ||
|
||
token = strtok(NULL, ","); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we avoid using strtok(2) function since it modifies the original buffer.
plugins/in_splunk/splunk.c
Outdated
@@ -236,6 +236,18 @@ static struct flb_config_map config_map[] = { | |||
"Set valid Splunk HEC tokens for the requests" | |||
}, | |||
|
|||
{ | |||
FLB_CONFIG_MAP_BOOL, "store_token_to_metadata", "true", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest a little change to `store_token_in_metadata"
plugins/in_splunk/splunk_config.c
Outdated
if (tmp) { | ||
tmp_tokens = flb_strdup(tmp); | ||
|
||
token = strtok(tmp_tokens, ","); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
avoid strtok(). you can use flb_utls_split instead
plugins/in_splunk/splunk_config.c
Outdated
|
||
tmp = flb_input_get_property("splunk_token", ctx->ins); | ||
if (tmp) { | ||
tmp_tokens = flb_strdup(tmp); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
validate the return value
plugins/in_splunk/splunk_prot.c
Outdated
} | ||
else { | ||
return SPLUNK_AUTH_UNAUTHORIZED; | ||
mk_list_foreach_safe(head, tmp, &ctx->auth_tokens) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if the list entry won't be deleted, you can use mk_list_foreach()
, the _safe_
version aims to provide an extra pointer to deal with cases where entries/nodes are being removed.
Signed-off-by: Hiroshi Hatake <[email protected]>
Signed-off-by: Hiroshi Hatake <[email protected]>
Signed-off-by: Hiroshi Hatake <[email protected]>
Signed-off-by: Hiroshi Hatake <[email protected]>
In this enhancement, I implemented capabilities for storing metadata into records and handle multiple HEC tokens in configuration.
Enter
[N/A]
in the box, if an item is not applicable to your change.Testing
Before we can approve your change; please submit the following in a comment:
For injecting HEC tokens into records case
For injecting HEC tokens into metadata case (default behavior)
For injecting HEC tokens into records case
For injecting HEC tokens into metadata case (default behavior)
For injecting HEC tokens into records case
For injecting HEC tokens into metadata case (default behavior)
If this is a change to packaging of containers or native binaries then please confirm it works for all targets.
ok-package-test
label to test for all targets (requires maintainer to do).Documentation
fluent/fluent-bit-docs#1387
Backporting
Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.