+
+ }
+ color="warning"
+ iconType="alert"
+ >
+
+
+
+
+ {isCloud && id !== null && (
+
+
+
+
+
+ ),
+ }}
+ />
+
+ )}
+
+
+
+
+ );
+ }
+};
diff --git a/x-pack/legacy/plugins/ml/public/jobs/new_job_new/utils/new_job_defaults.ts b/x-pack/legacy/plugins/ml/public/jobs/new_job_new/utils/new_job_defaults.ts
index c86a5a7861b642..e3c4bc8a4a28ce 100644
--- a/x-pack/legacy/plugins/ml/public/jobs/new_job_new/utils/new_job_defaults.ts
+++ b/x-pack/legacy/plugins/ml/public/jobs/new_job_new/utils/new_job_defaults.ts
@@ -19,20 +19,32 @@ export interface MlServerLimits {
max_model_memory_limit?: string;
}
+export interface CloudInfo {
+ cloudId: string | null;
+ isCloud: boolean;
+}
+
let defaults: MlServerDefaults = {
anomaly_detectors: {},
datafeeds: {},
};
let limits: MlServerLimits = {};
+const cloudInfo: CloudInfo = {
+ cloudId: null,
+ isCloud: false,
+};
+
export async function loadNewJobDefaults() {
try {
const resp = await ml.mlInfo();
defaults = resp.defaults;
limits = resp.limits;
- return { defaults, limits };
+ cloudInfo.cloudId = resp.cloudId || null;
+ cloudInfo.isCloud = resp.cloudId !== undefined;
+ return { defaults, limits, cloudId: cloudInfo };
} catch (error) {
- return { defaults, limits };
+ return { defaults, limits, cloudId: cloudInfo };
}
}
@@ -43,3 +55,24 @@ export function newJobDefaults(): MlServerDefaults {
export function newJobLimits(): MlServerLimits {
return limits;
}
+
+export function cloudId(): string | null {
+ return cloudInfo.cloudId;
+}
+
+export function isCloud(): boolean {
+ return cloudInfo.isCloud;
+}
+
+export function cloudDeploymentId(): string | null {
+ if (cloudInfo.cloudId === null) {
+ return null;
+ }
+ const tempCloudId = cloudInfo.cloudId.replace(/^.+:/, '');
+ try {
+ const matches = atob(tempCloudId).match(/^.+\$(.+)(?=\$)/);
+ return matches !== null && matches.length === 2 ? matches[1] : null;
+ } catch (error) {
+ return null;
+ }
+}
diff --git a/x-pack/legacy/plugins/ml/public/services/ml_api_service/index.d.ts b/x-pack/legacy/plugins/ml/public/services/ml_api_service/index.d.ts
index 2e7da6fb9cc69b..22062331bb380f 100644
--- a/x-pack/legacy/plugins/ml/public/services/ml_api_service/index.d.ts
+++ b/x-pack/legacy/plugins/ml/public/services/ml_api_service/index.d.ts
@@ -54,6 +54,7 @@ export interface MlInfoResponse {
version: string;
};
upgrade_mode: boolean;
+ cloudId?: string;
}
declare interface Ml {
diff --git a/x-pack/legacy/plugins/ml/server/routes/system.js b/x-pack/legacy/plugins/ml/server/routes/system.js
index 8ca285eb236089..a686971672c580 100644
--- a/x-pack/legacy/plugins/ml/server/routes/system.js
+++ b/x-pack/legacy/plugins/ml/server/routes/system.js
@@ -21,6 +21,7 @@ import { isSecurityDisabled } from '../lib/security_utils';
export function systemRoutes({
commonRouteConfig,
elasticsearchPlugin,
+ config,
route,
xpackMainPlugin,
spacesPlugin
@@ -168,10 +169,17 @@ export function systemRoutes({
route({
method: 'GET',
path: '/api/ml/info',
- handler(request) {
+ async handler(request) {
const callWithRequest = callWithRequestFactory(elasticsearchPlugin, request);
- return callWithRequest('ml.info')
- .catch(resp => wrapError(resp));
+
+ try {
+ const info = await callWithRequest('ml.info');
+ const cloudIdKey = 'xpack.cloud.id';
+ const cloudId = config.has(cloudIdKey) && config.get(cloudIdKey);
+ return { ...info, cloudId };
+ } catch (error) {
+ return wrapError(error);
+ }
},
config: {
...commonRouteConfig
diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json
index f5727b48343676..28db2197638ff2 100644
--- a/x-pack/plugins/translations/translations/ja-JP.json
+++ b/x-pack/plugins/translations/translations/ja-JP.json
@@ -6189,10 +6189,8 @@
"xpack.ml.jobsList.multiJobsActions.startDatafeedsLabel": "{jobsCount, plural, one {データフィード} other {データフィード}}を開始",
"xpack.ml.jobsList.multiJobsActions.stopDatafeedsLabel": "{jobsCount, plural, one {データフィード} other {データフィード}}を停止",
"xpack.ml.jobsList.nodeAvailableWarning.linkToCloud.hereLinkText": "こちら",
- "xpack.ml.jobsList.nodeAvailableWarning.linkToCloudDescription": "これはクラウド {hereCloudLink} で構成できます。",
"xpack.ml.jobsList.nodeAvailableWarning.noMLNodesAvailableDescription": "利用可能な ML ノードがありません。",
"xpack.ml.jobsList.nodeAvailableWarning.noMLNodesAvailableTitle": "利用可能な ML ノードがありません",
- "xpack.ml.jobsList.nodeAvailableWarning.unavailableCreateOrRunJobsDescription": "ジョブの作成または実行はできません. {cloudConfigLink}",
"xpack.ml.jobsList.noJobsFoundLabel": "ジョブが見つかりません",
"xpack.ml.jobsList.processedRecordsLabel": "処理済みレコード",
"xpack.ml.jobsList.refreshButtonLabel": "更新",
@@ -10308,4 +10306,4 @@
"xpack.fileUpload.fileParser.errorReadingFile": "ファイルの読み込み中にエラーが発生しました",
"xpack.fileUpload.fileParser.noFileProvided": "エラー、ファイルが提供されていません"
}
-}
+}
\ No newline at end of file
diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json
index 04f00d945b67c9..6cf125aee8f963 100644
--- a/x-pack/plugins/translations/translations/zh-CN.json
+++ b/x-pack/plugins/translations/translations/zh-CN.json
@@ -6190,10 +6190,8 @@
"xpack.ml.jobsList.multiJobsActions.startDatafeedsLabel": "开始 {jobsCount, plural, one { 个数据馈送} other { 个数据馈送}}",
"xpack.ml.jobsList.multiJobsActions.stopDatafeedsLabel": "停止 {jobsCount, plural, one { 个数据馈送} other { 个数据馈送}}",
"xpack.ml.jobsList.nodeAvailableWarning.linkToCloud.hereLinkText": "此处",
- "xpack.ml.jobsList.nodeAvailableWarning.linkToCloudDescription": "这可以在云 {hereCloudLink} 中进行配置。",
"xpack.ml.jobsList.nodeAvailableWarning.noMLNodesAvailableDescription": "没有可用的 ML 节点。",
"xpack.ml.jobsList.nodeAvailableWarning.noMLNodesAvailableTitle": "没有可用的 ML 节点",
- "xpack.ml.jobsList.nodeAvailableWarning.unavailableCreateOrRunJobsDescription": "您将无法创建或运行作业。{cloudConfigLink}",
"xpack.ml.jobsList.noJobsFoundLabel": "找不到作业",
"xpack.ml.jobsList.processedRecordsLabel": "已处理记录",
"xpack.ml.jobsList.refreshButtonLabel": "刷新",
@@ -10463,4 +10461,4 @@
"xpack.fileUpload.fileParser.errorReadingFile": "读取文件时出错",
"xpack.fileUpload.fileParser.noFileProvided": "错误,未提供任何文件"
}
-}
+}
\ No newline at end of file