-
Notifications
You must be signed in to change notification settings - Fork 154
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
Validate and sanitization of dataset and namespace field #3946
Comments
Pinging @elastic/elastic-agent (Team:Elastic-Agent) |
Users aren't going to be naming their pods while keeping the data stream naming convention in mind, so this is unfortunate. I wonder how common this is, since Similar to #3934 (comment) we could use feature flags to deal with the breaking nature of this problem: elastic-agent/elastic-agent.reference.yml Lines 194 to 197 in a76f4ba
This feels more like something that we really should be doing by default though if it is going to cause problems interacting with other parts of the stack. So perhaps in this case we default to sanitization with the option to disable it. The other option is for things like the reroute processor to just deal with the fact that not everything is going to adhere perfectly to our conventions since this is already out there (and you can of course write to ES without using Elastic agent). Given |
Taking what Josh has above, the data stream naming scheme would basically be extended with these 2 rules:
What I think this all comes back to is that whenever the data stream naming scheme is used, the |
I believe this is the issue you're looking for: |
If we want to keep existing data stream naming I think we could do the following.
That should catch static config errors (fleet check) and dynamic config errors (variable expansion). |
We should probably be consistent with the reroute processor and "encode" the
|
@ycombinator +1. FWIW APM Server and MIS has logic to sanitise data stream names, where we also use "_" as the replacement. May be worth copying for consistency: https://github.com/elastic/apm-data/blob/c5848755c65e676325c80780c24a14a941e5f176/model/modelprocessor/datastream.go#L197C6-L209 |
consistency is important, but I'd like to point out that this is a sub-optimal way to "sanitize". You can't go backwards from this, and you could have accidental name collisions. For example:
depending on variable substitution you could end up writing very different things to the same data_stream, and you will be making it harder for users to determine where the data_stream name came from. |
The fields for the data stream naming scheme have rules around what chars are valid. One of the goals it so make sure a pattern like
logs-*-*
always applies to the right dataset and namespace. Recently, some configs in helm charts were found that look as following:This is a valid configuration. But as it turns out, the
name
above can be for examplefoo-bar
. This means the value fordata_stream.dataset
becomesfoo-bar
. But for processors like reroute that match on the data stream name with the patternlogs-*-*
,foo
is assumed to be the dataset,bar
and everything afterwards the namespace.In the context of the reroute processor, these fields are sanitized. Unfortunately Elastic Agent (Beats) doesn't do this today but should.
Unfortunately turning on sanitization directly could be considered a breaking change as now suddenly
foo-bar
would becomefoo_bar
. At the same time, it is important for the system to function that the values are always the same.Some ideas for migration users is to at least start logging errors (once) and inform users if this happens and later turn it on by default (with an opt out option).
@axw This might also be relevant in the context of ingesting otel data.
The text was updated successfully, but these errors were encountered: