mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-03-25 09:28:27 +00:00
[DOCS] Enabled code snippet testing for datafeed APIs (elastic/x-pack-elasticsearch#2811)
* [DOCS] Enabled code snippet testing for put datafeed API * [DOCS] Addressed gradle errors in put datafeed API * [DOCS] Added job creation test to build.gradle Original commit: elastic/x-pack-elasticsearch@3548d920c7
This commit is contained in:
parent
c335b00c9b
commit
f69f6cd341
@ -76,7 +76,6 @@ buildRestTests.expectedUnconvertedCandidates = [
|
||||
'en/rest-api/ml/get-record.asciidoc',
|
||||
'en/rest-api/ml/open-job.asciidoc',
|
||||
'en/rest-api/ml/preview-datafeed.asciidoc',
|
||||
'en/rest-api/ml/put-datafeed.asciidoc',
|
||||
'en/rest-api/ml/start-datafeed.asciidoc',
|
||||
'en/rest-api/ml/stop-datafeed.asciidoc',
|
||||
'en/rest-api/ml/update-datafeed.asciidoc',
|
||||
@ -200,3 +199,55 @@ setups['my_inactive_watch'] = '''
|
||||
'''
|
||||
setups['my_active_watch'] = setups['my_inactive_watch'].replace(
|
||||
'active: false', 'active: true')
|
||||
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
|
||||
'''
|
||||
setups['server_metrics_job'] = '''
|
||||
- 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
|
||||
- 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"
|
||||
}
|
||||
}
|
||||
'''
|
||||
|
@ -86,43 +86,37 @@ For more information, see
|
||||
|
||||
==== Examples
|
||||
|
||||
The following example creates the `datafeed-it-ops-kpi` {dfeed}:
|
||||
The following example creates the `datafeed-total-requests` {dfeed}:
|
||||
|
||||
[source,js]
|
||||
--------------------------------------------------
|
||||
PUT _xpack/ml/datafeeds/datafeed-it-ops-kpi
|
||||
PUT _xpack/ml/datafeeds/datafeed-total-requests
|
||||
{
|
||||
"job_id": "it-ops-kpi",
|
||||
"indices": ["it_ops_metrics"],
|
||||
"types": ["kpi","network","sql"],
|
||||
"query": {
|
||||
"match_all": {
|
||||
"boost": 1
|
||||
}
|
||||
}
|
||||
"job_id": "total-requests",
|
||||
"indices": ["server-metrics"],
|
||||
"types": ["metric"],
|
||||
"scroll_size": 1000
|
||||
}
|
||||
--------------------------------------------------
|
||||
// CONSOLE
|
||||
// TEST[skip:todo]
|
||||
// TEST[setup:server_metrics_job]
|
||||
|
||||
When the {dfeed} is created, you receive the following results:
|
||||
[source,js]
|
||||
----
|
||||
{
|
||||
"datafeed_id": "datafeed-it-ops-kpi",
|
||||
"job_id": "it-ops-kpi",
|
||||
"query_delay": "1m",
|
||||
"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,
|
||||
@ -131,3 +125,4 @@ When the {dfeed} is created, you receive the following results:
|
||||
}
|
||||
}
|
||||
----
|
||||
//TESTRESPONSE[s/"query_delay": "83474ms"/"query_delay": $body.query_delay/]
|
||||
|
Loading…
x
Reference in New Issue
Block a user