Skip to content

Commit 231f2fa

Browse files
authored
Metrics framework integration with ml-commons (#3661)
1 parent 50bcbda commit 231f2fa

File tree

44 files changed

+2800
-713
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+2800
-713
lines changed

common/src/main/java/org/opensearch/ml/common/CommonValue.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,12 @@ public class CommonValue {
4444
public static final String ML_MEMORY_META_INDEX = ".plugins-ml-memory-meta";
4545
public static final String ML_MEMORY_MESSAGE_INDEX = ".plugins-ml-memory-message";
4646
public static final String ML_STOP_WORDS_INDEX = ".plugins-ml-stop-words";
47+
// index used in 2.19 to track MlTaskBatchUpdate task
4748
public static final String TASK_POLLING_JOB_INDEX = ".ml_commons_task_polling_job";
4849
public static final String MCP_SESSION_MANAGEMENT_INDEX = ".plugins-ml-mcp-session-management";
4950
public static final String MCP_TOOLS_INDEX = ".plugins-ml-mcp-tools";
51+
// index created in 3.1 to track all ml jobs created via job scheduler
52+
public static final String ML_JOBS_INDEX = ".plugins-ml-jobs";
5053
public static final Set<String> stopWordsIndices = ImmutableSet.of(".plugins-ml-stop-words");
5154
public static final String TOOL_PARAMETERS_PREFIX = "tools.parameters.";
5255

common/src/main/java/org/opensearch/ml/common/MLModel.java

Lines changed: 388 additions & 0 deletions
Large diffs are not rendered by default.

common/src/main/java/org/opensearch/ml/common/settings/MLCommonsSettings.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,4 +342,12 @@ private MLCommonsSettings() {}
342342
/** This setting sets the remote metadata service name */
343343
public static final Setting<String> REMOTE_METADATA_SERVICE_NAME = Setting
344344
.simpleString("plugins.ml_commons." + REMOTE_METADATA_SERVICE_NAME_KEY, Setting.Property.NodeScope, Setting.Property.Final);
345+
346+
// Feature flag for enabling telemetry metric collection via metrics framework
347+
public static final Setting<Boolean> ML_COMMONS_METRIC_COLLECTION_ENABLED = Setting
348+
.boolSetting("plugins.ml_commons.metrics_collection_enabled", false, Setting.Property.NodeScope, Setting.Property.Dynamic);
349+
350+
// Feature flag for enabling telemetry static metric collection job -- MLStatsJobProcessor
351+
public static final Setting<Boolean> ML_COMMONS_STATIC_METRIC_COLLECTION_ENABLED = Setting
352+
.boolSetting("plugins.ml_commons.metrics_static_collection_enabled", false, Setting.Property.NodeScope, Setting.Property.Dynamic);
345353
}

common/src/main/java/org/opensearch/ml/common/settings/MLFeatureEnabledSetting.java

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,13 @@
1212
import static org.opensearch.ml.common.settings.MLCommonsSettings.ML_COMMONS_CONTROLLER_ENABLED;
1313
import static org.opensearch.ml.common.settings.MLCommonsSettings.ML_COMMONS_LOCAL_MODEL_ENABLED;
1414
import static org.opensearch.ml.common.settings.MLCommonsSettings.ML_COMMONS_MCP_SERVER_ENABLED;
15+
import static org.opensearch.ml.common.settings.MLCommonsSettings.ML_COMMONS_METRIC_COLLECTION_ENABLED;
1516
import static org.opensearch.ml.common.settings.MLCommonsSettings.ML_COMMONS_MULTI_TENANCY_ENABLED;
1617
import static org.opensearch.ml.common.settings.MLCommonsSettings.ML_COMMONS_OFFLINE_BATCH_INFERENCE_ENABLED;
1718
import static org.opensearch.ml.common.settings.MLCommonsSettings.ML_COMMONS_OFFLINE_BATCH_INGESTION_ENABLED;
19+
import static org.opensearch.ml.common.settings.MLCommonsSettings.ML_COMMONS_RAG_PIPELINE_FEATURE_ENABLED;
1820
import static org.opensearch.ml.common.settings.MLCommonsSettings.ML_COMMONS_REMOTE_INFERENCE_ENABLED;
21+
import static org.opensearch.ml.common.settings.MLCommonsSettings.ML_COMMONS_STATIC_METRIC_COLLECTION_ENABLED;
1922

2023
import java.util.ArrayList;
2124
import java.util.List;
@@ -43,6 +46,11 @@ public class MLFeatureEnabledSetting {
4346

4447
private volatile Boolean isMcpServerEnabled;
4548

49+
private volatile Boolean isRagSearchPipelineEnabled;
50+
51+
private volatile Boolean isMetricCollectionEnabled;
52+
private volatile Boolean isStaticMetricCollectionEnabled;
53+
4654
private final List<SettingsChangeListener> listeners = new ArrayList<>();
4755

4856
public MLFeatureEnabledSetting(ClusterService clusterService, Settings settings) {
@@ -55,6 +63,9 @@ public MLFeatureEnabledSetting(ClusterService clusterService, Settings settings)
5563
isBatchInferenceEnabled = ML_COMMONS_OFFLINE_BATCH_INFERENCE_ENABLED.get(settings);
5664
isMultiTenancyEnabled = ML_COMMONS_MULTI_TENANCY_ENABLED.get(settings);
5765
isMcpServerEnabled = ML_COMMONS_MCP_SERVER_ENABLED.get(settings);
66+
isRagSearchPipelineEnabled = ML_COMMONS_RAG_PIPELINE_FEATURE_ENABLED.get(settings);
67+
isMetricCollectionEnabled = ML_COMMONS_METRIC_COLLECTION_ENABLED.get(settings);
68+
isStaticMetricCollectionEnabled = ML_COMMONS_STATIC_METRIC_COLLECTION_ENABLED.get(settings);
5869

5970
clusterService
6071
.getClusterSettings()
@@ -74,6 +85,15 @@ public MLFeatureEnabledSetting(ClusterService clusterService, Settings settings)
7485
.getClusterSettings()
7586
.addSettingsUpdateConsumer(ML_COMMONS_OFFLINE_BATCH_INFERENCE_ENABLED, it -> isBatchInferenceEnabled = it);
7687
clusterService.getClusterSettings().addSettingsUpdateConsumer(ML_COMMONS_MCP_SERVER_ENABLED, it -> isMcpServerEnabled = it);
88+
clusterService
89+
.getClusterSettings()
90+
.addSettingsUpdateConsumer(MLCommonsSettings.ML_COMMONS_RAG_PIPELINE_FEATURE_ENABLED, it -> isRagSearchPipelineEnabled = it);
91+
clusterService
92+
.getClusterSettings()
93+
.addSettingsUpdateConsumer(ML_COMMONS_METRIC_COLLECTION_ENABLED, it -> isMetricCollectionEnabled = it);
94+
clusterService
95+
.getClusterSettings()
96+
.addSettingsUpdateConsumer(ML_COMMONS_STATIC_METRIC_COLLECTION_ENABLED, it -> isStaticMetricCollectionEnabled = it);
7797
}
7898

7999
/**
@@ -148,6 +168,22 @@ public void addListener(SettingsChangeListener listener) {
148168
listeners.add(listener);
149169
}
150170

171+
/**
172+
* Whether the rag search pipeline feature is enabled. If disabled, APIs in ml-commons will block rag search pipeline.
173+
* @return whether the feature is enabled.
174+
*/
175+
public boolean isRagSearchPipelineEnabled() {
176+
return isRagSearchPipelineEnabled;
177+
}
178+
179+
public boolean isMetricCollectionEnabled() {
180+
return isMetricCollectionEnabled;
181+
}
182+
183+
public boolean isStaticMetricCollectionEnabled() {
184+
return isStaticMetricCollectionEnabled;
185+
}
186+
151187
@VisibleForTesting
152188
public void notifyMultiTenancyListeners(boolean isEnabled) {
153189
for (SettingsChangeListener listener : listeners) {

0 commit comments

Comments
 (0)