1
0

rollup-caps.asciidoc 5.2 KB

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