rollup-index-caps.asciidoc 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. [role="xpack"]
  2. [testenv="basic"]
  3. [[rollup-get-rollup-index-caps]]
  4. === Get rollup index capabilities API
  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,console]
  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. "fixed_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. // 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,console]
  63. --------------------------------------------------
  64. GET /sensor_rollup/_rollup/data
  65. --------------------------------------------------
  66. // TEST[continued]
  67. Note how we are requesting the concrete rollup index name (`sensor_rollup`) as the first part of the URL.
  68. This will yield the following response:
  69. [source,console-result]
  70. ----
  71. {
  72. "sensor_rollup" : {
  73. "rollup_jobs" : [
  74. {
  75. "job_id" : "sensor",
  76. "rollup_index" : "sensor_rollup",
  77. "index_pattern" : "sensor-*",
  78. "fields" : {
  79. "node" : [
  80. {
  81. "agg" : "terms"
  82. }
  83. ],
  84. "temperature" : [
  85. {
  86. "agg" : "min"
  87. },
  88. {
  89. "agg" : "max"
  90. },
  91. {
  92. "agg" : "sum"
  93. }
  94. ],
  95. "timestamp" : [
  96. {
  97. "agg" : "date_histogram",
  98. "time_zone" : "UTC",
  99. "fixed_interval" : "1h",
  100. "delay": "7d"
  101. }
  102. ],
  103. "voltage" : [
  104. {
  105. "agg" : "avg"
  106. }
  107. ]
  108. }
  109. }
  110. ]
  111. }
  112. }
  113. ----
  114. The response that is returned contains information that is similar to the original Rollup configuration, but formatted
  115. differently. First, there are some house-keeping details: the Rollup job's ID, the index that holds the rolled data,
  116. the index pattern that the job was targeting.
  117. Next it shows a list of fields that contain data eligible for rollup searches. Here we see four fields: `node`, `temperature`,
  118. `timestamp` and `voltage`. Each of these fields list the aggregations that are possible. For example, you can use a min, max
  119. or sum aggregation on the `temperature` field, but only a `date_histogram` on `timestamp`.
  120. Note that the `rollup_jobs` element is an array; there can be multiple, independent jobs configured for a single index
  121. or index pattern. Each of these jobs may have different configurations, so the API returns a list of all the various
  122. configurations available.
  123. Like other APIs that interact with indices, you can specify index patterns instead of explicit indices:
  124. [source,console]
  125. --------------------------------------------------
  126. GET /*_rollup/_rollup/data
  127. --------------------------------------------------
  128. // TEST[continued]