get-job.asciidoc 7.9 KB

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