WARNING: Deprecated in 7.15.0.
The Java REST Client is deprecated in favor of the Java API Client.
Create or update rollup job API
editCreate or update rollup job API
editThis functionality is in technical preview and may be changed or removed in a future release. Elastic will work to fix any issues, but features in technical preview are not subject to the support SLA of official GA features.
Creates a new Rollup job or updates an existing one.
The API accepts a PutRollupJobRequest
object
as a request and returns a PutRollupJobResponse
.
Request
editA PutRollupJobRequest
requires the following argument:
Rollup Job Configuration
editThe RollupJobConfig
object contains all the details about the rollup job
configuration. See create rollup job API to learn more
about the various configuration settings.
A RollupJobConfig
requires the following arguments:
RollupJobConfig config = new RollupJobConfig(id, indexPattern, rollupIndex, cron, pageSize, groups, metrics, timeout);
The name of the Rollup job |
|
The index (or index pattern) to rollup |
|
The index to store rollup results into |
|
A cron expression which defines when the Rollup job should be executed |
|
The page size to use for the Rollup job |
|
The grouping configuration of the Rollup job as a |
|
The metrics configuration of the Rollup job as a list of |
|
The timeout value to use for the Rollup job as a |
Grouping Configuration
editThe grouping configuration of the Rollup job is defined in the RollupJobConfig
using a GroupConfig
instance. GroupConfig
reflects all the configuration
settings that can be defined using the REST API. See Grouping config
to learn more about these settings.
Using the REST API, we could define this grouping configuration:
"groups" : { "date_histogram": { "field": "timestamp", "calendar_interval": "1h", "delay": "7d", "time_zone": "UTC" }, "terms": { "fields": ["hostname", "datacenter"] }, "histogram": { "fields": ["load", "net_in", "net_out"], "interval": 5 } }
Using the GroupConfig
object and the high level REST client, the same
configuration would be:
DateHistogramGroupConfig dateHistogram = new DateHistogramGroupConfig("timestamp", DateHistogramInterval.HOUR, new DateHistogramInterval("7d"), "UTC"); TermsGroupConfig terms = new TermsGroupConfig("hostname", "datacenter"); HistogramGroupConfig histogram = new HistogramGroupConfig(5L, "load", "net_in", "net_out"); GroupConfig groups = new GroupConfig(dateHistogram, histogram, terms);
Metrics Configuration
editAfter defining which groups should be generated for the data, you next configure
which metrics should be collected. The list of metrics is defined in the RollupJobConfig
using a List<MetricConfig>
instance. MetricConfig
reflects all the configuration
settings that can be defined using the REST API. See Metrics config
to learn more about these settings.
Using the REST API, we could define this metrics configuration:
"metrics": [ { "field": "temperature", "metrics": ["min", "max", "sum"] }, { "field": "voltage", "metrics": ["avg", "value_count"] } ]
Using the MetricConfig
object and the high level REST client, the same
configuration would be:
Execution
editThe API can be called through a RollupClient
instance. Such instance can be retrieved from a RestHighLevelClient
using the rollup()
method:
AcknowledgedResponse response = client.rollup().putRollupJob(request, RequestOptions.DEFAULT);
Response
editThe returned PutRollupJobResponse
indicates if the new Rollup job
has been successfully created:
Asynchronous Execution
editThis request can be executed asynchronously:
The asynchronous method does not block and returns immediately. Once it is
completed the ActionListener
is called back using the onResponse
method
if the execution successfully completed or using the onFailure
method if
it failed.
A typical listener for PutRollupJobResponse
looks like: