Skip to content
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

Added option to replace dots in keys with underscores #13

Closed
wants to merge 2 commits into from
Closed

Added option to replace dots in keys with underscores #13

wants to merge 2 commits into from

Conversation

MarcusNoble
Copy link
Contributor

Issue #, if available: N/A

Description of changes:
Add an option to replace dots (.) within keys with underscores (_) to help avoid type clashes in Elasticsearch and similar.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

case map[interface{}]interface{}:
v = replaceDots(vt)
// Ensure duplicated keys are merged rather than replaced
if _, ok := newObj[k]; ok {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checking for duplicated keys needs to happen in the first call to replaceDots, not just in the recursive case

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interestingly, the C code for the ES version of this option is very simple and does not check for duplicates:

https://github.com/fluent/fluent-bit/blob/master/plugins/out_es/es.c#L90

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checking for duplicated keys is safer; I like having that check. However, I think it should be able to be done in place without allocating a new map.

I believe this should be safe in Go: https://stackoverflow.com/questions/23229975/is-it-safe-to-remove-selected-keys-from-map-within-a-range-loop

kinesis/kinesis.go Outdated Show resolved Hide resolved
Copy link
Contributor

@PettitWesley PettitWesley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MarcusNoble the replaceDots function needs to be changed a bit. Post in the PR and we can discuss how to fix it. I'm torn on the duplicate key issue. It seems safe to cover it, but on the other hand Fluent Bit ES doesn't and as far as we know it's never caused anyone any trouble.

Also removed dedeuplication code as this is proving more troublesome and out of scope of this task.
@MarcusNoble
Copy link
Contributor Author

Thanks for your review @PettitWesley.

I've removed the re-assignment so now it just does a mutation in place.

I've also removed the deduplication code as that needs some more thought. I'm going to open an issue to discuss it and provide the scenario that I'm hitting a problem.

@PettitWesley
Copy link
Contributor

@MarcusNoble I lean towards saying this should be a feature in Fluent Bit core; see here: fluent/fluent-bit#1305 (comment)

@nsvijay04b1
Copy link

i am one of those who are waiting for this merge so i can use it :-)

@nsvijay04b1
Copy link

hi .. Any progress please? awaiting fix as i have the same problem.

@nsvijay04b1
Copy link

Release v2.7.0 also missed this feature. Hope this will be part of Release v2.8.0

@hossain-rayhan
Copy link
Contributor

Hi @nsvijay04b1 , as @PettitWesley mentioned, this might a good option to put into the fluent-bit core. So, I am not sure if we are planning to implement it separately for each of our plugins.

Check this for update: fluent/fluent-bit#1305 (comment)

@PettitWesley
Copy link
Contributor

We're now thinking of working on this and including it in an upcoming release

@PettitWesley
Copy link
Contributor

@MarcusNoble @nsvijay04b1 We have take this back up in #79. Marcus's original commits are preserved.

Apologies for taking so long to deliberate on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants