-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Fleet] add ilm policy per data stream #85492
[Fleet] add ilm policy per data stream #85492
Conversation
@@ -30,6 +30,7 @@ import { deleteKibanaSavedObjectsAssets } from './remove'; | |||
import { installTransform } from '../elasticsearch/transform/install'; | |||
import { createInstallation, saveKibanaAssetsRefs, updateVersion } from './install'; | |||
import { saveArchiveEntries } from '../archive/save_to_es'; | |||
import { installIlmForDataStream } from '../elasticsearch/datastream_ilm/install'; |
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.
is this file missing from the commit?
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.
yes, updated
@@ -24,6 +24,7 @@ import { packagePolicyService, appContextService } from '../..'; | |||
import { splitPkgKey } from '../registry'; | |||
import { deletePackageCache } from '../archive'; | |||
import { removeArchiveEntries } from '../archive/save_to_es'; | |||
import { deleteIlms } from '../elasticsearch/datastream_ilm/remove'; |
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.
same here, is this file missing from the commit?
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.
yes, updated
Again, would have preferred to have 2 separate PR's for ilm policy and hidden to keep the features separate. |
What is the name of the ILM policies that are loaded? |
…tion-ilm-policy-and-hidden
Currently, the one included in the Screenshot from running the code + package locally: There's another example in a couple of the tests. I don't have a strong opinion on the naming, happy to change it. cc/ @tsg |
Pinging @elastic/ingest-management (Team:Ingest Management) |
@kevinlog On the naming, I would assume the ilm policy has a similar / same name as the data stream(s) it applies to? |
@elasticmachine merge upstream |
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.
Happy with the code as long as @ruflin is happy with the implemented functionality.
The names are similar, however we can change it so that they are the same. Index template: current ILM Policy name: Let me know if the above looks good. Happy to make adjustments |
I think from a user perspective it would be easier if the name would be indentical so |
I tend to agree with you, however the existing |
@kevinlog Are these ILM policies related to Packages / New Indexing Strategy? |
yes, these ILM policies will be shipped with the package, here's an example with the Endpoint package: elastic/endpoint-package#118 |
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.
Some questions about the regex patterns.
} | ||
|
||
const isDataStreamIlm = (path: string) => { | ||
return new RegExp('(?<package>.*)/data_stream/(?<dataset>.*)/elasticsearch/ilm/*.*').test(path); |
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.
nit: Do we need the ?<package>
or the ?<dataset>
? I believe those are so we can extract out those specific fields.
Do we need to escape all the /
?
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions
Similarly, if you're writing a regular expression literal and need to match a slash ("/"), you need to escape that (otherwise, it terminates the pattern). For instance, to search for the string "/example/" followed by one or more alphabetic characters, you'd use //example/[a-z]+/i—the backslashes before each slash make them literal.
I was playing around with it here:
https://regex101.com/r/GLnjJN/1
https://regex101.com/r/GLnjJN/2
I think we might need one of these:
(?<package>.*)\/data_stream\/(?<dataset>.*)\/elasticsearch\/ilm\/.*
.*\/data_stream\/.*\/elasticsearch\/ilm\/.*
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.
Do we need? No, probably not. (?<package>.*)
vs .*
is adding a named capture group.
It doesn't look like we access or use the groups, so that's unnecessary. Adding the label, though, somewhat acts as in-regex-documentation of what we're looking at. I do like that.
We do not need to escape the slashes here because it is a new Regexp
constructor using a string. Not using slash-literals.
}; | ||
|
||
const isDatasetIlm = (path: string, datasetName: string) => { | ||
return new RegExp(`(?<package>.*)/data_stream\\/${datasetName}/elasticsearch/ilm/*.*`).test(path); |
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.
Same questions about groups and escaping as above
…tion-ilm-policy-and-hidden
…tion-ilm-policy-and-hidden
💚 Build SucceededMetrics [docs]Async chunks
Distributable file count
Page load bundle
History
To update your PR or re-run it, just comment with: |
Co-authored-by: kevinlog <kevin.logan@elastic.co> Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: kevinlog <kevin.logan@elastic.co> Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: nnamdifrankie <56440728+nnamdifrankie@users.noreply.github.com> Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Summary
This PR adds the installation flow for
ilm_policy
perdata_stream
. This feature will be used to define a customilm_policy
for adata_stream
that will override the one taken based ontype
.Example package PR that will use this field: elastic/endpoint-package#118
A screenshot showing the ILM policy that's installed from the Endpoint package.

Here's the Index Template showing that it's

lifecycle
points to the installed ILM policyChecklist
Delete any items that are not applicable to this PR.