Skip to content

Commit

Permalink
[ML] Add metrics app to check made for internal custom URLs (elastic#…
Browse files Browse the repository at this point in the history
  • Loading branch information
peteharverson committed Sep 17, 2020
1 parent 9355f5d commit d604754
Showing 2 changed files with 41 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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',
Original file line number Diff line number Diff line change
@@ -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#/')

0 comments on commit d604754

Please sign in to comment.