2018-02-23 17:10:37 -05:00
|
|
|
[role="xpack"]
|
2018-08-31 13:50:43 -04:00
|
|
|
[testenv="basic"]
|
2018-02-23 17:10:37 -05:00
|
|
|
[[rollup-put-job]]
|
2019-07-10 18:12:32 -04:00
|
|
|
=== Create {rollup-jobs} API
|
|
|
|
[subs="attributes"]
|
2018-02-23 17:10:37 -05:00
|
|
|
++++
|
2019-07-10 18:12:32 -04:00
|
|
|
<titleabbrev>Create {rollup-jobs}</titleabbrev>
|
2018-02-23 17:10:37 -05:00
|
|
|
++++
|
|
|
|
|
2019-07-10 18:12:32 -04:00
|
|
|
Creates a {rollup-job}.
|
2018-06-13 15:42:20 -04:00
|
|
|
|
2019-07-10 18:12:32 -04:00
|
|
|
experimental[]
|
2018-02-23 17:10:37 -05:00
|
|
|
|
2019-07-10 18:12:32 -04:00
|
|
|
[[sample-api-request]]
|
|
|
|
==== {api-request-title}
|
2018-02-23 17:10:37 -05:00
|
|
|
|
2018-12-11 19:43:17 -05:00
|
|
|
`PUT _rollup/job/<job_id>`
|
2018-02-23 17:10:37 -05:00
|
|
|
|
2019-07-10 18:12:32 -04:00
|
|
|
[[sample-api-prereqs]]
|
|
|
|
==== {api-prereq-title}
|
2018-02-23 17:10:37 -05:00
|
|
|
|
2019-07-10 18:12:32 -04:00
|
|
|
* If the {es} {security-features} are enabled, you must have `manage` or
|
|
|
|
`manage_rollup` cluster privileges to use this API. For more information, see
|
|
|
|
{stack-ov}/security-privileges.html[Security privileges].
|
2018-02-23 17:10:37 -05:00
|
|
|
|
2019-07-10 18:12:32 -04:00
|
|
|
[[sample-api-desc]]
|
|
|
|
==== {api-description-title}
|
2018-02-23 17:10:37 -05:00
|
|
|
|
2019-07-10 18:12:32 -04:00
|
|
|
Jobs are created in a `STOPPED` state. You can start them with the
|
|
|
|
<<rollup-start-job,start {rollup-jobs} API>>.
|
2018-02-23 17:10:37 -05:00
|
|
|
|
2019-07-10 18:12:32 -04:00
|
|
|
[[sample-api-path-params]]
|
|
|
|
==== {api-path-parms-title}
|
2018-02-23 17:10:37 -05:00
|
|
|
|
2019-07-10 18:12:32 -04:00
|
|
|
`job_id`::
|
2019-07-12 11:26:31 -04:00
|
|
|
(Required, string) Identifier for the {rollup-job}.
|
2018-02-23 17:10:37 -05:00
|
|
|
|
2019-07-10 18:12:32 -04:00
|
|
|
[[sample-api-request-body]]
|
|
|
|
==== {api-request-body-title}
|
2018-02-23 17:10:37 -05:00
|
|
|
|
2019-07-10 18:12:32 -04:00
|
|
|
`cron`::
|
2019-07-12 11:26:31 -04:00
|
|
|
(Required, string) A cron string which defines when the {rollup-job} should be executed.
|
2018-02-23 17:10:37 -05:00
|
|
|
|
2019-07-10 18:12:32 -04:00
|
|
|
`groups`::
|
2019-07-12 11:26:31 -04:00
|
|
|
(Required, object) Defines the grouping fields that are defined for this
|
2019-07-10 18:12:32 -04:00
|
|
|
{rollup-job}. See <<rollup-job-config,{rollup-job} config>>.
|
2018-02-23 17:10:37 -05:00
|
|
|
|
2019-07-10 18:12:32 -04:00
|
|
|
`index_pattern`::
|
2019-07-12 11:26:31 -04:00
|
|
|
(Required, string) The index or index pattern to roll up. Supports
|
2019-07-10 18:12:32 -04:00
|
|
|
wildcard-style patterns (`logstash-*`).
|
2018-02-23 17:10:37 -05:00
|
|
|
|
|
|
|
`metrics`::
|
2019-07-12 11:26:31 -04:00
|
|
|
(Optional, object) Defines the metrics to collect for each grouping tuple. See
|
2019-07-10 18:12:32 -04:00
|
|
|
<<rollup-job-config,{rollup-job} config>>.
|
2018-02-23 17:10:37 -05:00
|
|
|
|
2019-07-10 18:12:32 -04:00
|
|
|
`page_size`::
|
2019-07-12 11:26:31 -04:00
|
|
|
(Required, integer) The number of bucket results that are processed on each
|
2019-07-10 18:12:32 -04:00
|
|
|
iteration of the rollup indexer. A larger value tends to execute faster, but
|
|
|
|
requires more memory during processing.
|
2018-08-29 17:10:00 -04:00
|
|
|
|
2019-07-10 18:12:32 -04:00
|
|
|
`rollup_index`::
|
2019-07-12 11:26:31 -04:00
|
|
|
(Required, string) The index that contains the rollup results. The index can
|
2019-07-10 18:12:32 -04:00
|
|
|
be shared with other {rollup-jobs}.
|
2018-02-23 17:10:37 -05:00
|
|
|
|
2019-07-10 18:12:32 -04:00
|
|
|
For more details about the job configuration, see <<rollup-job-config>>.
|
2018-02-23 17:10:37 -05:00
|
|
|
|
2019-07-10 18:12:32 -04:00
|
|
|
[[sample-api-example]]
|
|
|
|
==== {api-example-title}
|
2018-02-23 17:10:37 -05:00
|
|
|
|
2019-07-10 18:12:32 -04:00
|
|
|
The following example creates a {rollup-job} named "sensor", targeting the
|
|
|
|
"sensor-*" index pattern:
|
2018-02-23 17:10:37 -05:00
|
|
|
|
|
|
|
[source,js]
|
|
|
|
--------------------------------------------------
|
2018-12-11 19:43:17 -05:00
|
|
|
PUT _rollup/job/sensor
|
2018-02-23 17:10:37 -05:00
|
|
|
{
|
|
|
|
"index_pattern": "sensor-*",
|
|
|
|
"rollup_index": "sensor_rollup",
|
|
|
|
"cron": "*/30 * * * * ?",
|
2018-04-10 16:34:40 -04:00
|
|
|
"page_size" :1000,
|
2018-02-23 17:10:37 -05:00
|
|
|
"groups" : {
|
|
|
|
"date_histogram": {
|
|
|
|
"field": "timestamp",
|
[7.x Backport] Force selection of calendar or fixed intervals (#41906)
The date_histogram accepts an interval which can be either a calendar
interval (DST-aware, leap seconds, arbitrary length of months, etc) or
fixed interval (strict multiples of SI units). Unfortunately this is inferred
by first trying to parse as a calendar interval, then falling back to fixed
if that fails.
This leads to confusing arrangement where `1d` == calendar, but
`2d` == fixed. And if you want a day of fixed time, you have to
specify `24h` (e.g. the next smallest unit). This arrangement is very
error-prone for users.
This PR adds `calendar_interval` and `fixed_interval` parameters to any
code that uses intervals (date_histogram, rollup, composite, datafeed, etc).
Calendar only accepts calendar intervals, fixed accepts any combination of
units (meaning `1d` can be used to specify `24h` in fixed time), and both
are mutually exclusive.
The old interval behavior is deprecated and will throw a deprecation warning.
It is also mutually exclusive with the two new parameters. In the future the
old dual-purpose interval will be removed.
The change applies to both REST and java clients.
2019-05-20 12:07:29 -04:00
|
|
|
"fixed_interval": "1h",
|
2018-02-23 17:10:37 -05:00
|
|
|
"delay": "7d"
|
|
|
|
},
|
|
|
|
"terms": {
|
|
|
|
"fields": ["node"]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"metrics": [
|
|
|
|
{
|
|
|
|
"field": "temperature",
|
|
|
|
"metrics": ["min", "max", "sum"]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"field": "voltage",
|
|
|
|
"metrics": ["avg"]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
--------------------------------------------------
|
|
|
|
// CONSOLE
|
2018-04-04 18:32:26 -04:00
|
|
|
// TEST[setup:sensor_index]
|
2018-02-23 17:10:37 -05:00
|
|
|
|
|
|
|
When the job is created, you receive the following results:
|
|
|
|
|
|
|
|
[source,js]
|
|
|
|
----
|
|
|
|
{
|
|
|
|
"acknowledged": true
|
|
|
|
}
|
|
|
|
----
|
2018-10-24 15:25:10 -04:00
|
|
|
// TESTRESPONSE
|