get-job.asciidoc 8.4 KB

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