[DOCS] Enabled code snippet testing for more ML APIs (elastic/x-pack-elasticsearch#3990)

Original commit: elastic/x-pack-elasticsearch@1b631adff6
This commit is contained in:
Lisa Cawley 2018-02-20 11:08:37 -08:00 committed by GitHub
parent e3e82ccb2d
commit e9b4a2d063
5 changed files with 91 additions and 54 deletions

View File

@ -23,8 +23,6 @@ buildRestTests.expectedUnconvertedCandidates = [
'en/rest-api/security/users.asciidoc',
'en/rest-api/security/tokens.asciidoc',
'en/rest-api/watcher/put-watch.asciidoc',
'en/rest-api/ml/delete-calendar-event.asciidoc',
'en/rest-api/ml/post-data.asciidoc',
'en/security/authentication/user-cache.asciidoc',
'en/security/authorization/field-and-document-access-control.asciidoc',
'en/security/authorization/run-as-privilege.asciidoc',
@ -64,23 +62,21 @@ buildRestTests.expectedUnconvertedCandidates = [
'en/watcher/trigger/schedule/yearly.asciidoc',
'en/watcher/troubleshooting.asciidoc',
'en/ml/api-quickref.asciidoc',
'en/rest-api/ml/delete-calendar-event.asciidoc',
'en/rest-api/ml/delete-snapshot.asciidoc',
'en/rest-api/ml/forecast.asciidoc',
'en/rest-api/ml/get-bucket.asciidoc',
'en/rest-api/ml/get-job-stats.asciidoc',
'en/rest-api/ml/get-overall-buckets.asciidoc',
'en/rest-api/ml/get-category.asciidoc',
'en/rest-api/ml/get-datafeed-stats.asciidoc',
'en/rest-api/ml/get-job-stats.asciidoc',
'en/rest-api/ml/get-record.asciidoc',
'en/rest-api/ml/preview-datafeed.asciidoc',
'en/rest-api/ml/update-datafeed.asciidoc',
'en/rest-api/ml/update-job.asciidoc',
'en/rest-api/ml/update-snapshot.asciidoc',
'en/rest-api/ml/validate-detector.asciidoc',
'en/rest-api/ml/get-datafeed.asciidoc',
'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/ml/validate-detector.asciidoc',
'en/rest-api/ml/validate-job.asciidoc',
'en/rest-api/security/authenticate.asciidoc',
'en/rest-api/watcher/stats.asciidoc',
@ -296,7 +292,45 @@ setups['server_metrics_index'] = '''
total:
type: long
'''
setups['server_metrics_job'] = setups['server_metrics_index'] + '''
setups['server_metrics_data'] = 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}
'''
setups['server_metrics_job'] = setups['server_metrics_data'] + '''
- do:
xpack.ml.put_job:
job_id: "total-requests"

View File

@ -59,14 +59,14 @@ privileges to use this API. For more information, see
==== Examples
The following example gets usage information for the
`datafeed-farequote` {dfeed}:
`datafeed-total-requests` {dfeed}:
[source,js]
--------------------------------------------------
GET _xpack/ml/datafeeds/datafeed-farequote/_stats
GET _xpack/ml/datafeeds/datafeed-total-requests/_stats
--------------------------------------------------
// CONSOLE
// TEST[skip:todo]
// TEST[setup:server_metrics_startdf]
The API returns the following results:
[source,js]
@ -75,14 +75,16 @@ The API returns the following results:
"count": 1,
"datafeeds": [
{
"datafeed_id": "datafeed-farequote",
"datafeed_id": "datafeed-total-requests",
"state": "started",
"node": {
"id": "IO_gxe2_S8mrzu7OpmK5Jw",
"name": "IO_gxe2",
"ephemeral_id": "KHMWPZoMToOzSsZY9lDDgQ",
"id": "2spCyo1pRi2Ajo-j-_dnPX",
"name": "node-0",
"ephemeral_id": "hoXMLZB0RWKfR9UPPUCxXX",
"transport_address": "127.0.0.1:9300",
"attributes": {
"ml.machine_memory": "17179869184",
"ml.max_open_jobs": "20",
"ml.enabled": "true"
}
},
@ -91,3 +93,7 @@ The API returns the following results:
]
}
----
// TESTRESPONSE[s/"2spCyo1pRi2Ajo-j-_dnPX"/$body.$_path/]
// TESTRESPONSE[s/"node-0"/$body.$_path/]
// TESTRESPONSE[s/"hoXMLZB0RWKfR9UPPUCxXX"/$body.$_path/]
// TESTRESPONSE[s/"127.0.0.1:9300"/$body.$_path/]

View File

@ -53,14 +53,14 @@ privileges to use this API. For more information, see
==== Examples
The following example gets configuration information for the
`datafeed-it-ops-kpi` {dfeed}:
`datafeed-total-requests` {dfeed}:
[source,js]
--------------------------------------------------
GET _xpack/ml/datafeeds/datafeed-it-ops-kpi
GET _xpack/ml/datafeeds/datafeed-total-requests
--------------------------------------------------
// CONSOLE
// TEST[skip:todo]
// TEST[setup:server_metrics_datafeed]
The API returns the following results:
[source,js]
@ -69,21 +69,18 @@ The API returns the following results:
"count": 1,
"datafeeds": [
{
"datafeed_id": "datafeed-it-ops-kpi",
"job_id": "it-ops-kpi",
"query_delay": "60s",
"frequency": "150s",
"datafeed_id": "datafeed-total-requests",
"job_id": "total-requests",
"query_delay": "83474ms",
"indices": [
"it_ops_metrics"
"server-metrics"
],
"types": [
"kpi",
"network",
"sql"
"metric"
],
"query": {
"match_all": {
"boost": 1
"boost": 1.0
}
},
"scroll_size": 1000,
@ -94,3 +91,4 @@ The API returns the following results:
]
}
----
// TESTRESPONSE[s/"query.boost": "1.0"/"query.boost": $body.query.boost/]

View File

@ -80,7 +80,6 @@ see <<ml-datafeed-resource>>.
You must have `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
@ -91,12 +90,12 @@ updated it had at the time of update, and run the query using those same roles.
==== Examples
The following example updates the query for the `datafeed-it-ops-kpi` {dfeed}
so that only log entries of error level are analyzed:
The following example updates the query for the `datafeed-total-requests`
{dfeed} so that only log entries of error level are analyzed:
[source,js]
--------------------------------------------------
POST _xpack/ml/datafeeds/datafeed-it-ops-kpi/_update
POST _xpack/ml/datafeeds/datafeed-total-requests/_update
{
"query": {
"term": {
@ -106,7 +105,7 @@ POST _xpack/ml/datafeeds/datafeed-it-ops-kpi/_update
}
--------------------------------------------------
// CONSOLE
// TEST[skip:todo]
// TEST[setup:server_metrics_datafeed]
When the {dfeed} is updated, you receive the full {dfeed} configuration with
with the updated values:
@ -114,16 +113,16 @@ with the updated values:
[source,js]
----
{
"datafeed_id": "datafeed-it-ops-kpi",
"job_id": "it-ops-kpi",
"query_delay": "1m",
"indices": ["it-ops"],
"types": ["logs"],
"datafeed_id": "datafeed-total-requests",
"job_id": "total-requests",
"query_delay": "83474ms",
"indices": ["server-metrics"],
"types": ["metric"],
"query": {
"term": {
"level": {
"value": "error",
"boost": 1
"boost": 1.0
}
}
},
@ -133,3 +132,4 @@ with the updated values:
}
}
----
// TESTRESPONSE[s/"query.boost": "1.0"/"query.boost": $body.query.boost/]

View File

@ -79,16 +79,15 @@ want to re-run this job with an increased `model_memory_limit`.
You must have `manage_ml`, or `manage` cluster privileges to use this API.
For more information, see
{xpack-ref}/security-privileges.html[Security Privileges].
//<<privileges-list-cluster>>.
==== Examples
The following example updates the `it_ops_new_logs` job:
The following example updates the `total-requests` job:
[source,js]
--------------------------------------------------
POST _xpack/ml/anomaly_detectors/it_ops_new_logs/_update
POST _xpack/ml/anomaly_detectors/total-requests/_update
{
"description":"An updated job",
"groups": ["group1","group2"],
@ -111,7 +110,7 @@ POST _xpack/ml/anomaly_detectors/it_ops_new_logs/_update
}
--------------------------------------------------
// CONSOLE
// TEST[skip:todo]
// TEST[setup:server_metrics_job]
When the job is updated, you receive a summary of the job configuration
information, including the updated property values. For example:
@ -119,7 +118,7 @@ information, including the updated property values. For example:
[source,js]
----
{
"job_id": "it_ops_new_logs",
"job_id": "total-requests",
"job_type": "anomaly_detector",
"job_version": "7.0.0-alpha1",
"groups": [
@ -127,15 +126,14 @@ information, including the updated property values. For example:
"group2"
],
"description": "An updated job",
"create_time": 1502904685360,
"create_time": 1518808660505,
"analysis_config": {
"bucket_span": "1800s",
"categorization_field_name": "message",
"bucket_span": "10m",
"detectors": [
{
"detector_description": "Unusual message counts",
"function": "count",
"by_field_name": "mlcategory",
"detector_description": "Sum of total",
"function": "sum",
"field_name": "total",
"rules": [],
"detector_index": 0
}
@ -146,7 +144,7 @@ information, including the updated property values. For example:
"model_memory_limit": "1024mb"
},
"data_description": {
"time_field": "time",
"time_field": "timestamp",
"time_format": "epoch_ms"
},
"model_plot_config": {
@ -164,7 +162,8 @@ information, including the updated property values. For example:
}
]
},
"model_snapshot_id": "1493678315",
"results_index_name": "shared"
}
----
// TESTRESPONSE[s/"job_version": "7.0.0-alpha1"/"job_version": $body.job_version/]
// TESTRESPONSE[s/"create_time": 1518808660505/"create_time": $body.create_time/]