Skip to content

Commit

Permalink
[DOCS] Adds test for ML preview API
Browse files Browse the repository at this point in the history
  • Loading branch information
lcawl committed Jun 20, 2018
1 parent 32394ce commit 0353a8c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 17 deletions.
21 changes: 16 additions & 5 deletions x-pack/docs/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ buildRestTests.expectedUnconvertedCandidates = [
'en/rest-api/ml/get-influencer.asciidoc',
'en/rest-api/ml/get-snapshot.asciidoc',
'en/rest-api/ml/post-data.asciidoc',
'en/rest-api/ml/preview-datafeed.asciidoc',
'en/rest-api/ml/revert-snapshot.asciidoc',
'en/rest-api/ml/update-snapshot.asciidoc',
'en/rest-api/watcher/stats.asciidoc',
Expand Down Expand Up @@ -296,7 +295,9 @@ setups['farequote_index'] = '''
responsetime:
type: float
airline:
type: keyword
type: keyword
doc_count:
type: integer
'''
setups['farequote_data'] = setups['farequote_index'] + '''
- do:
Expand All @@ -306,11 +307,11 @@ setups['farequote_data'] = setups['farequote_index'] + '''
refresh: true
body: |
{"index": {"_id":"1"}}
{"airline":"JZA","responsetime":990.4628,"time":"2016-02-07T00:00:00+0000"}
{"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"}
{"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"}
{"airline":"KLM","responsetime":1355.4812,"time":"2016-02-07T00:00:00+0000", "doc_count": "42"}
'''
setups['farequote_job'] = setups['farequote_data'] + '''
- do:
Expand All @@ -332,6 +333,16 @@ setups['farequote_job'] = setups['farequote_data'] + '''
}
}
'''
setups['farequote_datafeed'] = setups['farequote_job'] + '''
- do:
xpack.ml.put_datafeed:
datafeed_id: "datafeed-farequote"
body: >
{
"job_id":"farequote",
"indexes":"farequote"
}
'''
setups['server_metrics_index'] = '''
- do:
indices.create:
Expand Down
4 changes: 2 additions & 2 deletions x-pack/docs/en/rest-api/ml/forecast.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ POST _xpack/ml/anomaly_detectors/total-requests/_forecast
}
--------------------------------------------------
// CONSOLE
// TEST[setup:server_metrics_openjob]
// TEST[skip:requires delay]

When the forecast is created, you receive the following results:
[source,js]
Expand All @@ -72,7 +72,7 @@ When the forecast is created, you receive the following results:
"forecast_id": "wkCWa2IB2lF8nSE_TzZo"
}
----
// TESTRESPONSE[s/"forecast_id": "wkCWa2IB2lF8nSE_TzZo"/"forecast_id": $body.forecast_id/]
// NOTCONSOLE

You can subsequently see the forecast in the *Single Metric Viewer* in {kib}.

22 changes: 12 additions & 10 deletions x-pack/docs/en/rest-api/ml/preview-datafeed.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ structure of the data that will be passed to the anomaly detection engine.
You must have `monitor_ml`, `monitor`, `manage_ml`, or `manage` cluster
privileges to use this API. For more information, see
{xpack-ref}/security-privileges.html[Security Privileges].
//<<privileges-list-cluster>>.


==== Security Integration
Expand All @@ -54,27 +53,30 @@ The following example obtains a preview of the `datafeed-farequote` {dfeed}:
GET _xpack/ml/datafeeds/datafeed-farequote/_preview
--------------------------------------------------
// CONSOLE
// TEST[skip:todo]
// TEST[setup:farequote_datafeed]

The data that is returned for this example is as follows:
[source,js]
----
[
{
"@timestamp": 1454803200000,
"airline": "AAL",
"responsetime": 132.20460510253906
},
{
"@timestamp": 1454803200000,
"time": 1454803200000,
"airline": "JZA",
"doc_count": 5,
"responsetime": 990.4628295898438
},
{
"@timestamp": 1454803200000,
"time": 1454803200000,
"airline": "JBU",
"doc_count": 23,
"responsetime": 877.5927124023438
},
...
{
"time": 1454803200000,
"airline": "KLM",
"doc_count": 42,
"responsetime": 1355.481201171875
}
]
----
// TESTRESPONSE

0 comments on commit 0353a8c

Please sign in to comment.