Skip to content

Commit d604754

Browse files
committed
[ML] Add metrics app to check made for internal custom URLs (#77627)
1 parent 9355f5d commit d604754

2 files changed

Lines changed: 41 additions & 1 deletion

File tree

x-pack/plugins/ml/public/application/util/custom_url_utils.test.ts

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -456,7 +456,7 @@ describe('ML - custom URL utils', () => {
456456
);
457457
});
458458

459-
test('return expected url for Security app', () => {
459+
test('return expected URL for Security app', () => {
460460
const urlConfig = {
461461
url_name: 'Hosts Details by process name',
462462
url_value:
@@ -508,6 +508,45 @@ describe('ML - custom URL utils', () => {
508508
);
509509
});
510510

511+
test('return expected URL for Metrics app', () => {
512+
const urlConfig = {
513+
url_name: 'Hosts Details by process name',
514+
url_value:
515+
'metrics/detail/host/$host.name$?metricTime=(autoReload:!f,refreshInterval:5000,time:(from:%27$earliest$%27,interval:%3E%3D1m,to:%27$latest$%27))',
516+
};
517+
518+
const testRecord = {
519+
job_id: 'hosts_memory_usage',
520+
result_type: 'record',
521+
probability: 0.0001288876418224276,
522+
multi_bucket_impact: -5,
523+
record_score: 88.26287,
524+
initial_record_score: 61.553927615180186,
525+
bucket_span: 900,
526+
detector_index: 0,
527+
is_interim: false,
528+
timestamp: 1599571800000,
529+
function: 'max',
530+
function_description: 'max',
531+
typical: [0.23685835059986396],
532+
actual: [0.258],
533+
field_name: 'system.memory.actual.used.pct',
534+
influencers: [
535+
{
536+
influencer_field_name: 'host.name',
537+
influencer_field_values: ['gke-dev-next-oblt-dev-next-oblt-pool-404d7f0c-2bfl'],
538+
},
539+
],
540+
'host.name': ['gke-dev-next-oblt-dev-next-oblt-pool-404d7f0c-2bfl'],
541+
earliest: '2019-09-08T12:00:00.000Z',
542+
latest: '2019-09-08T14:59:59.999Z',
543+
};
544+
545+
expect(getUrlForRecord(urlConfig, testRecord)).toBe(
546+
"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'))"
547+
);
548+
});
549+
511550
test('removes an empty path component with a trailing slash', () => {
512551
const urlConfig = {
513552
url_name: 'APM',

x-pack/plugins/ml/public/application/util/custom_url_utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ function isKibanaUrl(urlConfig: UrlConfig) {
117117
urlValue.startsWith('dashboards#/') ||
118118
urlValue.startsWith('apm#/') ||
119119
// BrowserRouter based plugins
120+
urlValue.startsWith('metrics/') ||
120121
urlValue.startsWith('security/') ||
121122
// Legacy links
122123
urlValue.startsWith('siem#/')

0 commit comments

Comments
 (0)