-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Parameterizing Painless script #9821
Comments
I don't fully understand the example in the docs:
In this case the multiplier is never going to change, it is always going to be |
@jsoriano Seems like scripts has |
@kaiyan-sheng yes, this is what I don't understand, why is |
I think we need @jakelandis to comment on this one. I'm also curious why we need to parametrise constants. |
You don't need to parameterize constants for ingest node scripts (unless you are constantly changing the pipeline, which you don't want to do for other reasons). You may want to parameterize if your testing uses randomized constants but not needed for production code. Parameterize the arguments is imo and arguably a best practice for consistency with update scripts.
The keyword in there is "different multipliers". The script's cache keys are basically by the script itself as a string, so if that multiplier keeps changing, the string changes and it is cache miss. This maybe a concern for update/upsert scripts but not really for ingest node scripts. The recent increase in circuit breaker exceptions is likely due to adding support for more template'd fields (starting in '6.4') and the 'if' condition in '6.5'. Once elastic/elasticsearch#37120 is fixed, it should help considerably with the circuit breaker exceptions. (Also, somewhere, can't find it now, I provided a less concrete answer to a similar question... sorry about that. I have looked at this abit more since and ^^ is the correct answer). |
@jakelandis thanks for the explanation. Let's see if I understand it now... So, parametrization is only needed if the script is used with different multipliers. Then, following with the example, recompilations are triggered if there are scripts like these ones:
And
But not if they are defined like:
And
This makes sense. But if the script is always used as But then I don't understand why we need to parametrize literals that are never different, like in these cases. Or maybe we don't need to parametrize so many things? To check recompilations, is there some metric exposing the count of compilations done? |
@jsoriano But the real issue here is that all options that can be templated currently trigger a compilation, even if there's no Mustache interpolation in the value. This is what elastic/elasticsearch#37120 will address. The reason we're seeing this problem on and off is likely that we're hovering close to that limit. Sometimes we trip it up, sometimes we don't. Our attempts at parameterizing just mix things up, they don't really fix anything. But if you think about all of the processor options that support templating where we don't actually do templating most of the time... I think ES issue will be the game changer that brings everything back to a sane level. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
The fix for elastic/elasticsearch#37120 was already merged. I guess we can close this then? |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Filebeat modules use ingest pipelines with scripts inside. Parameterised scripts are preferred and more efficent as they only have to be compiled ones (see https://www.elastic.co/guide/en/elasticsearch/reference/6.x/modules-scripting-using.html#prefer-params). To have efficient pipelines in all modules each pipeline should be reviewed to assure we only use parameterised scripts.
Related:
The text was updated successfully, but these errors were encountered: