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-get-rollup-caps]]
|
2018-12-20 13:23:28 -05:00
|
|
|
=== Get rollup job capabilities API
|
2018-02-23 17:10:37 -05:00
|
|
|
++++
|
2018-12-20 13:23:28 -05:00
|
|
|
<titleabbrev>Get rollup caps</titleabbrev>
|
2018-02-23 17:10:37 -05:00
|
|
|
++++
|
|
|
|
|
2018-06-13 15:42:20 -04:00
|
|
|
experimental[]
|
|
|
|
|
2019-01-15 11:46:36 -05:00
|
|
|
This API returns the capabilities of any rollup jobs that have been configured
|
|
|
|
for a specific index or index pattern.
|
2018-02-23 17:10:37 -05:00
|
|
|
|
2019-01-15 11:46:36 -05:00
|
|
|
This API is useful because a rollup job is often configured to rollup only a
|
|
|
|
subset of fields from the source index. Furthermore, only certain aggregations
|
|
|
|
can be configured for various fields, leading to a limited subset of
|
|
|
|
functionality depending on that configuration.
|
|
|
|
|
|
|
|
This API enables you to inspect an index and determine:
|
2018-02-23 17:10:37 -05:00
|
|
|
|
|
|
|
1. Does this index have associated rollup data somewhere in the cluster?
|
2019-01-15 11:46:36 -05:00
|
|
|
2. If yes to the first question, what fields were rolled up, what aggregations
|
|
|
|
can be performed, and where does the data live?
|
2018-02-23 17:10:37 -05:00
|
|
|
|
|
|
|
==== Request
|
|
|
|
|
2018-12-11 19:43:17 -05:00
|
|
|
`GET _rollup/data/{index}`
|
2018-02-23 17:10:37 -05:00
|
|
|
|
|
|
|
//===== Description
|
|
|
|
|
|
|
|
==== Path Parameters
|
|
|
|
|
|
|
|
`index`::
|
2018-08-17 13:33:12 -04:00
|
|
|
(string) Index, indices or index-pattern to return rollup capabilities for. `_all` may be used to fetch
|
|
|
|
rollup capabilities from all jobs
|
2018-02-23 17:10:37 -05:00
|
|
|
|
|
|
|
|
|
|
|
==== Request Body
|
|
|
|
|
2018-07-24 05:21:34 -04:00
|
|
|
There is no request body for the Get Rollup Caps API.
|
2018-02-23 17:10:37 -05:00
|
|
|
|
|
|
|
==== Authorization
|
|
|
|
|
|
|
|
You must have `monitor`, `monitor_rollup`, `manage` or `manage_rollup` cluster privileges to use this API.
|
|
|
|
For more information, see
|
2019-10-07 18:23:19 -04:00
|
|
|
<<security-privileges>>.
|
2018-02-23 17:10:37 -05:00
|
|
|
|
|
|
|
==== Examples
|
|
|
|
|
|
|
|
Imagine we have an index named `sensor-1` full of raw data. We know that the data will grow over time, so there
|
2018-10-03 13:11:39 -04:00
|
|
|
will be a `sensor-2`, `sensor-3`, etc. Let's create a Rollup job that targets the index pattern `sensor-*` to accommodate
|
2018-02-23 17:10:37 -05:00
|
|
|
this future scaling:
|
|
|
|
|
2019-09-09 12:35:50 -04:00
|
|
|
[source,console]
|
2018-02-23 17:10:37 -05:00
|
|
|
--------------------------------------------------
|
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"]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
--------------------------------------------------
|
|
|
|
// TEST[setup:sensor_index]
|
|
|
|
|
|
|
|
We can then retrieve the rollup capabilities of that index pattern (`sensor-*`) via the following command:
|
|
|
|
|
2019-09-09 12:35:50 -04:00
|
|
|
[source,console]
|
2018-02-23 17:10:37 -05:00
|
|
|
--------------------------------------------------
|
2018-12-11 19:43:17 -05:00
|
|
|
GET _rollup/data/sensor-*
|
2018-02-23 17:10:37 -05:00
|
|
|
--------------------------------------------------
|
|
|
|
// TEST[continued]
|
|
|
|
|
|
|
|
Which will yield the following response:
|
|
|
|
|
2019-09-06 09:22:08 -04:00
|
|
|
[source,console-result]
|
2018-02-23 17:10:37 -05:00
|
|
|
----
|
|
|
|
{
|
|
|
|
"sensor-*" : {
|
|
|
|
"rollup_jobs" : [
|
|
|
|
{
|
|
|
|
"job_id" : "sensor",
|
|
|
|
"rollup_index" : "sensor_rollup",
|
|
|
|
"index_pattern" : "sensor-*",
|
|
|
|
"fields" : {
|
|
|
|
"node" : [
|
|
|
|
{
|
|
|
|
"agg" : "terms"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"temperature" : [
|
|
|
|
{
|
|
|
|
"agg" : "min"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"agg" : "max"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"agg" : "sum"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"timestamp" : [
|
|
|
|
{
|
|
|
|
"agg" : "date_histogram",
|
|
|
|
"time_zone" : "UTC",
|
[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"
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"voltage" : [
|
|
|
|
{
|
|
|
|
"agg" : "avg"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
----
|
|
|
|
|
|
|
|
The response that is returned contains information that is similar to the original Rollup configuration, but formatted
|
|
|
|
differently. First, there are some house-keeping details: the Rollup job's ID, the index that holds the rolled data,
|
|
|
|
the index pattern that the job was targeting.
|
|
|
|
|
|
|
|
Next it shows a list of fields that contain data eligible for rollup searches. Here we see four fields: `node`, `temperature`,
|
|
|
|
`timestamp` and `voltage`. Each of these fields list the aggregations that are possible. For example, you can use a min, max
|
|
|
|
or sum aggregation on the `temperature` field, but only a `date_histogram` on `timestamp`.
|
|
|
|
|
|
|
|
Note that the `rollup_jobs` element is an array; there can be multiple, independent jobs configured for a single index
|
|
|
|
or index pattern. Each of these jobs may have different configurations, so the API returns a list of all the various
|
|
|
|
configurations available.
|
|
|
|
|
|
|
|
We could also retrieve the same information with a request to `_all`:
|
|
|
|
|
2019-09-09 12:35:50 -04:00
|
|
|
[source,console]
|
2018-02-23 17:10:37 -05:00
|
|
|
--------------------------------------------------
|
2018-12-11 19:43:17 -05:00
|
|
|
GET _rollup/data/_all
|
2018-02-23 17:10:37 -05:00
|
|
|
--------------------------------------------------
|
|
|
|
// TEST[continued]
|
|
|
|
|
|
|
|
But note that if we use the concrete index name (`sensor-1`), we'll retrieve no rollup capabilities:
|
|
|
|
|
2019-09-09 12:35:50 -04:00
|
|
|
[source,console]
|
2018-02-23 17:10:37 -05:00
|
|
|
--------------------------------------------------
|
2018-12-11 19:43:17 -05:00
|
|
|
GET _rollup/data/sensor-1
|
2018-02-23 17:10:37 -05:00
|
|
|
--------------------------------------------------
|
|
|
|
// TEST[continued]
|
|
|
|
|
2019-09-06 09:22:08 -04:00
|
|
|
[source,console-result]
|
2018-02-23 17:10:37 -05:00
|
|
|
----
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
----
|
|
|
|
|
|
|
|
Why is this? The original rollup job was configured against a specific index pattern (`sensor-*`) not a concrete index
|
|
|
|
(`sensor-1`). So while the index belongs to the pattern, the rollup job is only valid across the entirety of the pattern
|
|
|
|
not just one of it's containing indices. So for that reason, the Rollup Capabilities API only returns information based
|
2018-07-24 05:21:34 -04:00
|
|
|
on the originally configured index name or pattern.
|