Skip to content

Commit

Permalink
[DOCS] Moves machine learning APIs to docs folder (#31118)
Browse files Browse the repository at this point in the history
  • Loading branch information
lcawl committed Sep 1, 2018
1 parent 052b04d commit 4151bd2
Show file tree
Hide file tree
Showing 56 changed files with 409 additions and 174 deletions.
235 changes: 233 additions & 2 deletions docs/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,20 @@

apply plugin: 'elasticsearch.docs-test'

/* List of files that have snippets that require a gold or platinum licence
and therefore cannot be tested yet... */
/* List of files that have snippets that will not work until platinum tests can occur ... */
buildRestTests.expectedUnconvertedCandidates = [
'reference/ml/transforms.asciidoc',
'reference/ml/apis/delete-calendar-event.asciidoc',
'reference/ml/apis/get-bucket.asciidoc',
'reference/ml/apis/get-category.asciidoc',
'reference/ml/apis/get-influencer.asciidoc',
'reference/ml/apis/get-job-stats.asciidoc',
'reference/ml/apis/get-overall-buckets.asciidoc',
'reference/ml/apis/get-record.asciidoc',
'reference/ml/apis/get-snapshot.asciidoc',
'reference/ml/apis/post-data.asciidoc',
'reference/ml/apis/revert-snapshot.asciidoc',
'reference/ml/apis/update-snapshot.asciidoc',
]

integTestCluster {
Expand Down Expand Up @@ -856,3 +866,224 @@ buildRestTests.setups['sensor_prefab_data'] = '''
{"node.terms.value":"c","temperature.sum.value":202.0,"temperature.max.value":202.0,"timestamp.date_histogram.time_zone":"UTC","temperature.min.value":202.0,"timestamp.date_histogram._count":1,"timestamp.date_histogram.interval":"1h","_rollup.computed":["temperature.sum","temperature.min","voltage.avg","temperature.max","node.terms","timestamp.date_histogram"],"voltage.avg.value":4.0,"node.terms._count":1,"_rollup.version":1,"timestamp.date_histogram.timestamp":1516294800000,"voltage.avg._count":1.0,"_rollup.id":"sensor"}
'''
buildRestTests.setups['sample_job'] = '''
- do:
xpack.ml.put_job:
job_id: "sample_job"
body: >
{
"description" : "Very basic job",
"analysis_config" : {
"bucket_span":"10m",
"detectors" :[
{
"function": "count"
}
]},
"data_description" : {
"time_field":"timestamp",
"time_format": "epoch_ms"
}
}
'''
buildRestTests.setups['farequote_index'] = '''
- do:
indices.create:
index: farequote
body:
settings:
number_of_shards: 1
number_of_replicas: 0
mappings:
metric:
properties:
time:
type: date
responsetime:
type: float
airline:
type: keyword
doc_count:
type: integer
'''
buildRestTests.setups['farequote_data'] = buildRestTests.setups['farequote_index'] + '''
- do:
bulk:
index: farequote
type: metric
refresh: true
body: |
{"index": {"_id":"1"}}
{"airline":"JZA","responsetime":990.4628,"time":"2016-02-07T00:00:00+0000", "doc_count": 5}
{"index": {"_id":"2"}}
{"airline":"JBU","responsetime":877.5927,"time":"2016-02-07T00:00:00+0000", "doc_count": 23}
{"index": {"_id":"3"}}
{"airline":"KLM","responsetime":1355.4812,"time":"2016-02-07T00:00:00+0000", "doc_count": 42}
'''
buildRestTests.setups['farequote_job'] = buildRestTests.setups['farequote_data'] + '''
- do:
xpack.ml.put_job:
job_id: "farequote"
body: >
{
"analysis_config": {
"bucket_span": "60m",
"detectors": [{
"function": "mean",
"field_name": "responsetime",
"by_field_name": "airline"
}],
"summary_count_field_name": "doc_count"
},
"data_description": {
"time_field": "time"
}
}
'''
buildRestTests.setups['farequote_datafeed'] = buildRestTests.setups['farequote_job'] + '''
- do:
xpack.ml.put_datafeed:
datafeed_id: "datafeed-farequote"
body: >
{
"job_id":"farequote",
"indexes":"farequote"
}
'''
buildRestTests.setups['server_metrics_index'] = '''
- do:
indices.create:
index: server-metrics
body:
settings:
number_of_shards: 1
number_of_replicas: 0
mappings:
metric:
properties:
timestamp:
type: date
total:
type: long
'''
buildRestTests.setups['server_metrics_data'] = buildRestTests.setups['server_metrics_index'] + '''
- do:
bulk:
index: server-metrics
type: metric
refresh: true
body: |
{"index": {"_id":"1177"}}
{"timestamp":"2017-03-23T13:00:00","total":40476}
{"index": {"_id":"1178"}}
{"timestamp":"2017-03-23T13:00:00","total":15287}
{"index": {"_id":"1179"}}
{"timestamp":"2017-03-23T13:00:00","total":-776}
{"index": {"_id":"1180"}}
{"timestamp":"2017-03-23T13:00:00","total":11366}
{"index": {"_id":"1181"}}
{"timestamp":"2017-03-23T13:00:00","total":3606}
{"index": {"_id":"1182"}}
{"timestamp":"2017-03-23T13:00:00","total":19006}
{"index": {"_id":"1183"}}
{"timestamp":"2017-03-23T13:00:00","total":38613}
{"index": {"_id":"1184"}}
{"timestamp":"2017-03-23T13:00:00","total":19516}
{"index": {"_id":"1185"}}
{"timestamp":"2017-03-23T13:00:00","total":-258}
{"index": {"_id":"1186"}}
{"timestamp":"2017-03-23T13:00:00","total":9551}
{"index": {"_id":"1187"}}
{"timestamp":"2017-03-23T13:00:00","total":11217}
{"index": {"_id":"1188"}}
{"timestamp":"2017-03-23T13:00:00","total":22557}
{"index": {"_id":"1189"}}
{"timestamp":"2017-03-23T13:00:00","total":40508}
{"index": {"_id":"1190"}}
{"timestamp":"2017-03-23T13:00:00","total":11887}
{"index": {"_id":"1191"}}
{"timestamp":"2017-03-23T13:00:00","total":31659}
'''
buildRestTests.setups['server_metrics_job'] = buildRestTests.setups['server_metrics_data'] + '''
- do:
xpack.ml.put_job:
job_id: "total-requests"
body: >
{
"description" : "Total sum of requests",
"analysis_config" : {
"bucket_span":"10m",
"detectors" :[
{
"detector_description": "Sum of total",
"function": "sum",
"field_name": "total"
}
]},
"data_description" : {
"time_field":"timestamp",
"time_format": "epoch_ms"
}
}
'''
buildRestTests.setups['server_metrics_datafeed'] = buildRestTests.setups['server_metrics_job'] + '''
- do:
xpack.ml.put_datafeed:
datafeed_id: "datafeed-total-requests"
body: >
{
"job_id":"total-requests",
"indexes":"server-metrics"
}
'''
buildRestTests.setups['server_metrics_openjob'] = buildRestTests.setups['server_metrics_datafeed'] + '''
- do:
xpack.ml.open_job:
job_id: "total-requests"
'''
buildRestTests.setups['server_metrics_startdf'] = buildRestTests.setups['server_metrics_openjob'] + '''
- do:
xpack.ml.start_datafeed:
datafeed_id: "datafeed-total-requests"
'''
buildRestTests.setups['calendar_outages'] = '''
- do:
xpack.ml.put_calendar:
calendar_id: "planned-outages"
'''
buildRestTests.setups['calendar_outages_addevent'] = buildRestTests.setups['calendar_outages'] + '''
- do:
xpack.ml.post_calendar_events:
calendar_id: "planned-outages"
body: >
{ "description": "event 1", "start_time": "2017-12-01T00:00:00Z", "end_time": "2017-12-02T00:00:00Z", "calendar_id": "planned-outages" }
'''
buildRestTests.setups['calendar_outages_openjob'] = buildRestTests.setups['server_metrics_openjob'] + '''
- do:
xpack.ml.put_calendar:
calendar_id: "planned-outages"
'''
buildRestTests.setups['calendar_outages_addjob'] = buildRestTests.setups['server_metrics_openjob'] + '''
- do:
xpack.ml.put_calendar:
calendar_id: "planned-outages"
body: >
{
"job_ids": ["total-requests"]
}
'''
buildRestTests.setups['calendar_outages_addevent'] = buildRestTests.setups['calendar_outages_addjob'] + '''
- do:
xpack.ml.post_calendar_events:
calendar_id: "planned-outages"
body: >
{ "events" : [
{ "description": "event 1", "start_time": "1513641600000", "end_time": "1513728000000"},
{ "description": "event 2", "start_time": "1513814400000", "end_time": "1513900800000"},
{ "description": "event 3", "start_time": "1514160000000", "end_time": "1514246400000"}
]}
'''


Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[role="xpack"]
[testenv="platinum"]
[[ml-calendar-resource]]
=== Calendar Resources

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[role="xpack"]
[testenv="platinum"]
[[ml-close-job]]
=== Close Jobs API
++++
Expand Down Expand Up @@ -80,7 +81,7 @@ The following example closes the `total-requests` job:
POST _xpack/ml/anomaly_detectors/total-requests/_close
--------------------------------------------------
// CONSOLE
// TEST[setup:server_metrics_openjob]
// TEST[skip:setup:server_metrics_openjob]

When the job is closed, you receive the following results:
[source,js]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[role="xpack"]
[testenv="platinum"]
[[ml-datafeed-resource]]
=== {dfeed-cap} Resources

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[role="xpack"]
[testenv="platinum"]
[[ml-delete-calendar-event]]
=== Delete Events from Calendar API
++++
Expand Down Expand Up @@ -44,7 +45,7 @@ calendar:
DELETE _xpack/ml/calendars/planned-outages/events/LS8LJGEBMTCMA-qz49st
--------------------------------------------------
// CONSOLE
// TEST[catch:missing]
// TEST[skip:catch:missing]

When the event is removed, you receive the following results:
[source,js]
Expand All @@ -53,4 +54,3 @@ When the event is removed, you receive the following results:
"acknowledged": true
}
----
// NOTCONSOLE
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[role="xpack"]
[testenv="platinum"]
[[ml-delete-calendar-job]]
=== Delete Jobs from Calendar API
++++
Expand Down Expand Up @@ -38,7 +39,7 @@ calendar and `total-requests` job:
DELETE _xpack/ml/calendars/planned-outages/jobs/total-requests
--------------------------------------------------
// CONSOLE
// TEST[setup:calendar_outages_addjob]
// TEST[skip:setup:calendar_outages_addjob]

When the job is removed from the calendar, you receive the following
results:
Expand All @@ -50,4 +51,4 @@ results:
"job_ids": []
}
----
//TESTRESPONSE
// TESTRESPONSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[role="xpack"]
[testenv="platinum"]
[[ml-delete-calendar]]
=== Delete Calendar API
++++
Expand Down Expand Up @@ -40,7 +41,7 @@ The following example deletes the `planned-outages` calendar:
DELETE _xpack/ml/calendars/planned-outages
--------------------------------------------------
// CONSOLE
// TEST[setup:calendar_outages]
// TEST[skip:setup:calendar_outages]

