Skip to content

Commit

Permalink
[DOCS] Re-enable code snippet testing in close anomaly detection job …
Browse files Browse the repository at this point in the history
…API (#48259) (#48585)
  • Loading branch information
lcawl authored Oct 28, 2019
1 parent 1ba57db commit 13ce179
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 7 deletions.
51 changes: 45 additions & 6 deletions docs/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -972,12 +972,11 @@ buildRestTests.setups['server_metrics_index'] = '''
number_of_shards: 1
number_of_replicas: 0
mappings:
metric:
properties:
timestamp:
type: date
total:
type: long
properties:
timestamp:
type: date
total:
type: long
'''
buildRestTests.setups['server_metrics_data'] = buildRestTests.setups['server_metrics_index'] + '''
- do:
Expand Down Expand Up @@ -1039,6 +1038,29 @@ buildRestTests.setups['server_metrics_job'] = buildRestTests.setups['server_metr
}
}
'''
buildRestTests.setups['server_metrics_job-raw'] = buildRestTests.setups['server_metrics_data'] + '''
- do:
raw:
method: PUT
path: _ml/anomaly_detectors/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:
ml.put_datafeed:
Expand All @@ -1049,11 +1071,28 @@ buildRestTests.setups['server_metrics_datafeed'] = buildRestTests.setups['server
"indexes":"server-metrics"
}
'''
buildRestTests.setups['server_metrics_datafeed-raw'] = buildRestTests.setups['server_metrics_job-raw'] + '''
- do:
raw:
method: PUT
path: _ml/datafeeds/datafeed-total-requests
body: >
{
"job_id":"total-requests",
"indexes":"server-metrics"
}
'''
buildRestTests.setups['server_metrics_openjob'] = buildRestTests.setups['server_metrics_datafeed'] + '''
- do:
ml.open_job:
job_id: "total-requests"
'''
buildRestTests.setups['server_metrics_openjob-raw'] = buildRestTests.setups['server_metrics_datafeed-raw'] + '''
- do:
raw:
method: POST
path: _ml/anomaly_detectors/total-requests/_open
'''
buildRestTests.setups['server_metrics_startdf'] = buildRestTests.setups['server_metrics_openjob'] + '''
- do:
ml.start_datafeed:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ The following example closes the `total-requests` job:
--------------------------------------------------
POST _ml/anomaly_detectors/total-requests/_close
--------------------------------------------------
// TEST[skip:setup:server_metrics_openjob]
// TEST[setup:server_metrics_openjob-raw]

When the job is closed, you receive the following results:

Expand Down

0 comments on commit 13ce179

Please sign in to comment.