-
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
loki_out: add stuctured_metadata_map_keys #9530
base: master
Are you sure you want to change the base?
loki_out: add stuctured_metadata_map_keys #9530
Conversation
7f1db76
to
a9cdcad
Compare
a9cdcad
to
e9fee7d
Compare
8387b9a
to
99caf96
Compare
* Adds stuctured_metadata_map_keys config to dynamically populate stuctured_metadata from a map * Add docker-compose to test loki backend Signed-off-by: Greg Eales <[email protected]>
99caf96
to
ca46caf
Compare
if (kv->ra_key != NULL && kv->ra_val == NULL) { | ||
|
||
/* try to get the value for the record accessor */ | ||
if (flb_ra_get_kv_pair(kv->ra_key, *map, &start_key, &out_key, &out_val) |
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.
flb_ra_* API do not use msgpack-c return codes like MSGPACK_UNPACK_CONTINUE
, need to check the return values and adjust it
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'm a bit confused as to the meaning of the return code from flb_ra_get_kv_pair
. I see from the source it is commented that this should
Returns FLB_TRUE if the pattern matched a kv pair, otherwise it returns FLB_FALSE
Where FLB_TRUE
is 1
and FLB_FALSE
is 0
However, actually reading the code, if this doesn't hit the FLB_FALSE
code path, it actually just returns whatever the following call to flb_ra_key_value_get
returns, and function flb_ra_key_value_get
actually seems to return 0
for okay, and -1
for not okay..
It looks like we are getting return codes as follows:
- Valid RA, normal happy path - this will delegate to
flb_ra_key_value_get
and return0
- Syntactically invalid RA key, such as
$$
- this will returnFLB_FALSE
(also0
) viaget_ra_parser
.- This PR then proceeds assuming things are okay, then to check
out_val
and finally logNo valid map data found for key $
(test caseflb_test_structured_metadata_map_invalid_ra_key
)
- This PR then proceeds assuming things are okay, then to check
- Syntactically valid RA key, such as
$missing_map
which doesn't reference anything - this will delegate toflb_ra_key_value_get
and return-1
(test casestructured_metadata_map_single_missing_map
)
It seems like the main option here to to test for not equal to -1
, and then check out_val
.
Otherwise, we have to change how flb_ra_get_kv_pair
works to agree with its comment, which I assume would break some important things elsewhere?
@@ -91,6 +92,7 @@ struct flb_loki { | |||
struct flb_record_accessor *ra_k8s; /* kubernetes record accessor */ | |||
struct mk_list labels_list; /* list of flb_loki_kv nodes */ | |||
struct mk_list structured_metadata_list; /* list of flb_loki_kv nodes */ | |||
struct mk_list structured_metadata_map_keys_list; /* list of flb_loki_kv nodes */ |
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.
Do the comment start positions need to be aligned, or is it okay for this one to stick out further?
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'd say line them up if you can
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.
This pushed a couple of the lines over 90 characters long.
I could align the righthand side instead, like this?
int ra_used; /* number of record accessor label keys */
struct flb_record_accessor *ra_k8s; /* kubernetes record accessor */
struct mk_list labels_list; /* list of flb_loki_kv nodes */
struct mk_list structured_metadata_list; /* list of flb_loki_kv nodes */
struct mk_list structured_metadata_map_keys_list; /* list of flb_loki_kv nodes */
struct mk_list remove_keys_derived; /* remove_keys with label RAs */
struct flb_mp_accessor *remove_mpa; /* remove_keys multi-pattern accessor */
struct flb_record_accessor *ra_tenant_id_key; /* dynamic tenant id key */
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.
seems reasonable to me
Signed-off-by: Greg Eales <[email protected]>
Resolves #9463
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:
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#1527
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.