diff --git a/x-pack/plugins/ml/public/application/util/custom_url_utils.test.ts b/x-pack/plugins/ml/public/application/util/custom_url_utils.test.ts index 6a5583ecbb8ac..fa6329b4e8652 100644 --- a/x-pack/plugins/ml/public/application/util/custom_url_utils.test.ts +++ b/x-pack/plugins/ml/public/application/util/custom_url_utils.test.ts @@ -456,7 +456,7 @@ describe('ML - custom URL utils', () => { ); }); - test('return expected url for Security app', () => { + test('return expected URL for Security app', () => { const urlConfig = { url_name: 'Hosts Details by process name', url_value: @@ -508,6 +508,45 @@ describe('ML - custom URL utils', () => { ); }); + test('return expected URL for Metrics app', () => { + const urlConfig = { + url_name: 'Hosts Details by process name', + url_value: + 'metrics/detail/host/$host.name$?metricTime=(autoReload:!f,refreshInterval:5000,time:(from:%27$earliest$%27,interval:%3E%3D1m,to:%27$latest$%27))', + }; + + const testRecord = { + job_id: 'hosts_memory_usage', + result_type: 'record', + probability: 0.0001288876418224276, + multi_bucket_impact: -5, + record_score: 88.26287, + initial_record_score: 61.553927615180186, + bucket_span: 900, + detector_index: 0, + is_interim: false, + timestamp: 1599571800000, + function: 'max', + function_description: 'max', + typical: [0.23685835059986396], + actual: [0.258], + field_name: 'system.memory.actual.used.pct', + influencers: [ + { + influencer_field_name: 'host.name', + influencer_field_values: ['gke-dev-next-oblt-dev-next-oblt-pool-404d7f0c-2bfl'], + }, + ], + 'host.name': ['gke-dev-next-oblt-dev-next-oblt-pool-404d7f0c-2bfl'], + earliest: '2019-09-08T12:00:00.000Z', + latest: '2019-09-08T14:59:59.999Z', + }; + + expect(getUrlForRecord(urlConfig, testRecord)).toBe( + "metrics/detail/host/gke-dev-next-oblt-dev-next-oblt-pool-404d7f0c-2bfl?metricTime=(autoReload:!f,refreshInterval:5000,time:(from:'2019-09-08T12:00:00.000Z',interval:>=1m,to:'2019-09-08T14:59:59.999Z'))" + ); + }); + test('removes an empty path component with a trailing slash', () => { const urlConfig = { url_name: 'APM', diff --git a/x-pack/plugins/ml/public/application/util/custom_url_utils.ts b/x-pack/plugins/ml/public/application/util/custom_url_utils.ts index 18ba1e4ee337b..cf24fdb22a651 100644 --- a/x-pack/plugins/ml/public/application/util/custom_url_utils.ts +++ b/x-pack/plugins/ml/public/application/util/custom_url_utils.ts @@ -117,6 +117,7 @@ function isKibanaUrl(urlConfig: UrlConfig) { urlValue.startsWith('dashboards#/') || urlValue.startsWith('apm#/') || // BrowserRouter based plugins + urlValue.startsWith('metrics/') || urlValue.startsWith('security/') || // Legacy links urlValue.startsWith('siem#/')