rollup-caps.asciidoc 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. [role="xpack"]
  2. [[rollup-get-rollup-caps]]
  3. === Get {rollup-job} capabilities API
  4. ++++
  5. <titleabbrev>Get rollup caps</titleabbrev>
  6. ++++
  7. Returns the capabilities of any {rollup-jobs} that have been configured for a
  8. specific index or index pattern.
  9. experimental[]
  10. [[rollup-get-rollup-caps-request]]
  11. ==== {api-request-title}
  12. `GET _rollup/data/<index>`
  13. [[rollup-get-rollup-caps-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-rollup-caps-desc]]
  19. ==== {api-description-title}
  20. This API is useful because a {rollup-job} is often configured to rollup only a
  21. subset of fields from the source index. Furthermore, only certain aggregations
  22. can be configured for various fields, leading to a limited subset of
  23. functionality depending on that configuration.
  24. This API enables you to inspect an index and determine:
  25. 1. Does this index have associated rollup data somewhere in the cluster?
  26. 2. If yes to the first question, what fields were rolled up, what aggregations
  27. can be performed, and where does the data live?
  28. [[rollup-get-rollup-path-params]]
  29. ==== {api-path-parms-title}
  30. `<index>`::
  31. (string) Index, indices or index-pattern to return rollup capabilities for.
  32. `_all` may be used to fetch rollup capabilities from all jobs.
  33. [[rollup-get-rollup-example]]
  34. ==== {api-examples-title}
  35. Imagine we have an index named `sensor-1` full of raw data. We know that the
  36. data will grow over time, so there will be a `sensor-2`, `sensor-3`, etc. Let's
  37. create a {rollup-job} that targets the index pattern `sensor-*` to accommodate
  38. this future scaling:
  39. [source,console]
  40. --------------------------------------------------
  41. PUT _rollup/job/sensor
  42. {
  43. "index_pattern": "sensor-*",
  44. "rollup_index": "sensor_rollup",
  45. "cron": "*/30 * * * * ?",
  46. "page_size": 1000,
  47. "groups": {
  48. "date_histogram": {
  49. "field": "timestamp",
  50. "fixed_interval": "1h",
  51. "delay": "7d"
  52. },
  53. "terms": {
  54. "fields": [ "node" ]
  55. }
  56. },
  57. "metrics": [
  58. {
  59. "field": "temperature",
  60. "metrics": [ "min", "max", "sum" ]
  61. },
  62. {
  63. "field": "voltage",
  64. "metrics": [ "avg" ]
  65. }
  66. ]
  67. }
  68. --------------------------------------------------
  69. // TEST[setup:sensor_index]
  70. We can then retrieve the rollup capabilities of that index pattern (`sensor-*`)
  71. via the following command:
  72. [source,console]
  73. --------------------------------------------------
  74. GET _rollup/data/sensor-*
  75. --------------------------------------------------
  76. // TEST[continued]
  77. Which will yield the following response:
  78. [source,console-result]
  79. ----
  80. {
  81. "sensor-*" : {
  82. "rollup_jobs" : [
  83. {
  84. "job_id" : "sensor",
  85. "rollup_index" : "sensor_rollup",
  86. "index_pattern" : "sensor-*",
  87. "fields" : {
  88. "node" : [
  89. {
  90. "agg" : "terms"
  91. }
  92. ],
  93. "temperature" : [
  94. {
  95. "agg" : "min"
  96. },
  97. {
  98. "agg" : "max"
  99. },
  100. {
  101. "agg" : "sum"
  102. }
  103. ],
  104. "timestamp" : [
  105. {
  106. "agg" : "date_histogram",
  107. "time_zone" : "UTC",
  108. "fixed_interval" : "1h",
  109. "delay": "7d"
  110. }
  111. ],
  112. "voltage" : [
  113. {
  114. "agg" : "avg"
  115. }
  116. ]
  117. }
  118. }
  119. ]
  120. }
  121. }
  122. ----
  123. The response that is returned contains information that is similar to the
  124. original rollup configuration, but formatted differently. First, there are some
  125. house-keeping details: the {rollup-job} ID, the index that holds the rolled data,
  126. and the index pattern that the job was targeting.
  127. Next it shows a list of fields that contain data eligible for rollup searches.
  128. Here we see four fields: `node`, `temperature`, `timestamp` and `voltage`. Each
  129. of these fields list the aggregations that are possible. For example, you can
  130. use a min, max or sum aggregation on the `temperature` field, but only a
  131. `date_histogram` on `timestamp`.
  132. Note that the `rollup_jobs` element is an array; there can be multiple,
  133. independent jobs configured for a single index or index pattern. Each of these
  134. jobs may have different configurations, so the API returns a list of all the
  135. various configurations available.
  136. We could also retrieve the same information with a request to `_all`:
  137. [source,console]
  138. --------------------------------------------------
  139. GET _rollup/data/_all
  140. --------------------------------------------------
  141. // TEST[continued]
  142. But note that if we use the concrete index name (`sensor-1`), we'll retrieve no
  143. rollup capabilities:
  144. [source,console]
  145. --------------------------------------------------
  146. GET _rollup/data/sensor-1
  147. --------------------------------------------------
  148. // TEST[continued]
  149. [source,console-result]
  150. ----
  151. {
  152. }
  153. ----
  154. Why is this? The original {rollup-job} was configured against a specific index
  155. pattern (`sensor-*`) not a concrete index (`sensor-1`). So while the index
  156. belongs to the pattern, the {rollup-job} is only valid across the entirety of
  157. the pattern not just one of it's containing indices. So for that reason, the
  158. get rollup capabilities API only returns information based on the originally
  159. configured index name or pattern.