rollup-index-caps.asciidoc 4.6 KB

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