get-job.asciidoc 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  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 _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 _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. "index_failures": 0,
  87. "index_time_in_ms": 0,
  88. "index_total": 0,
  89. "search_failures": 0,
  90. "search_time_in_ms": 0,
  91. "search_total": 0
  92. }
  93. }
  94. ]
  95. }
  96. ----
  97. // TESTRESPONSE
  98. The `jobs` array contains a single job (`id: sensor`) since we requested a single job in the endpoint's URL. The
  99. details for this job contain three top-level parameters: `config`, `status` and `stats`
  100. `config` holds the rollup job's configuration, which is identical to the configuration that was supplied when creating
  101. the job via the <<rollup-put-job,Create Job API>>.
  102. The `status` object holds the current status of the rollup job's indexer. The possible values and their meanings are:
  103. - `stopped` means the indexer is paused and will not process data, even if it's cron interval triggers
  104. - `started` means the indexer is running, but not actively indexing data. When the cron interval triggers, the job's
  105. indexer will begin to process data
  106. - `indexing` means the indexer is actively processing data and creating new rollup documents. When in this state, any
  107. subsequent cron interval triggers will be ignored because the job is already active with the prior trigger
  108. - `abort` a transient state, which is usually not witnessed by the user. The `abort` state is used if the task needs to
  109. be shut down for some reason (job has been deleted, an unrecoverable error has been encountered, etc). Shortly after
  110. the `abort` state is set, the job will remove itself from the cluster
  111. Finally, the `stats` object provides transient statistics about the rollup job, such as how many documents have been
  112. processed and how many rollup summary docs have been indexed. These stats are not persisted, so if a node is restarted
  113. these stats will be reset.
  114. If we add another job, we can see how multi-job responses are handled:
  115. [source,js]
  116. --------------------------------------------------
  117. PUT _rollup/job/sensor2 <1>
  118. {
  119. "index_pattern": "sensor-*",
  120. "rollup_index": "sensor_rollup",
  121. "cron": "*/30 * * * * ?",
  122. "page_size" :1000,
  123. "groups" : {
  124. "date_histogram": {
  125. "field": "timestamp",
  126. "interval": "1h",
  127. "delay": "7d"
  128. },
  129. "terms": {
  130. "fields": ["node"]
  131. }
  132. },
  133. "metrics": [
  134. {
  135. "field": "temperature",
  136. "metrics": ["min", "max", "sum"]
  137. },
  138. {
  139. "field": "voltage",
  140. "metrics": ["avg"]
  141. }
  142. ]
  143. }
  144. GET _rollup/job/_all <2>
  145. --------------------------------------------------
  146. // CONSOLE
  147. // TEST[setup:sensor_rollup_job]
  148. <1> We create a second job with name `sensor2`
  149. <2> Then request all jobs by using `_all` in the GetJobs API
  150. Which will yield the following response:
  151. [source,js]
  152. ----
  153. {
  154. "jobs" : [
  155. {
  156. "config" : {
  157. "id" : "sensor2",
  158. "index_pattern" : "sensor-*",
  159. "rollup_index" : "sensor_rollup",
  160. "cron" : "*/30 * * * * ?",
  161. "groups" : {
  162. "date_histogram" : {
  163. "interval" : "1h",
  164. "delay": "7d",
  165. "field": "timestamp",
  166. "time_zone": "UTC"
  167. },
  168. "terms" : {
  169. "fields" : [
  170. "node"
  171. ]
  172. }
  173. },
  174. "metrics" : [
  175. {
  176. "field" : "temperature",
  177. "metrics" : [
  178. "min",
  179. "max",
  180. "sum"
  181. ]
  182. },
  183. {
  184. "field" : "voltage",
  185. "metrics" : [
  186. "avg"
  187. ]
  188. }
  189. ],
  190. "timeout" : "20s",
  191. "page_size" : 1000
  192. },
  193. "status" : {
  194. "job_state" : "stopped",
  195. "upgraded_doc_id": true
  196. },
  197. "stats" : {
  198. "pages_processed" : 0,
  199. "documents_processed" : 0,
  200. "rollups_indexed" : 0,
  201. "trigger_count" : 0,
  202. "index_failures": 0,
  203. "index_time_in_ms": 0,
  204. "index_total": 0,
  205. "search_failures": 0,
  206. "search_time_in_ms": 0,
  207. "search_total": 0
  208. }
  209. },
  210. {
  211. "config" : {
  212. "id" : "sensor",
  213. "index_pattern" : "sensor-*",
  214. "rollup_index" : "sensor_rollup",
  215. "cron" : "*/30 * * * * ?",
  216. "groups" : {
  217. "date_histogram" : {
  218. "interval" : "1h",
  219. "delay": "7d",
  220. "field": "timestamp",
  221. "time_zone": "UTC"
  222. },
  223. "terms" : {
  224. "fields" : [
  225. "node"
  226. ]
  227. }
  228. },
  229. "metrics" : [
  230. {
  231. "field" : "temperature",
  232. "metrics" : [
  233. "min",
  234. "max",
  235. "sum"
  236. ]
  237. },
  238. {
  239. "field" : "voltage",
  240. "metrics" : [
  241. "avg"
  242. ]
  243. }
  244. ],
  245. "timeout" : "20s",
  246. "page_size" : 1000
  247. },
  248. "status" : {
  249. "job_state" : "stopped",
  250. "upgraded_doc_id": true
  251. },
  252. "stats" : {
  253. "pages_processed" : 0,
  254. "documents_processed" : 0,
  255. "rollups_indexed" : 0,
  256. "trigger_count" : 0,
  257. "index_failures": 0,
  258. "index_time_in_ms": 0,
  259. "index_total": 0,
  260. "search_failures": 0,
  261. "search_time_in_ms": 0,
  262. "search_total": 0
  263. }
  264. }
  265. ]
  266. }
  267. ----
  268. // NOTCONSOLE