|
@@ -394,64 +394,146 @@ include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=results-retention-days]
|
|
|
[[ml-put-job-example]]
|
|
|
== {api-examples-title}
|
|
|
|
|
|
+Create an {anomaly-job} and {dfeed}:
|
|
|
+
|
|
|
[source,console]
|
|
|
--------------------------------------------------
|
|
|
-PUT _ml/anomaly_detectors/total-requests
|
|
|
+PUT _ml/anomaly_detectors/test-job1?pretty
|
|
|
{
|
|
|
- "description" : "Total sum of requests",
|
|
|
- "analysis_config" : {
|
|
|
- "bucket_span":"10m",
|
|
|
+ "analysis_config": {
|
|
|
+ "bucket_span": "15m",
|
|
|
"detectors": [
|
|
|
{
|
|
|
- "detector_description": "Sum of total",
|
|
|
+ "detector_description": "Sum of bytes",
|
|
|
"function": "sum",
|
|
|
- "field_name": "total"
|
|
|
+ "field_name": "bytes"
|
|
|
}
|
|
|
]
|
|
|
},
|
|
|
- "data_description" : {
|
|
|
- "time_field":"timestamp",
|
|
|
+ "data_description": {
|
|
|
+ "time_field": "timestamp",
|
|
|
"time_format": "epoch_ms"
|
|
|
+ },
|
|
|
+ "analysis_limits": {
|
|
|
+ "model_memory_limit": "11MB"
|
|
|
+ },
|
|
|
+ "model_plot_config": {
|
|
|
+ "enabled": true,
|
|
|
+ "annotations_enabled": true
|
|
|
+ },
|
|
|
+ "results_index_name": "test-job1",
|
|
|
+ "datafeed_config":
|
|
|
+ {
|
|
|
+ "indices": [
|
|
|
+ "kibana_sample_data_logs"
|
|
|
+ ],
|
|
|
+ "query": {
|
|
|
+ "bool": {
|
|
|
+ "must": [
|
|
|
+ {
|
|
|
+ "match_all": {}
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ },
|
|
|
+ "runtime_mappings": {
|
|
|
+ "hour_of_day": {
|
|
|
+ "type": "long",
|
|
|
+ "script": {
|
|
|
+ "source": "emit(doc['timestamp'].value.getHour());"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ "datafeed_id": "datafeed-test-job1"
|
|
|
}
|
|
|
}
|
|
|
--------------------------------------------------
|
|
|
+// TEST[skip:setup Kibana sample data]
|
|
|
|
|
|
-When the job is created, you receive the following results:
|
|
|
+The API returns the following results:
|
|
|
|
|
|
-[source,console-result]
|
|
|
+[source,js]
|
|
|
----
|
|
|
{
|
|
|
- "job_id" : "total-requests",
|
|
|
+ "job_id" : "test-job1",
|
|
|
"job_type" : "anomaly_detector",
|
|
|
- "job_version" : "8.0.0",
|
|
|
- "description" : "Total sum of requests",
|
|
|
- "create_time" : 1562352500629,
|
|
|
+ "job_version" : "8.4.0",
|
|
|
+ "create_time" : 1656087283340,
|
|
|
+ "datafeed_config" : {
|
|
|
+ "datafeed_id" : "datafeed-test-job1",
|
|
|
+ "job_id" : "test-job1",
|
|
|
+ "authorization" : {
|
|
|
+ "roles" : [
|
|
|
+ "superuser"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ "query_delay" : "61499ms",
|
|
|
+ "chunking_config" : {
|
|
|
+ "mode" : "auto"
|
|
|
+ },
|
|
|
+ "indices_options" : {
|
|
|
+ "expand_wildcards" : [
|
|
|
+ "open"
|
|
|
+ ],
|
|
|
+ "ignore_unavailable" : false,
|
|
|
+ "allow_no_indices" : true,
|
|
|
+ "ignore_throttled" : true
|
|
|
+ },
|
|
|
+ "query" : {
|
|
|
+ "bool" : {
|
|
|
+ "must" : [
|
|
|
+ {
|
|
|
+ "match_all" : { }
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ },
|
|
|
+ "indices" : [
|
|
|
+ "kibana_sample_data_logs"
|
|
|
+ ],
|
|
|
+ "scroll_size" : 1000,
|
|
|
+ "delayed_data_check_config" : {
|
|
|
+ "enabled" : true
|
|
|
+ },
|
|
|
+ "runtime_mappings" : {
|
|
|
+ "hour_of_day" : {
|
|
|
+ "type" : "long",
|
|
|
+ "script" : {
|
|
|
+ "source" : "emit(doc['timestamp'].value.getHour());"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
"analysis_config" : {
|
|
|
- "bucket_span" : "10m",
|
|
|
+ "bucket_span" : "15m",
|
|
|
"detectors" : [
|
|
|
{
|
|
|
- "detector_description" : "Sum of total",
|
|
|
+ "detector_description" : "Sum of bytes",
|
|
|
"function" : "sum",
|
|
|
- "field_name" : "total",
|
|
|
+ "field_name" : "bytes",
|
|
|
"detector_index" : 0
|
|
|
}
|
|
|
],
|
|
|
"influencers" : [ ],
|
|
|
- "model_prune_window": "30d"
|
|
|
+ "model_prune_window" : "30d"
|
|
|
},
|
|
|
"analysis_limits" : {
|
|
|
- "model_memory_limit" : "1024mb",
|
|
|
+ "model_memory_limit" : "11mb",
|
|
|
"categorization_examples_limit" : 4
|
|
|
},
|
|
|
"data_description" : {
|
|
|
"time_field" : "timestamp",
|
|
|
"time_format" : "epoch_ms"
|
|
|
},
|
|
|
+ "model_plot_config" : {
|
|
|
+ "enabled" : true,
|
|
|
+ "annotations_enabled" : true
|
|
|
+ },
|
|
|
"model_snapshot_retention_days" : 10,
|
|
|
"daily_model_snapshot_retention_after_days" : 1,
|
|
|
- "results_index_name" : "shared",
|
|
|
+ "results_index_name" : "custom-test-job1",
|
|
|
"allow_lazy_open" : false
|
|
|
}
|
|
|
----
|
|
|
-// TESTRESPONSE[s/"job_version" : "8.0.0"/"job_version" : $body.job_version/]
|
|
|
-// TESTRESPONSE[s/1562352500629/$body.$_path/]
|
|
|
+// TESTRESPONSE[s/"job_version" : "8.4.0"/"job_version" : $body.job_version/]
|
|
|
+// TESTRESPONSE[s/1656087283340/$body.$_path/]
|