put-job.asciidoc 2.4 KB

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