rollup-index-caps.asciidoc 4.5 KB

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