-
Notifications
You must be signed in to change notification settings - Fork 528
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
model: sanitize/de-dot keys for labels, custom, and marks #4465
Conversation
Replace reserved label key characters with '_', alleviating clients from having to do this. Also, optimise how we merge global and event-specific labels. Instead of adding all global labels and then using utility.DeepUpdate, de-dot the label keys first and range over the two maps to create a second map. Because the labels keys cannot have dots, we do not need to deep merge.
Sanitize the keys of "custom" context using the same logic applied to labels. Also, drop the model.Custom type and just use common.MapStr. This eliminates some unnecessary pointer indirection.
💚 Build Succeeded
Expand to view the summary
Build stats
Test stats 🧪
Steps errors
Expand to view the steps failures
|
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.
Great improvement!
(just realized the PR is still in draft, looked ready to me ;) )
* model: sanitize label keys Replace reserved label key characters with '_', alleviating clients from having to do this. Also, optimise how we merge global and event-specific labels. Instead of adding all global labels and then using utility.DeepUpdate, de-dot the label keys first and range over the two maps to create a second map. Because the labels keys cannot have dots, we do not need to deep merge. * model: sanitize "custom" attribute keys Sanitize the keys of "custom" context using the same logic applied to labels. Also, drop the model.Custom type and just use common.MapStr. This eliminates some unnecessary pointer indirection. * model: sanitize "marks" keys * model/modeldecoder: drop label key regexp rules * Add changelog entry
) * model: sanitize label keys Replace reserved label key characters with '_', alleviating clients from having to do this. Also, optimise how we merge global and event-specific labels. Instead of adding all global labels and then using utility.DeepUpdate, de-dot the label keys first and range over the two maps to create a second map. Because the labels keys cannot have dots, we do not need to deep merge. * model: sanitize "custom" attribute keys Sanitize the keys of "custom" context using the same logic applied to labels. Also, drop the model.Custom type and just use common.MapStr. This eliminates some unnecessary pointer indirection. * model: sanitize "marks" keys * model/modeldecoder: drop label key regexp rules * Add changelog entry
Tested with BC1 - sent key |
Motivation/summary
Sanitize/de-dot keys for labels, custom, and marks, in the server when transforming to documents. Reserved characters (
*
,.
, and"
) will be replaced with_
.Remove the validation from the modeldecoder types, as agents will no longer be required to sanitize the keys. This changes various
patternProperties
toadditionalProperties
in the generated JSON Schema.Finally, remove the
model.Labels
andmodels.Custom
types and usecommon.MapStr
directly (and without an extra level of pointer indirection). Use the knowledge that label keys cannot have dots to avoid the need for deep updates, replacing the relatively expensiveutility.DeepUpdate
calls with shallow map merging.Checklist
I have considered changes for:
- [ ] documentation- [ ] logging (add log lines, choose appropriate log selector, etc.)- [ ] metrics and monitoring (create issue for Kibana team to add metrics to visualizations, e.g. Kibana#44001)- [ ] telemetry- [ ] Elasticsearch Service (https://cloud.elastic.co)- [ ] Elastic Cloud Enterprise (https://www.elastic.co/products/ece)- [ ] Elastic Cloud on Kubernetes (https://www.elastic.co/elastic-cloud-kubernetes)How to test these changes
make test
Related issues
Closes #4225