put-job.asciidoc 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. [role="xpack"]
  2. [testenv="basic"]
  3. [[rollup-put-job]]
  4. === Create {rollup-jobs} API
  5. [subs="attributes"]
  6. ++++
  7. <titleabbrev>Create {rollup-jobs}</titleabbrev>
  8. ++++
  9. Creates a {rollup-job}.
  10. experimental[]
  11. [[sample-api-request]]
  12. ==== {api-request-title}
  13. `PUT _rollup/job/<job_id>`
  14. [[sample-api-prereqs]]
  15. ==== {api-prereq-title}
  16. * If the {es} {security-features} are enabled, you must have `manage` or
  17. `manage_rollup` cluster privileges to use this API. For more information, see
  18. {stack-ov}/security-privileges.html[Security privileges].
  19. [[sample-api-desc]]
  20. ==== {api-description-title}
  21. Jobs are created in a `STOPPED` state. You can start them with the
  22. <<rollup-start-job,start {rollup-jobs} API>>.
  23. [[sample-api-path-params]]
  24. ==== {api-path-parms-title}
  25. `job_id`::
  26. (string) Required. Identifier for the {rollup-job}.
  27. [[sample-api-request-body]]
  28. ==== {api-request-body-title}
  29. `cron`::
  30. (string) Required. A cron string which defines when the {rollup-job} should be executed.
  31. `groups`::
  32. (object) Required. Defines the grouping fields that are defined for this
  33. {rollup-job}. See <<rollup-job-config,{rollup-job} config>>.
  34. `index_pattern`::
  35. (string) Required. The index or index pattern to roll up. Supports
  36. wildcard-style patterns (`logstash-*`).
  37. `metrics`::
  38. (object) Optional. Defines the metrics to collect for each grouping tuple. See
  39. <<rollup-job-config,{rollup-job} config>>.
  40. `page_size`::
  41. (integer) Required. The number of bucket results that are processed on each
  42. iteration of the rollup indexer. A larger value tends to execute faster, but
  43. requires more memory during processing.
  44. `rollup_index`::
  45. (string) Required. The index that contains the rollup results. The index can
  46. be shared with other {rollup-jobs}.
  47. For more details about the job configuration, see <<rollup-job-config>>.
  48. [[sample-api-example]]
  49. ==== {api-example-title}
  50. The following example creates a {rollup-job} named "sensor", targeting the
  51. "sensor-*" index pattern:
  52. [source,js]
  53. --------------------------------------------------
  54. PUT _rollup/job/sensor
  55. {
  56. "index_pattern": "sensor-*",
  57. "rollup_index": "sensor_rollup",
  58. "cron": "*/30 * * * * ?",
  59. "page_size" :1000,
  60. "groups" : {
  61. "date_histogram": {
  62. "field": "timestamp",
  63. "fixed_interval": "1h",
  64. "delay": "7d"
  65. },
  66. "terms": {
  67. "fields": ["node"]
  68. }
  69. },
  70. "metrics": [
  71. {
  72. "field": "temperature",
  73. "metrics": ["min", "max", "sum"]
  74. },
  75. {
  76. "field": "voltage",
  77. "metrics": ["avg"]
  78. }
  79. ]
  80. }
  81. --------------------------------------------------
  82. // CONSOLE
  83. // TEST[setup:sensor_index]
  84. When the job is created, you receive the following results:
  85. [source,js]
  86. ----
  87. {
  88. "acknowledged": true
  89. }
  90. ----
  91. // TESTRESPONSE