-
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
libbeat: support explicit dynamic templates #25422
Conversation
Add the field `DynamicTemplate bool` to `mapping.Field`, indicating that the field represents an explicitly named dynamic template. Update Elasticsearch template generation to create dynamic templates from these fields when the target Elasticsearch is 7.13.0+, when support for these dynamic templates was added and the requirement of match criteria was dropped. Such dynamic templates are suitable only for use in dynamic_templates bulk request parameters and in ingest pipelines; they will have no path or type matching criteria.
Pinging @elastic/agent (Team:Agent) |
💚 Build Succeeded
Expand to view the summary
Build stats
Test stats 🧪
Trends 🧪💚 Flaky test reportTests succeeded. Expand to view the summary
Test stats 🧪
|
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.
Thank you! 🚀 left a few comments
Do we expect differences on these dynamic maps between beats? or custom mappings of this kind per integration? If not, perhaps we could hardcode and always install the dynamic mapping for histograms and summaries (and other types we could need in the future), so we are sure that all collectors use the same approach to store these types of metrics. And we don't add more options to fields definition ymls. |
I have opened this conversation as a follow up of our latests metrics discussion: elastic/elasticsearch#72536. I think it's ok to keep going with these PRs as we work on getting better alignment |
I was thinking in the option of including the default dynamic mapping for histograms and summaries in the base index template that libbeat generates, the same way as the |
@jsoriano I think we should standardise, but I'm not sure about forcing it on every beat like that. As @exekias points out in elastic/elasticsearch#72536, we'll end up with many combinations for a completely general solution. So I think I'd rather wait for that conversation to play out before trying to standardise. You make a good point about not adding yet more options to templateConfig.DynamicTemplates = map[string]mapping.Field{
"histogram_counter_nanos": mapping.Field{Type: "histogram", MetricType: "counter", Unit: "nanos"},
} It would not be possible to define these in WDYT? |
This pull request is now in conflicts. Could you fix it? 🙏
|
I like this option, this would be similar to what I was thinking of always adding these templates, but without forcing this to every beat. If at some point we find a general solution we can implement it the same way for every beat.
Are we installing now the If we are going to wait to confirm a general solution maybe the approach of using |
I can go either way. Speaking only for APM, I don't think it'll be a problem for us to change from one dynamic template name to another as we'll be doing the mapping in an ingest pipeline. Because the template and ingest pipeline are installed together we'll be able to change them at the same time. @exekias @ruflin do you have an opinion on doing this in code vs. |
I did not dig into the full conversation but for the fields.yml support, I think that is preferrable. Will these templates also be specified by packages in the future? If yes, I think fields.yml is our way to go and we need to bring support for it also to Fleet. |
I think it's ok to move forward with this. We only have a few entry points where dynamic templates will be used for now, so things should be easy to maintain. Let's not wait on the other conversation as it may take some time to align and get the features we need. Also an eventual update on namings will be transparent for the user, as we will be updating our code / mappings, but not the UX. @axw something that would be interesting is to follow up with adding this to the package spec and Kibana so we can have dynamic templates in packages too. Do you plan to open issues for that? |
Will do 👍 |
/test |
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.
Ok, let's go on with this approach, thanks!
/test |
/test |
* libbeat: support explicit dynamic templates Add the field `DynamicTemplate bool` to `mapping.Field`, indicating that the field represents an explicitly named dynamic template. Update Elasticsearch template generation to create dynamic templates from these fields when the target Elasticsearch is 7.13.0+, when support for these dynamic templates was added and the requirement of match criteria was dropped. Such dynamic templates are suitable only for use in dynamic_templates bulk request parameters and in ingest pipelines; they will have no path or type matching criteria. * Update changelog * Revert signature change * Disallow dynamic_template with object_type_params * Add a constant for min version * libbeat/mapping: fix field validation (cherry picked from commit 7a49ca1)
* libbeat: support explicit dynamic templates Add the field `DynamicTemplate bool` to `mapping.Field`, indicating that the field represents an explicitly named dynamic template. Update Elasticsearch template generation to create dynamic templates from these fields when the target Elasticsearch is 7.13.0+, when support for these dynamic templates was added and the requirement of match criteria was dropped. Such dynamic templates are suitable only for use in dynamic_templates bulk request parameters and in ingest pipelines; they will have no path or type matching criteria. * Update changelog * Revert signature change * Disallow dynamic_template with object_type_params * Add a constant for min version * libbeat/mapping: fix field validation (cherry picked from commit 7a49ca1) Co-authored-by: Andrew Wilkins <[email protected]>
What does this PR do?
Add the field
DynamicTemplate bool
tomapping.Field
, indicating that the field represents an explicitly named dynamic template. Update Elasticsearch template generation to create dynamic templates from these fields when the target Elasticsearch is 7.13.0+, when support for these dynamic templates was added and the requirement of match criteria was dropped.Such dynamic templates are suitable only for use in dynamic_templates bulk request parameters and in ingest pipelines; they will have no path or type matching criteria.
Why is it important?
In APM we would like to be able to dynamically map histogram and summary metrics: elastic/apm-server#3195. To do this we will use the new (7.13.0+) feature of Elasticsearch where dynamic_templates can be specified by name at ingest time, to have explicit control over how dynamic mapping takes place. We will need to predefine dynamic templates for each combination of field type and unit that we support in dynamic metrics.
Checklist
- [ ] I have made corresponding changes to the documentation- [ ] I have made corresponding change to the default configuration filesCHANGELOG.next.asciidoc
orCHANGELOG-developer.next.asciidoc
.