When the calendar is deleted, you receive the following results:
[source,js]
Expand All @@ -49,4 +50,4 @@ When the calendar is deleted, you receive the following results:
"acknowledged": true
}
----
//TESTRESPONSE
// TESTRESPONSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[role="xpack"]
[testenv="platinum"]
[[ml-delete-datafeed]]
=== Delete {dfeeds-cap} API
++++
Expand Down Expand Up @@ -47,7 +48,7 @@ The following example deletes the `datafeed-total-requests` {dfeed}:
DELETE _xpack/ml/datafeeds/datafeed-total-requests
--------------------------------------------------
// CONSOLE
// TEST[setup:server_metrics_datafeed]
// TEST[skip:setup:server_metrics_datafeed]

When the {dfeed} is deleted, you receive the following results:
[source,js]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[role="xpack"]
[testenv="platinum"]
[[ml-delete-filter]]
=== Delete Filter API
++++
Expand Down Expand Up @@ -41,7 +42,7 @@ The following example deletes the `safe_domains` filter:
DELETE _xpack/ml/filters/safe_domains
--------------------------------------------------
// CONSOLE
// TEST[setup:ml_filter_safe_domains]
// TEST[skip:setup:ml_filter_safe_domains]

When the filter is deleted, you receive the following results:
[source,js]
Expand All @@ -50,4 +51,4 @@ When the filter is deleted, you receive the following results:
"acknowledged": true
}
----
//TESTRESPONSE
// TESTRESPONSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[role="xpack"]
[testenv="platinum"]
[[ml-delete-job]]
=== Delete Jobs API
++++
Expand Down Expand Up @@ -56,7 +57,7 @@ The following example deletes the `total-requests` job:
DELETE _xpack/ml/anomaly_detectors/total-requests
--------------------------------------------------
// CONSOLE
// TEST[setup:server_metrics_job]
// TEST[skip:setup:server_metrics_job]

When the job is deleted, you receive the following results:
[source,js]
Expand All @@ -65,4 +66,4 @@ When the job is deleted, you receive the following results:
"acknowledged": true
}
----
// TESTRESPONSE
// TESTRESPONSE
Loading

0 comments on commit 4151bd2

Please sign in to comment.