get-job.asciidoc 7.9 KB

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