downsampling.asciidoc 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. [[downsampling]]
  2. === Downsampling a time series data stream
  3. Downsampling provides a method to reduce the footprint of your <<tsds,time
  4. series data>> by storing it at reduced granularity.
  5. Metrics solutions collect large amounts of time series data that grow over time.
  6. As that data ages, it becomes less relevant to the current state of the system.
  7. The downsampling process rolls up documents within a fixed time interval into a
  8. single summary document. Each summary document includes statistical
  9. representations of the original data: the `min`, `max`, `sum`, `value_count`,
  10. and `average` for each metric. Data stream <<time-series-dimension,time series
  11. dimensions>> are stored unchanged.
  12. Downsampling, in effect, lets you to trade data resolution and precision for
  13. storage size. You can include it in an <<index-lifecycle-management,{ilm}
  14. ({ilm-init})>> policy to automatically manage the volume and associated cost of
  15. your metrics data at it ages.
  16. Check the following sections to learn more:
  17. * <<how-downsampling-works>>
  18. * <<running-downsampling>>
  19. * <<querying-downsampled-indices>>
  20. * <<downsampling-restrictions>>
  21. * <<try-out-downsampling>>
  22. [discrete]
  23. [[how-downsampling-works]]
  24. === How it works
  25. A <<time-series,time series>> is a sequence of observations taken over time for
  26. a specific entity. The observed samples can be represented as a continuous
  27. function, where the time series dimensions remain constant and the time series
  28. metrics change over time.
  29. //.Sampling a continuous function
  30. image::images/data-streams/time-series-function.png[align="center"]
  31. In an Elasticsearch index, a single document is created for each timestamp,
  32. containing the immutable time series dimensions, together with the metrics names
  33. and the changing metrics values. For a single timestamp, several time series
  34. dimensions and metrics may be stored.
  35. //.Metric anatomy
  36. image::images/data-streams/time-series-metric-anatomy.png[align="center"]
  37. For your most current and relevant data, the metrics series typically has a low
  38. sampling time interval, so it's optimized for queries that require a high data
  39. resolution.
  40. .Original metrics series
  41. image::images/data-streams/time-series-original.png[align="center"]
  42. Downsampling works on older, less frequently accessed data by replacing the
  43. original time series with both a data stream of a higher sampling interval and
  44. statistical representations of that data. Where the original metrics samples may
  45. have been taken, for example, every ten seconds, as the data ages you may choose
  46. to reduce the sample granularity to hourly or daily. You may choose to reduce
  47. the granularity of `cold` archival data to monthly or less.
  48. .Downsampled metrics series
  49. image::images/data-streams/time-series-downsampled.png[align="center"]
  50. [discrete]
  51. [[running-downsampling]]
  52. === Running downsampling on time series data
  53. To downsample a time series index, use the
  54. <<indices-downsample-data-stream,Downsample API>> and set `fixed_interval` to
  55. the level of granularity that you'd like:
  56. include::../indices/downsample-data-stream.asciidoc[tag=downsample-example]
  57. To downsample time series data as part of ILM, include a
  58. <<ilm-downsample,Downsample action>> in your ILM policy and set `fixed_interval`
  59. to the level of granularity that you'd like:
  60. [source,console]
  61. ----
  62. PUT _ilm/policy/my_policy
  63. {
  64. "policy": {
  65. "phases": {
  66. "warm": {
  67. "actions": {
  68. "downsample" : {
  69. "fixed_interval": "1h"
  70. }
  71. }
  72. }
  73. }
  74. }
  75. }
  76. ----
  77. [discrete]
  78. [[querying-downsampled-indices]]
  79. === Querying downsampled indices
  80. You can use the <<search-search,`_search`>> and <<async-search,`_async_search`>>
  81. endpoints to query a downsampled index. Multiple raw data and downsampled
  82. indices can be queried in a single request, and a single request can include
  83. downsampled indices at different granularities (different bucket timespan). That
  84. is, you can query data streams that contain downsampled indices with multiple
  85. downsampling intervals (for example, `15m`, `1h`, `1d`).
  86. The result of a time based histogram aggregation is in a uniform bucket size and
  87. each downsampled index returns data ignoring the downsampling time interval. For
  88. example, if you run a `date_histogram` aggregation with `"fixed_interval": "1m"`
  89. on a downsampled index that has been downsampled at an hourly resolution
  90. (`"fixed_interval": "1h"`), the query returns one bucket with all of the data at
  91. minute 0, then 59 empty buckets, and then a bucket with data again for the next
  92. hour.
  93. NOTE:
  94. There are a few things to note when querying downsampled indices:
  95. * When you run queries in {kib} and through Elastic solutions, a normal
  96. response is returned without notification that some of the queried indices are
  97. downsampled.
  98. * For
  99. <<search-aggregations-bucket-datehistogram-aggregation,date histogram aggregations>>,
  100. only `fixed_intervals` (and not calendar-aware intervals) are supported.
  101. * Only Coordinated Universal Time (UTC) date-times are supported.
  102. [discrete]
  103. [[downsampling-restrictions]]
  104. === Restrictions and limitations
  105. The following restrictions and limitations apply for downsampling:
  106. * Only indices in a <<tsds,time series data stream>> are supported.
  107. * Data is downsampled based on the time dimension only. All other dimensions are
  108. copied to the new index without any modification.
  109. * Within a data stream, a downsampled index replaces the original index and the
  110. original index is deleted. Only one index can exist for a given time period.
  111. * A source index must be in read-only mode for the downsampling process to
  112. succeed. Check the <<downsampling-manual,Run downsampling manually>> example for
  113. details.
  114. * Downsampling data for the same period many times (downsampling of a
  115. downsampled index) is supported. The downsampling interval must be a multiple of
  116. the interval of the downsampled index.
  117. * Downsampling is provided as an ILM action. See <<ilm-downsample,Downsample>>.
  118. * The new, downsampled index is created on the data tier of the original index
  119. and it inherits its settings (for example, the number of shards and replicas).
  120. * The numeric `gauge` and `counter` <<mapping-field-meta,metric types>> are
  121. supported.
  122. * The downsampling configuration is extracted from the time series data stream
  123. <<tsds-create-mappings-component-template,index mapping>>. The only additional
  124. required setting is the downsampling `fixed_interval`.
  125. [discrete]
  126. [[try-out-downsampling]]
  127. === Try it out
  128. To take downsampling for a test run, try our example of
  129. <<downsampling-manual,running downsampling manually>>.
  130. Downsampling can easily be added to your ILM policy. To learn how, try our
  131. <<downsampling-ilm,Run downsampling with ILM>> example.