rollup-index-caps.asciidoc 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. [role="xpack"]
  2. [[rollup-get-rollup-index-caps]]
  3. === Get Rollup Index Capabilities
  4. ++++
  5. <titleabbrev>Get Rollup Index Caps</titleabbrev>
  6. ++++
  7. experimental[]
  8. This API returns the rollup capabilities of all jobs inside of a rollup index (e.g. the index where rollup data is stored).
  9. A single rollup index may store the data for multiple rollup jobs, and may have a variety of capabilities depending on those jobs.
  10. This API will allow you to determine:
  11. 1. What jobs are stored in an index (or indices specified via a pattern)?
  12. 2. What target indices were rolled up, what fields were used in those rollups and what aggregations can be performed on each job?
  13. ==== Request
  14. `GET {index}/_xpack/rollup/data`
  15. //===== Description
  16. ==== Path Parameters
  17. `index`::
  18. (string) Index or index-pattern of concrete rollup indices to check for capabilities.
  19. ==== Request Body
  20. There is no request body for the Get Jobs API.
  21. ==== Authorization
  22. You must have the `read` index privilege on the index that stores the rollup results.
  23. For more information, see
  24. {xpack-ref}/security-privileges.html[Security Privileges].
  25. ==== Examples
  26. Imagine we have an index named `sensor-1` full of raw data. We know that the data will grow over time, so there
  27. will be a `sensor-2`, `sensor-3`, etc. Let's create a Rollup job, which stores it's data in `sensor_rollup`:
  28. [source,js]
  29. --------------------------------------------------
  30. PUT _xpack/rollup/job/sensor
  31. {
  32. "index_pattern": "sensor-*",
  33. "rollup_index": "sensor_rollup",
  34. "cron": "*/30 * * * * ?",
  35. "page_size" :1000,
  36. "groups" : {
  37. "date_histogram": {
  38. "field": "timestamp",
  39. "interval": "1h",
  40. "delay": "7d"
  41. },
  42. "terms": {
  43. "fields": ["node"]
  44. }
  45. },
  46. "metrics": [
  47. {
  48. "field": "temperature",
  49. "metrics": ["min", "max", "sum"]
  50. },
  51. {
  52. "field": "voltage",
  53. "metrics": ["avg"]
  54. }
  55. ]
  56. }
  57. --------------------------------------------------
  58. // CONSOLE
  59. // TEST[setup:sensor_index]
  60. If at a later date, we'd like to determine what jobs and capabilities were stored in the `sensor_rollup` index, we can use the Get Rollup
  61. Index API:
  62. [source,js]
  63. --------------------------------------------------
  64. GET /sensor_rollup/_xpack/rollup/data
  65. --------------------------------------------------
  66. // CONSOLE
  67. // TEST[continued]
  68. Note how we are requesting the concrete rollup index name (`sensor_rollup`) as the first part of the URL.
  69. This will yield the following response:
  70. [source,js]
  71. ----
  72. {
  73. "sensor_rollup" : {
  74. "rollup_jobs" : [
  75. {
  76. "job_id" : "sensor",
  77. "rollup_index" : "sensor_rollup",
  78. "index_pattern" : "sensor-*",
  79. "fields" : {
  80. "node" : [
  81. {
  82. "agg" : "terms"
  83. }
  84. ],
  85. "temperature" : [
  86. {
  87. "agg" : "min"
  88. },
  89. {
  90. "agg" : "max"
  91. },
  92. {
  93. "agg" : "sum"
  94. }
  95. ],
  96. "timestamp" : [
  97. {
  98. "agg" : "date_histogram",
  99. "time_zone" : "UTC",
  100. "interval" : "1h",
  101. "delay": "7d"
  102. }
  103. ],
  104. "voltage" : [
  105. {
  106. "agg" : "avg"
  107. }
  108. ]
  109. }
  110. }
  111. ]
  112. }
  113. }
  114. ----
  115. // TESTRESPONSE
  116. The response that is returned contains information that is similar to the original Rollup configuration, but formatted
  117. differently. First, there are some house-keeping details: the Rollup job's ID, the index that holds the rolled data,
  118. the index pattern that the job was targeting.
  119. Next it shows a list of fields that contain data eligible for rollup searches. Here we see four fields: `node`, `temperature`,
  120. `timestamp` and `voltage`. Each of these fields list the aggregations that are possible. For example, you can use a min, max
  121. or sum aggregation on the `temperature` field, but only a `date_histogram` on `timestamp`.
  122. Note that the `rollup_jobs` element is an array; there can be multiple, independent jobs configured for a single index
  123. or index pattern. Each of these jobs may have different configurations, so the API returns a list of all the various
  124. configurations available.
  125. Like other APIs that interact with indices, you can specify index patterns instead of explicit indices:
  126. [source,js]
  127. --------------------------------------------------
  128. GET /*_rollup/_xpack/rollup/data
  129. --------------------------------------------------
  130. // CONSOLE
  131. // TEST[continued]