-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Fieldref StringInterpolation and Fixnum/Float values #5114
Comments
@colinsurprenant @arizonawayfarer I was a bit curious and I did a bit more investigation, this is really a regression but not from the version we were thinking, it was in the 1.5.X series when I refactored the string interpolation. 1.4.2 was returning a string. So for me the correct behavior is we should always return a string, so I dont think we should revert that change. WDYT? |
From a performance standpoint, wouldn't forcing users to explicitly convert strings back to their original datatype add unnecessary processing overhead? Why not just keep the original datatype, unless explicitly converted to a string using a mutate block?? Converting a float to a string and then back to a float seems silly, in my opinion. Although, I have to admit that I'm getting confused again. I don't know what the goal of converting everything to a string is/was. |
I think that from config standpoint we should support both the forced-string and original-value-type. The |
@colinsurprenant That makes sense, and I totally agree. As to how the field references are made.. I feel like removing %{} from the reference would make things easier to read, and people might appreciate the byte savings when transferring large amounts of configs? Also, why have superfluous decoration if it's not needed? Just makes things simpler, yeah? |
I am +1 for removing the need to recast the value itself. So the for the record.
|
I think, if I understood @colinsurprenant it would look more like this:
|
Probably makes sense to keep the curly braces, I feel like parsing that would be horrible. |
yes, we should keep the string interpolation syntax as-is, but with the quotes, as we have today Recap: In your previous example @ph I'd just add quotes to And @arizonawayfarer I wouldn't support quoted fieldref like |
@colinsurprenant oops, yup just updated my comment with the quotes. Supporting To make it simple, instead of sending a Concerning the 2.3.X issue, do we agree that the keeping the original type was a bug and we should not fix it? |
I'm on the fence but I think that since from 1.5 to 2.2 we were returning the original type using |
my vote for the following plan: for 2.3: for 5.0: To do a field reference without a string, either |
I think it is very confusing for our end users who are not developers to understand using In 2.3.2, we should go back to 2.x behaviour to not break compatibility. And stick to the same strategy in 5.0 as well. |
I like what @arizonawayfarer proposed:
|
@suyograo IMO the principle of least surprise is to avoid auto-magic type conversions which will, yes, require users to learn on the usage of using quotes or not. To make things simpler in the future (5.x) I think the string interpolation template syntax Now to get the original type I think we should only rely on using the current fieldref syntax and support Using this strategy makes it pretty consistent: use |
What's the scope of users impacted by the fixed bug (which can be viewed as a feature break)? For the 2.3 branch:
My instinct is to call it what it is, a bug, and leave it "fixed" - but that conclusion ignores one of my favorite lines "If a user has a bad time, it's a bug" and that I greatly care about upgrade experience. @colinsurprenant proposed that we revert the "bug fix" for 2.3 only because users upgrading to 2.3 could have an upsetting experience. I agree that upgrade experience matters. Regardless of what we do for 2.3, my understanding from this report is that some folks want a way to copy a field, so we should make that copying possible. |
Perhaps there should be a copy_field configuration option for filters? I apologize, as this is probably going to fall way out of the scope of this discussion. I have a lot of things floating around in my head. When considering the geoip filter, you currently have to do this in order to use the heatmap visualization in kibana:
Knowing what I know now, that this should never have worked, seems a little silly to me. As a user, I never realized string interpolation was happening until I started investigating this issue. I assumed that data types were being preserved along the way, and that if I really wanted those to be strings, I would have needed to use a mutate block. I can't recall seeing anything about the add_field option automatically converting stuff to strings. Although, with the deeper understanding I have now it makes total sense. However, in the context of the geoip filter it didn't click for me. I would totally be behind something like this:
The way I'm kind of imagining how this would work, add_field always converts to string, and copy_field retains datatypes? Something like that. I don't know, there are literally 9000 ways to approach this hehe I also think efforts should be made to reduce config bloat, having to explicitly mutate the fields to their original datatype would make an already big configuration file even bigger. Again, knowing what I know now, this is what would have been expected, and it just doesn't seem right.
I would imagine that for larger arrays, that would be an expensive operation. |
Geoip filter provides a
|
Oh wow, I must have been looking at some old docs when I started mucking with it. I'm an idiot hehe |
Hi there and sorry to barge in. I came across this conversation cause I spent some time figuring out why my For plugin authors, what is the current way to get a primitive type when using From the source it seems the value is always returned as string. https://www.rubydoc.info/gems/logstash-event/LogStash/Event:sprintf Do I read it right? Edit: Decided to use |
In 2.3 we have introduced a change to deal with reference values when applying string interpolation for fieldref (see #4592). This change broke backward compatibility with existing configuration that were using the
add_field
function to copyFixnum
andFloat
values (#4961) into new fields.Before 2.3, the string interpolation wasn't doing pessimistic conversion of the value into a string and was keeping the original type.
Example:
Since we are explicitly using quoted string to use the fieldref reference, I think its fair to expect it to behave like the Kernel.sprintf method and always return a string. (The underlying method is actually called sprintf)
I think for 5.0 we should make
sprintf
always return a string and this is already the case in the current Java Event implementation. The downside of this, people will actually need to manually convert the value using the mutate filter if they really need a specific type.In #4961 @colinsurprenant also suggested to support non-quoted string to keep the original value, this could be something to investigate.
The text was updated successfully, but these errors were encountered: