-
Notifications
You must be signed in to change notification settings - Fork 25.7k
[ML] Manage AD results indices #136065
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
[ML] Manage AD results indices #136065
Changes from 49 commits
9ff0b94
78d0d8e
0ec99b6
8405ff3
d10d09d
dfb1939
ffc2842
9863169
8f17540
d60a811
2729a86
c5f58e1
7b6caf0
52ab642
66d7268
f9296fd
07ddbaa
e7eb106
cb85a49
123c8cb
1a5d0da
c54a354
80b1b71
84ad33d
2a66d40
83e7e2b
e9c0c2c
0b6b79a
97106a1
468f712
96cecaf
63f97c5
8050133
c320ccc
8e22944
644c57f
0532c8b
5465b24
42e63c9
5e7a9da
16cb2d1
7abf680
b5513a2
29faf9e
77ab9df
8bf9e6f
f9f6881
cd9b467
fe2c12d
326eedd
21ea400
f90e4b8
5d06353
988eeeb
000e1b3
cc157c8
58540ae
74d92ae
0c2fbe9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| pr: 136065 | ||
| summary: Manage ad results indices | ||
| area: Machine Learning | ||
| type: enhancement | ||
| issues: [] | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -86,6 +86,9 @@ $$$xpack.ml.max_open_jobs$$$ | |||||
| `xpack.ml.nightly_maintenance_requests_per_second` | ||||||
| : ([Dynamic](docs-content://deploy-manage/stack-settings.md#dynamic-cluster-setting)) The rate at which the nightly maintenance task deletes expired model snapshots and results. The setting is a proxy to the [`requests_per_second`](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-delete-by-query) parameter used in the delete by query requests and controls throttling. When the {{operator-feature}} is enabled, this setting can be updated only by operator users. Valid values must be greater than `0.0` or equal to `-1.0`, where `-1.0` means a default value is used. Defaults to `-1.0` | ||||||
|
|
||||||
| `xpack.ml.nightly_maintenance_rollover_max_size` | ||||||
|
||||||
| `xpack.ml.nightly_maintenance_rollover_max_size` | |
| `xpack.ml.results_index_rollover_max_size` |
Outdated
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.
What does the -1B setting mean?
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.
What does the
-1Bsetting mean?
It is the minimum valid value accepted by ByteSizeValue.
I'll change the xpack.ml.nightly_maintenance_rollover_max_size setting to have a minimum valid value of 0B, where 0B would result in the indices always being rolled over.
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.
We actually discussed it in the team and it would be good to have -1B option to turn off rollover if needed.
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -8,7 +8,9 @@ | |||
|
|
||||
| import org.elasticsearch.ResourceAlreadyExistsException; | ||||
| import org.elasticsearch.action.support.IndicesOptions; | ||||
| import org.elasticsearch.cluster.ClusterState; | ||||
| import org.elasticsearch.cluster.SimpleDiffable; | ||||
| import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver; | ||||
| import org.elasticsearch.common.Strings; | ||||
| import org.elasticsearch.common.io.stream.StreamInput; | ||||
| import org.elasticsearch.common.io.stream.StreamOutput; | ||||
|
|
@@ -30,6 +32,7 @@ | |||
| import org.elasticsearch.xpack.core.ml.job.persistence.AnomalyDetectorsIndexFields; | ||||
| import org.elasticsearch.xpack.core.ml.job.process.autodetect.state.DataCounts; | ||||
| import org.elasticsearch.xpack.core.ml.utils.ExceptionsHelper; | ||||
| import org.elasticsearch.xpack.core.ml.utils.MlIndexAndAlias; | ||||
| import org.elasticsearch.xpack.core.ml.utils.MlStrings; | ||||
| import org.elasticsearch.xpack.core.ml.utils.ToXContentParams; | ||||
|
|
||||
|
|
@@ -805,6 +808,8 @@ public static class Builder implements Writeable { | |||
| private boolean allowLazyOpen; | ||||
| private Blocked blocked = Blocked.none(); | ||||
| private DatafeedConfig.Builder datafeedConfig; | ||||
| private ClusterState clusterState; | ||||
| private IndexNameExpressionResolver indexNameExpressionResolver; | ||||
|
|
||||
| public Builder() {} | ||||
|
|
||||
|
|
@@ -879,6 +884,14 @@ public String getId() { | |||
| return id; | ||||
| } | ||||
|
|
||||
| private void setClusterState(ClusterState state) { | ||||
| this.clusterState = state; | ||||
| } | ||||
|
|
||||
| private void setIndexNameExpressionResolver(IndexNameExpressionResolver indexNameExpressionResolver) { | ||||
| this.indexNameExpressionResolver = indexNameExpressionResolver; | ||||
| } | ||||
|
|
||||
| public void setJobVersion(MlConfigVersion jobVersion) { | ||||
| this.jobVersion = jobVersion; | ||||
| } | ||||
|
|
@@ -1305,6 +1318,16 @@ public void validateDetectorsAreUnique() { | |||
| } | ||||
| } | ||||
|
|
||||
| public Job build( | ||||
| @SuppressWarnings("HiddenField") Date createTime, | ||||
| ClusterState state, | ||||
| IndexNameExpressionResolver indexNameExpressionResolver | ||||
| ) { | ||||
| setClusterState(state); | ||||
| setIndexNameExpressionResolver(indexNameExpressionResolver); | ||||
| return build(createTime); | ||||
| } | ||||
|
|
||||
| /** | ||||
| * Builds a job with the given {@code createTime} and the current version. | ||||
| * This should be used when a new job is created as opposed to {@link #build()}. | ||||
|
|
@@ -1344,11 +1367,26 @@ public Job build() { | |||
|
|
||||
| if (Strings.isNullOrEmpty(resultsIndexName)) { | ||||
| resultsIndexName = AnomalyDetectorsIndexFields.RESULTS_INDEX_DEFAULT; | ||||
| } else if (resultsIndexName.equals(AnomalyDetectorsIndexFields.RESULTS_INDEX_DEFAULT) == false) { | ||||
| // User-defined names are prepended with "custom" | ||||
| // Conditional guards against multiple prepending due to updates instead of first creation | ||||
| resultsIndexName = resultsIndexName.startsWith("custom-") ? resultsIndexName : "custom-" + resultsIndexName; | ||||
| } else if ((resultsIndexName.startsWith(AnomalyDetectorsIndexFields.RESULTS_INDEX_SHARED) | ||||
| && MlIndexAndAlias.has6DigitSuffix(resultsIndexName) | ||||
| && resultsIndexName.length() == AnomalyDetectorsIndexFields.RESULTS_INDEX_DEFAULT.length()) == false) { | ||||
valeriy42 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||
| // User-defined names are prepended with "custom" and end with a 6 digit suffix | ||||
| // Conditional guards against multiple prepending due to updates instead of first creation | ||||
| resultsIndexName = resultsIndexName.startsWith("custom-") ? resultsIndexName : "custom-" + resultsIndexName; | ||||
| } | ||||
|
|
||||
| resultsIndexName = MlIndexAndAlias.has6DigitSuffix(resultsIndexName) ? resultsIndexName : resultsIndexName + "-000001"; | ||||
|
||||
| public void createJobResultIndex(Job job, ClusterState state, final ActionListener<Boolean> finalListener) { |
This build() method is called both when creating the job and when it is parsed from the stored document. For that reason I think it would be safer to move the results index logic to where the index is created.
Uh oh!
There was an error while loading. Please reload this page.