diff --git a/x-pack/plugins/ml/public/components/messagebar/messagebar_service.js b/x-pack/plugins/ml/public/components/messagebar/messagebar_service.js index 3bbf7e79c683ef..4395be2a9fb4b7 100644 --- a/x-pack/plugins/ml/public/components/messagebar/messagebar_service.js +++ b/x-pack/plugins/ml/public/components/messagebar/messagebar_service.js @@ -6,7 +6,7 @@ import { notify } from 'ui/notify'; -import { MLRequestFailure } from 'plugins/ml/util/ml_error'; +import { MLRequestFailure } from '../../util/ml_error'; const messages = []; diff --git a/x-pack/plugins/ml/public/explorer/explorer_charts/__mocks__/mock_anomaly_chart_records.json b/x-pack/plugins/ml/public/explorer/explorer_charts/__mocks__/mock_anomaly_chart_records.json new file mode 100644 index 00000000000000..3f106d399f8527 --- /dev/null +++ b/x-pack/plugins/ml/public/explorer/explorer_charts/__mocks__/mock_anomaly_chart_records.json @@ -0,0 +1,68 @@ +[ + { + "job_id": "mock-job-id", + "result_type": "record", + "probability": 1.6552181439816634e-32, + "record_score": 98.56065708456248, + "initial_record_score": 98.56065708456248, + "bucket_span": 900, + "detector_index": 0, + "is_interim": false, + "timestamp": 1486656000000, + "partition_field_name": "airline", + "partition_field_value": "AAL", + "function": "mean", + "function_description": "mean", + "typical": [ + 99.81123207526203 + ], + "actual": [ + 242.3568918440077 + ], + "field_name": "responsetime", + "influencers": [ + { + "influencer_field_name": "airline", + "influencer_field_values": [ + "AAL" + ] + } + ], + "airline": [ + "AAL" + ] + }, + { + "job_id": "mock-job-id", + "result_type": "record", + "probability": 2.6276047868032343e-28, + "record_score": 96.93718, + "initial_record_score": 92.70812367638732, + "bucket_span": 900, + "detector_index": 0, + "is_interim": false, + "timestamp": 1486656900000, + "partition_field_name": "airline", + "partition_field_value": "AAL", + "function": "mean", + "function_description": "mean", + "typical": [ + 100.02884159032787 + ], + "actual": [ + 282.02533259111306 + ], + "field_name": "responsetime", + "influencers": [ + { + "influencer_field_name": "airline", + "influencer_field_values": [ + "AAL" + ] + } + ], + "airline": [ + "AAL" + ] + } +] diff --git a/x-pack/plugins/ml/public/explorer/explorer_charts/__mocks__/mock_anomaly_record.json b/x-pack/plugins/ml/public/explorer/explorer_charts/__mocks__/mock_anomaly_record.json new file mode 100644 index 00000000000000..ccc13b6a815a42 --- /dev/null +++ b/x-pack/plugins/ml/public/explorer/explorer_charts/__mocks__/mock_anomaly_record.json @@ -0,0 +1,33 @@ +{ + "job_id": "mock-job-id", + "result_type": "record", + "probability": 0.000374234162864467, + "record_score": 1.3677172011743646, + "initial_record_score": 1.3677172011743646, + "bucket_span": 900, + "detector_index": 0, + "is_interim": false, + "timestamp": 1486743300000, + "partition_field_name": "airline", + "partition_field_value": "JAL", + "function": "mean", + "function_description": "mean", + "typical": [ + 499.9850000350266 + ], + "actual": [ + 511.4997161865235 + ], + "field_name": "responsetime", + "influencers": [ + { + "influencer_field_name": "airline", + "influencer_field_values": [ + "JAL" + ] + } + ], + "airline": [ + "JAL" + ] +} diff --git a/x-pack/plugins/ml/public/explorer/explorer_charts/__mocks__/mock_chart_data.js b/x-pack/plugins/ml/public/explorer/explorer_charts/__mocks__/mock_chart_data.js new file mode 100644 index 00000000000000..e150335114a201 --- /dev/null +++ b/x-pack/plugins/ml/public/explorer/explorer_charts/__mocks__/mock_chart_data.js @@ -0,0 +1,26 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License; + * you may not use this file except in compliance with the Elastic License. + */ + +export const chartData = [ + { + date: new Date('2017-02-23T08:00:00.000Z'), + value: 228243469, anomalyScore: 63.32916, numberOfCauses: 1, + actual: [228243469], typical: [133107.7703441773] + }, + { date: new Date('2017-02-23T09:00:00.000Z'), value: null }, + { date: new Date('2017-02-23T10:00:00.000Z'), value: null }, + { date: new Date('2017-02-23T11:00:00.000Z'), value: null }, + { + date: new Date('2017-02-23T12:00:00.000Z'), + value: 625736376, anomalyScore: 97.32085, numberOfCauses: 1, + actual: [625736376], typical: [132830.424736973] + }, + { + date: new Date('2017-02-23T13:00:00.000Z'), + value: 201039318, anomalyScore: 59.83488, numberOfCauses: 1, + actual: [201039318], typical: [132739.5267403542] + } +]; diff --git a/x-pack/plugins/ml/public/explorer/explorer_charts/__mocks__/mock_detectors_by_job.json b/x-pack/plugins/ml/public/explorer/explorer_charts/__mocks__/mock_detectors_by_job.json new file mode 100644 index 00000000000000..f45a2d5b8f2b9e --- /dev/null +++ b/x-pack/plugins/ml/public/explorer/explorer_charts/__mocks__/mock_detectors_by_job.json @@ -0,0 +1,11 @@ +{ + "mock-job-id": [ + { + "detector_description": "mean(responsetime)", + "function": "mean", + "field_name": "responsetime", + "partition_field_name": "airline", + "detector_index": 0 + } + ] +} diff --git a/x-pack/plugins/ml/public/explorer/explorer_charts/__mocks__/mock_job_config.json b/x-pack/plugins/ml/public/explorer/explorer_charts/__mocks__/mock_job_config.json new file mode 100644 index 00000000000000..2750ad84a8308e --- /dev/null +++ b/x-pack/plugins/ml/public/explorer/explorer_charts/__mocks__/mock_job_config.json @@ -0,0 +1,88 @@ +{ + "job_id": "mock-job-id", + "job_type": "anomaly_detector", + "job_version": "7.0.0-alpha1", + "description": "", + "create_time": 1532692299663, + "finished_time": 1532692304364, + "established_model_memory": 560894, + "analysis_config": { + "bucket_span": "15m", + "detectors": [ + { + "detector_description": "mean(responsetime)", + "function": "mean", + "field_name": "responsetime", + "partition_field_name": "airline", + "detector_index": 0 + } + ], + "influencers": [ + "airline" + ] + }, + "analysis_limits": { + "model_memory_limit": "13mb", + "categorization_examples_limit": 4 + }, + "data_description": { + "time_field": "@timestamp", + "time_format": "epoch_ms" + }, + "model_snapshot_retention_days": 1, + "custom_settings": { + "created_by": "multi-metric-wizard" + }, + "model_snapshot_id": "1532692303", + "model_snapshot_min_version": "6.4.0", + "results_index_name": "shared", + "data_counts": { + "job_id": "mock-job-id", + "processed_record_count": 86274, + "processed_field_count": 172548, + "input_bytes": 6744642, + "input_field_count": 172548, + "invalid_date_count": 0, + "missing_field_count": 0, + "out_of_order_timestamp_count": 0, + "empty_bucket_count": 0, + "sparse_bucket_count": 0, + "bucket_count": 479, + "earliest_record_timestamp": 1486425600000, + "latest_record_timestamp": 1486857594000, + "last_data_time": 1532692303844, + "input_record_count": 86274 + }, + "model_size_stats": { + "job_id": "mock-job-id", + "result_type": "model_size_stats", + "model_bytes": 560894, + "total_by_field_count": 21, + "total_over_field_count": 0, + "total_partition_field_count": 20, + "bucket_allocation_failures_count": 0, + "memory_status": "ok", + "log_time": 1532692303000, + "timestamp": 1486855800000 + }, + "datafeed_config": { + "datafeed_id": "datafeed-mock-job-id", + "job_id": "mock-job-id", + "query_delay": "86658ms", + "indices": [ + "farequote-2017" + ], + "types": [], + "query": { + "match_all": { + "boost": 1 + } + }, + "scroll_size": 1000, + "chunking_config": { + "mode": "auto" + }, + "state": "stopped" + }, + "state": "closed" +} diff --git a/x-pack/plugins/ml/public/explorer/explorer_charts/__mocks__/mock_series_config_filebeat.json b/x-pack/plugins/ml/public/explorer/explorer_charts/__mocks__/mock_series_config_filebeat.json new file mode 100644 index 00000000000000..b2c974e737e48c --- /dev/null +++ b/x-pack/plugins/ml/public/explorer/explorer_charts/__mocks__/mock_series_config_filebeat.json @@ -0,0 +1,57 @@ +{ + "jobId": "population-03", + "detectorIndex": 0, + "metricFunction": "sum", + "timeField": "@timestamp", + "interval": "1h", + "datafeedConfig": { + "datafeed_id": "datafeed-population-03", + "job_id": "population-03", + "query_delay": "60s", + "frequency": "600s", + "indices": [ + "filebeat-7.0.0*" + ], + "types": [ + "doc" + ], + "query": { + "match_all": { + "boost": 1 + } + }, + "scroll_size": 1000, + "chunking_config": { + "mode": "auto" + }, + "state": "stopped" + }, + "metricFieldName": "nginx.access.body_sent.bytes", + "functionDescription": "sum", + "bucketSpanSeconds": 3600, + "detectorLabel": "high_sum(nginx.access.body_sent.bytes) over nginx.access.remote_ip (population-03)", + "fieldName": "nginx.access.body_sent.bytes", + "entityFields": [ + { + "fieldName": "nginx.access.remote_ip", + "fieldValue": "72.57.0.53", + "$$hashKey": "object:813" + } + ], + "infoTooltip": { + "jobId": "population-03", + "aggregationInterval": "1h", + "chartFunction": "sum nginx.access.body_sent.bytes", + "entityFields": [ + { + "fieldName": "nginx.access.remote_ip", + "fieldValue": "72.57.0.53" + } + ] + }, + "loading": false, + "plotEarliest": 1487534400000, + "plotLatest": 1488168000000, + "selectedEarliest": 1487808000000, + "selectedLatest": 1487894399999 +} diff --git a/x-pack/plugins/ml/public/explorer/explorer_charts/__mocks__/mock_series_promises_response.json b/x-pack/plugins/ml/public/explorer/explorer_charts/__mocks__/mock_series_promises_response.json new file mode 100644 index 00000000000000..b2d51e7de713ba --- /dev/null +++ b/x-pack/plugins/ml/public/explorer/explorer_charts/__mocks__/mock_series_promises_response.json @@ -0,0 +1,231 @@ +[ + [ + { + "success": true, + "results": { + "1486611900000": 95.61584963117328, + "1486612800000": 99.34646708170573, + "1486613700000": 92.54502330106847, + "1486614600000": 98.87258768081665, + "1486615500000": 102.82824816022601, + "1486616400000": 96.7391939163208, + "1486617300000": 99.72634760538737, + "1486618200000": 101.08556365966797, + "1486619100000": 84.60266517190372, + "1486620000000": 105.24246263504028, + "1486620900000": 91.86086603800456, + "1486621800000": 94.5369130452474, + "1486622700000": 97.63843189586292, + "1486623600000": 93.79290502211627, + "1486624500000": 108.91006604362937, + "1486625400000": 107.46900049845378, + "1486626300000": 100.03502061631944, + "1486627200000": 92.0638559129503, + "1486628100000": 96.06356851678146, + "1486629000000": 109.89569989372703, + "1486629900000": 96.09498441786994, + "1486630800000": 105.05972120496962, + "1486631700000": 94.53041982650757, + "1486632600000": 103.37048240329908, + "1486633500000": 105.2058048248291, + "1486634400000": 102.06169471740722, + "1486635300000": 101.4836499955919, + "1486636200000": 96.34219177246094, + "1486637100000": 102.81613063812256, + "1486638000000": 96.09064518321644, + "1486638900000": 104.8488635012978, + "1486639800000": 93.45240384056454, + "1486640700000": 102.28834065524015, + "1486641600000": 104.54204668317523, + "1486642500000": 99.85492063823499, + "1486643400000": 97.12778260972765, + "1486644300000": 103.99638447008635, + "1486645200000": 95.34676822863128, + "1486646100000": 97.04620517383923, + "1486647000000": 104.2849609375, + "1486647900000": 97.88982413796818, + "1486648800000": 99.03312370300293, + "1486649700000": 105.5509593963623, + "1486650600000": 100.49496881585372, + "1486651500000": 99.06059494018555, + "1486652400000": 90.58293914794922, + "1486653300000": 92.8633090655009, + "1486654200000": 96.12510445004418, + "1486655100000": 100.4840145111084, + "1486656000000": 242.3568918440077, + "1486656900000": 282.02533259111294, + "1486657800000": 100.15823459625244, + "1486658700000": 97.5446532754337, + "1486659600000": 99.53840043809679, + "1486660500000": 101.24810005636776, + "1486661400000": 101.11400771141052, + "1486662300000": 100.70463662398488, + "1486663200000": 110.70174247340152, + "1486664100000": 96.51030629475912, + "1486665000000": 103.92840491400824, + "1486665900000": 98.29448418868215, + "1486666800000": 98.0272060394287, + "1486667700000": 99.63833363850911, + "1486668600000": 105.18764642568735, + "1486669500000": 97.8544118669298, + "1486670400000": 97.99196343672902, + "1486671300000": 106.30481338500977, + "1486672200000": 99.88215498490767, + "1486673100000": 93.50493303934734, + "1486674000000": 101.2538422175816, + "1486674900000": 102.07398986816406, + "1486675800000": 102.66583075890175, + "1486676700000": 108.5278158748851, + "1486677600000": 103.91436131795247, + "1486678500000": 98.55452414119945, + "1486679400000": 88.25028387705485, + "1486680300000": 93.57433591570172, + "1486681200000": 96.70550713172325, + "1486682100000": 98.14921424502418, + "1486683000000": 96.99264602661133, + "1486683900000": 88.23578810691833, + "1486684800000": 106.89157305265728, + "1486685700000": 101.07822271493765, + "1486686600000": 101.77820564718807, + "1486687500000": 102.84660829816546, + "1486688400000": 103.91598869772518, + "1486689300000": 104.73469270978656, + "1486690200000": 97.01155325082632, + "1486691100000": 104.97890539730297, + "1486692000000": 99.66440022786459, + "1486692900000": 99.64117607703575, + "1486693800000": 87.37038326263428, + "1486694700000": 105.95191955566406, + "1486695600000": 104.33271111382379, + "1486696500000": 101.93921706255745, + "1486697400000": 101.11774004422702, + "1486698300000": 101.70929403866039, + "1486699200000": 102.61243908221905, + "1486700100000": 99.16273922390408, + "1486701000000": 105.98729952643899, + "1486701900000": 114.16951904296874, + "1486702800000": 98.25128769874573, + "1486703700000": 94.25434192858245, + "1486704600000": 99.7759528526893, + "1486705500000": 113.10429502788342, + "1486706400000": 97.95185834711248, + "1486707300000": 114.46214866638184, + "1486708200000": 105.51880025863647, + "1486709100000": 99.89148930140904, + "1486710000000": 90.5253866369074, + "1486710900000": 103.66612243652344, + "1486711800000": 103.97851837158203, + "1486712700000": 92.76053659539474, + "1486713600000": 99.99461364746094 + } + }, + { + "success": true, + "records": [ + { + "job_id": "mock-job-id", + "result_type": "record", + "probability": 1.6552181439816634e-32, + "record_score": 98.56065708456248, + "initial_record_score": 98.56065708456248, + "bucket_span": 900, + "detector_index": 0, + "is_interim": false, + "timestamp": 1486656000000, + "partition_field_name": "airline", + "partition_field_value": "AAL", + "function": "mean", + "function_description": "mean", + "typical": [ + 99.81123207526203 + ], + "actual": [ + 242.3568918440077 + ], + "field_name": "responsetime", + "influencers": [ + { + "influencer_field_name": "airline", + "influencer_field_values": [ + "AAL" + ] + } + ], + "airline": [ + "AAL" + ] + }, + { + "job_id": "mock-job-id", + "result_type": "record", + "probability": 2.6276047868032343e-28, + "record_score": 96.93718, + "initial_record_score": 92.70812367638732, + "bucket_span": 900, + "detector_index": 0, + "is_interim": false, + "timestamp": 1486656900000, + "partition_field_name": "airline", + "partition_field_value": "AAL", + "function": "mean", + "function_description": "mean", + "typical": [ + 100.02884159032787 + ], + "actual": [ + 282.02533259111306 + ], + "field_name": "responsetime", + "influencers": [ + { + "influencer_field_name": "airline", + "influencer_field_values": [ + "AAL" + ] + } + ], + "airline": [ + "AAL" + ] + }, + { + "job_id": "mock-job-id", + "result_type": "record", + "probability": 0.013283203854072794, + "record_score": 0.02716009, + "initial_record_score": 0.6110770406098681, + "bucket_span": 900, + "detector_index": 0, + "is_interim": false, + "timestamp": 1486619100000, + "partition_field_name": "airline", + "partition_field_value": "AAL", + "function": "mean", + "function_description": "mean", + "typical": [ + 99.79426367092864 + ], + "actual": [ + 84.60266517190372 + ], + "field_name": "responsetime", + "influencers": [ + { + "influencer_field_name": "airline", + "influencer_field_values": [ + "AAL" + ] + } + ], + "airline": [ + "AAL" + ] + } + ] + }, + { + "success": true, + "events": {} + } + ] +] diff --git a/x-pack/plugins/ml/public/explorer/explorer_charts/__snapshots__/explorer_chart_config_builder.test.js.snap b/x-pack/plugins/ml/public/explorer/explorer_charts/__snapshots__/explorer_chart_config_builder.test.js.snap new file mode 100644 index 00000000000000..f899ee14003b78 --- /dev/null +++ b/x-pack/plugins/ml/public/explorer/explorer_charts/__snapshots__/explorer_chart_config_builder.test.js.snap @@ -0,0 +1,52 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`buildConfig get dataConfig for anomaly record 1`] = ` +Object { + "bucketSpanSeconds": 900, + "datafeedConfig": Object { + "chunking_config": Object { + "mode": "auto", + }, + "datafeed_id": "datafeed-mock-job-id", + "indices": Array [ + "farequote-2017", + ], + "job_id": "mock-job-id", + "query": Object { + "match_all": Object { + "boost": 1, + }, + }, + "query_delay": "86658ms", + "scroll_size": 1000, + "state": "stopped", + "types": Array [], + }, + "detectorIndex": 0, + "detectorLabel": "mean(responsetime)", + "entityFields": Array [ + Object { + "fieldName": "airline", + "fieldValue": "JAL", + }, + ], + "fieldName": "responsetime", + "functionDescription": "mean", + "infoTooltip": Object { + "aggregationInterval": "15m", + "chartFunction": "avg responsetime", + "entityFields": Array [ + Object { + "fieldName": "airline", + "fieldValue": "JAL", + }, + ], + "jobId": "mock-job-id", + }, + "interval": "15m", + "jobId": "mock-job-id", + "metricFieldName": "responsetime", + "metricFunction": "avg", + "timeField": "@timestamp", +} +`; diff --git a/x-pack/plugins/ml/public/explorer/explorer_charts/__snapshots__/explorer_chart_tooltip.test.js.snap b/x-pack/plugins/ml/public/explorer/explorer_charts/__snapshots__/explorer_chart_tooltip.test.js.snap new file mode 100644 index 00000000000000..c602bc0373c51e --- /dev/null +++ b/x-pack/plugins/ml/public/explorer/explorer_charts/__snapshots__/explorer_chart_tooltip.test.js.snap @@ -0,0 +1,24 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`ExplorerChartTooltip Render tooltip based on infoTooltip data. 1`] = ` +
+ job ID: + mock-job-id +
+ aggregation interval: + 15m +
+ chart function: + avg responsetime + +
+ airline + : + JAL +
+
+`; diff --git a/x-pack/plugins/ml/public/explorer/explorer_charts/__snapshots__/explorer_charts_container.test.js.snap b/x-pack/plugins/ml/public/explorer/explorer_charts/__snapshots__/explorer_charts_container.test.js.snap new file mode 100644 index 00000000000000..087558cfa4ed4d --- /dev/null +++ b/x-pack/plugins/ml/public/explorer/explorer_charts/__snapshots__/explorer_charts_container.test.js.snap @@ -0,0 +1,54 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`ExplorerChartsContainer Initialization with chart data 1`] = ` +
+
+ + high_sum(nginx.access.body_sent.bytes) over nginx.access.remote_ip (population-03) + - + + + nginx.access.remote_ip + + 72.57.0.53 + +
+ + } + position="left" + size="s" + type="questionInCircle" + /> + + View +