put-job.asciidoc 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. [role="xpack"]
  2. [testenv="basic"]
  3. [[rollup-put-job]]
  4. === Create Job API
  5. ++++
  6. <titleabbrev>Create Job</titleabbrev>
  7. ++++
  8. experimental[]
  9. This API enables you to create a rollup job. The job will be created in a `STOPPED` state, and must be
  10. started with the <<rollup-start-job,Start Job API>>.
  11. ==== Request
  12. `PUT _xpack/rollup/job/<job_id>`
  13. //===== Description
  14. ==== Path Parameters
  15. `job_id` (required)::
  16. (string) Identifier for the job
  17. ==== Request Body
  18. `index_pattern` (required)::
  19. (string) The index, or index pattern, that you wish to rollup. Supports wildcard-style patterns (`logstash-*`).
  20. `rollup_index` (required)::
  21. (string) The index that you wish to store rollup results into. Can be shared with other rollup jobs.
  22. `cron` (required)::
  23. (string) A cron string which defines when the rollup job should be executed.
  24. `page_size` (required)::
  25. (int) The number of bucket results that should be processed on each iteration of the rollup indexer. A larger value
  26. will tend to execute faster, but will require more memory during processing.
  27. `groups` (required)::
  28. (object) Defines the grouping fields that are defined for this rollup job. See <<rollup-job-config,rollup job config>>.
  29. `metrics`::
  30. (object) Defines the metrics that should be collected for each grouping tuple. See <<rollup-job-config,rollup job config>>.
  31. For more details about the job configuration, see <<rollup-job-config>>.
  32. ==== Authorization
  33. You must have `manage` or `manage_rollup` cluster privileges to use this API.
  34. For more information, see
  35. {xpack-ref}/security-privileges.html[Security Privileges].
  36. ==== Examples
  37. The following example creates a rollup job named "sensor", targeting the "sensor-*" index pattern:
  38. [source,js]
  39. --------------------------------------------------
  40. PUT _xpack/rollup/job/sensor
  41. {
  42. "index_pattern": "sensor-*",
  43. "rollup_index": "sensor_rollup",
  44. "cron": "*/30 * * * * ?",
  45. "page_size" :1000,
  46. "groups" : {
  47. "date_histogram": {
  48. "field": "timestamp",
  49. "interval": "1h",
  50. "delay": "7d"
  51. },
  52. "terms": {
  53. "fields": ["node"]
  54. }
  55. },
  56. "metrics": [
  57. {
  58. "field": "temperature",
  59. "metrics": ["min", "max", "sum"]
  60. },
  61. {
  62. "field": "voltage",
  63. "metrics": ["avg"]
  64. }
  65. ]
  66. }
  67. --------------------------------------------------
  68. // CONSOLE
  69. // TEST[setup:sensor_index]
  70. When the job is created, you receive the following results:
  71. [source,js]
  72. ----
  73. {
  74. "acknowledged": true
  75. }
  76. ----
  77. // TESTRESPONSE