get-job.asciidoc 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. [role="xpack"]
  2. [testenv="basic"]
  3. [[rollup-get-job]]
  4. === Get Rollup Jobs API
  5. ++++
  6. <titleabbrev>Get Job</titleabbrev>
  7. ++++
  8. experimental[]
  9. This API returns the configuration, stats and status of rollup jobs. The API can return the details for a single job,
  10. or for all jobs.
  11. Note: This API only returns active (both `STARTED` and `STOPPED`) jobs. If a job was created, ran for a while then deleted,
  12. this API will not return any details about that job.
  13. For details about a historical job, the <<rollup-get-rollup-caps,Rollup Capabilities API>> may be more useful
  14. ==== Request
  15. `GET _xpack/rollup/job/<job_id>`
  16. //===== Description
  17. ==== Path Parameters
  18. `job_id`::
  19. (string) Identifier for the job to retrieve. If omitted (or `_all` is used) all jobs will be returned
  20. ==== Request Body
  21. There is no request body for the Get Jobs API.
  22. ==== Authorization
  23. You must have `monitor`, `monitor_rollup`, `manage` or `manage_rollup` cluster privileges to use this API.
  24. For more information, see
  25. {xpack-ref}/security-privileges.html[Security Privileges].
  26. ==== Examples
  27. If we have already created a rollup job named `sensor`, the details about the job can be retrieved with:
  28. [source,js]
  29. --------------------------------------------------
  30. GET _xpack/rollup/job/sensor
  31. --------------------------------------------------
  32. // CONSOLE
  33. // TEST[setup:sensor_rollup_job]
  34. Which will yield the following response:
  35. [source,js]
  36. ----
  37. {
  38. "jobs" : [
  39. {
  40. "config" : {
  41. "id" : "sensor",
  42. "index_pattern" : "sensor-*",
  43. "rollup_index" : "sensor_rollup",
  44. "cron" : "*/30 * * * * ?",
  45. "groups" : {
  46. "date_histogram" : {
  47. "interval" : "1h",
  48. "delay": "7d",
  49. "field": "timestamp",
  50. "time_zone": "UTC"
  51. },
  52. "terms" : {
  53. "fields" : [
  54. "node"
  55. ]
  56. }
  57. },
  58. "metrics" : [
  59. {
  60. "field" : "temperature",
  61. "metrics" : [
  62. "min",
  63. "max",
  64. "sum"
  65. ]
  66. },
  67. {
  68. "field" : "voltage",
  69. "metrics" : [
  70. "avg"
  71. ]
  72. }
  73. ],
  74. "timeout" : "20s",
  75. "page_size" : 1000
  76. },
  77. "status" : {
  78. "job_state" : "stopped",
  79. "upgraded_doc_id": true
  80. },
  81. "stats" : {
  82. "pages_processed" : 0,
  83. "documents_processed" : 0,
  84. "rollups_indexed" : 0,
  85. "trigger_count" : 0
  86. }
  87. }
  88. ]
  89. }
  90. ----
  91. // TESTRESPONSE
  92. The `jobs` array contains a single job (`id: sensor`) since we requested a single job in the endpoint's URL. The
  93. details for this job contain three top-level parameters: `config`, `status` and `stats`
  94. `config` holds the rollup job's configuration, which is identical to the configuration that was supplied when creating
  95. the job via the <<rollup-put-job,Create Job API>>.
  96. The `status` object holds the current status of the rollup job's indexer. The possible values and their meanings are:
  97. - `stopped` means the indexer is paused and will not process data, even if it's cron interval triggers
  98. - `started` means the indexer is running, but not actively indexing data. When the cron interval triggers, the job's
  99. indexer will begin to process data
  100. - `indexing` means the indexer is actively processing data and creating new rollup documents. When in this state, any
  101. subsequent cron interval triggers will be ignored because the job is already active with the prior trigger
  102. - `abort` a transient state, which is usually not witnessed by the user. The `abort` state is used if the task needs to
  103. be shut down for some reason (job has been deleted, an unrecoverable error has been encountered, etc). Shortly after
  104. the `abort` state is set, the job will remove itself from the cluster
  105. Finally, the `stats` object provides transient statistics about the rollup job, such as how many documents have been
  106. processed and how many rollup summary docs have been indexed. These stats are not persisted, so if a node is restarted
  107. these stats will be reset.
  108. If we add another job, we can see how multi-job responses are handled:
  109. [source,js]
  110. --------------------------------------------------
  111. PUT _xpack/rollup/job/sensor2 <1>
  112. {
  113. "index_pattern": "sensor-*",
  114. "rollup_index": "sensor_rollup",
  115. "cron": "*/30 * * * * ?",
  116. "page_size" :1000,
  117. "groups" : {
  118. "date_histogram": {
  119. "field": "timestamp",
  120. "interval": "1h",
  121. "delay": "7d"
  122. },
  123. "terms": {
  124. "fields": ["node"]
  125. }
  126. },
  127. "metrics": [
  128. {
  129. "field": "temperature",
  130. "metrics": ["min", "max", "sum"]
  131. },
  132. {
  133. "field": "voltage",
  134. "metrics": ["avg"]
  135. }
  136. ]
  137. }
  138. GET _xpack/rollup/job/_all <2>
  139. --------------------------------------------------
  140. // CONSOLE
  141. // TEST[setup:sensor_rollup_job]
  142. <1> We create a second job with name `sensor2`
  143. <2> Then request all jobs by using `_all` in the GetJobs API
  144. Which will yield the following response:
  145. [source,js]
  146. ----
  147. {
  148. "jobs" : [
  149. {
  150. "config" : {
  151. "id" : "sensor2",
  152. "index_pattern" : "sensor-*",
  153. "rollup_index" : "sensor_rollup",
  154. "cron" : "*/30 * * * * ?",
  155. "groups" : {
  156. "date_histogram" : {
  157. "interval" : "1h",
  158. "delay": "7d",
  159. "field": "timestamp",
  160. "time_zone": "UTC"
  161. },
  162. "terms" : {
  163. "fields" : [
  164. "node"
  165. ]
  166. }
  167. },
  168. "metrics" : [
  169. {
  170. "field" : "temperature",
  171. "metrics" : [
  172. "min",
  173. "max",
  174. "sum"
  175. ]
  176. },
  177. {
  178. "field" : "voltage",
  179. "metrics" : [
  180. "avg"
  181. ]
  182. }
  183. ],
  184. "timeout" : "20s",
  185. "page_size" : 1000
  186. },
  187. "status" : {
  188. "job_state" : "stopped",
  189. "upgraded_doc_id": true
  190. },
  191. "stats" : {
  192. "pages_processed" : 0,
  193. "documents_processed" : 0,
  194. "rollups_indexed" : 0,
  195. "trigger_count" : 0
  196. }
  197. },
  198. {
  199. "config" : {
  200. "id" : "sensor",
  201. "index_pattern" : "sensor-*",
  202. "rollup_index" : "sensor_rollup",
  203. "cron" : "*/30 * * * * ?",
  204. "groups" : {
  205. "date_histogram" : {
  206. "interval" : "1h",
  207. "delay": "7d",
  208. "field": "timestamp",
  209. "time_zone": "UTC"
  210. },
  211. "terms" : {
  212. "fields" : [
  213. "node"
  214. ]
  215. }
  216. },
  217. "metrics" : [
  218. {
  219. "field" : "temperature",
  220. "metrics" : [
  221. "min",
  222. "max",
  223. "sum"
  224. ]
  225. },
  226. {
  227. "field" : "voltage",
  228. "metrics" : [
  229. "avg"
  230. ]
  231. }
  232. ],
  233. "timeout" : "20s",
  234. "page_size" : 1000
  235. },
  236. "status" : {
  237. "job_state" : "stopped",
  238. "upgraded_doc_id": true
  239. },
  240. "stats" : {
  241. "pages_processed" : 0,
  242. "documents_processed" : 0,
  243. "rollups_indexed" : 0,
  244. "trigger_count" : 0
  245. }
  246. }
  247. ]
  248. }
  249. ----
  250. // NOTCONSOLE