downsampling-manual.asciidoc 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638
  1. [[downsampling-manual]]
  2. === Run downsampling manually
  3. ++++
  4. <titleabbrev>Run downsampling manually</titleabbrev>
  5. ++++
  6. ////
  7. [source,console]
  8. ----
  9. DELETE _data_stream/my-data-stream
  10. DELETE _index_template/my-data-stream-template
  11. DELETE _ingest/pipeline/my-timestamp-pipeline
  12. ----
  13. // TEARDOWN
  14. ////
  15. The recommended way to <<downsampling,downsample>> a <<tsds,time-series data stream (TSDS)>> is
  16. <<downsampling-ilm,through index lifecycle management (ILM)>>. However, if
  17. you're not using ILM, you can downsample a TSDS manually. This guide shows you
  18. how, using typical Kubernetes cluster monitoring data.
  19. To test out manual downsampling, follow these steps:
  20. . Check the <<downsampling-manual-prereqs,prerequisites>>.
  21. . <<downsampling-manual-create-index>>.
  22. . <<downsampling-manual-ingest-data>>.
  23. . <<downsampling-manual-run>>.
  24. . <<downsampling-manual-view-results>>.
  25. [discrete]
  26. [[downsampling-manual-prereqs]]
  27. ==== Prerequisites
  28. * Refer to the <<tsds-prereqs,TSDS prerequisites>>.
  29. * It is not possible to downsample a <<data-streams,data stream>> directly, nor
  30. multiple indices at once. It's only possible to downsample one time series index
  31. (TSDS backing index).
  32. * In order to downsample an index, it needs to be read-only. For a TSDS write
  33. index, this means it needs to be rolled over and made read-only first.
  34. * Downsampling uses UTC timestamps.
  35. * Downsampling needs at least one metric field to exist in the time series
  36. index.
  37. [discrete]
  38. [[downsampling-manual-create-index]]
  39. ==== Create a time series data stream
  40. First, you'll create a TSDS. For simplicity, in the time series mapping all
  41. `time_series_metric` parameters are set to type `gauge`, but
  42. <<time-series-metric,other values>> such as `counter` and `histogram` may also
  43. be used. The `time_series_metric` values determine the kind of statistical
  44. representations that are used during downsampling.
  45. The index template includes a set of static
  46. <<time-series-dimension,time series dimensions>>: `host`, `namespace`,
  47. `node`, and `pod`. The time series dimensions are not changed by the
  48. downsampling process.
  49. [source,console]
  50. ----
  51. PUT _index_template/my-data-stream-template
  52. {
  53. "index_patterns": [
  54. "my-data-stream*"
  55. ],
  56. "data_stream": {},
  57. "template": {
  58. "settings": {
  59. "index": {
  60. "mode": "time_series",
  61. "routing_path": [
  62. "kubernetes.namespace",
  63. "kubernetes.host",
  64. "kubernetes.node",
  65. "kubernetes.pod"
  66. ],
  67. "number_of_replicas": 0,
  68. "number_of_shards": 2
  69. }
  70. },
  71. "mappings": {
  72. "properties": {
  73. "@timestamp": {
  74. "type": "date"
  75. },
  76. "kubernetes": {
  77. "properties": {
  78. "container": {
  79. "properties": {
  80. "cpu": {
  81. "properties": {
  82. "usage": {
  83. "properties": {
  84. "core": {
  85. "properties": {
  86. "ns": {
  87. "type": "long"
  88. }
  89. }
  90. },
  91. "limit": {
  92. "properties": {
  93. "pct": {
  94. "type": "float"
  95. }
  96. }
  97. },
  98. "nanocores": {
  99. "type": "long",
  100. "time_series_metric": "gauge"
  101. },
  102. "node": {
  103. "properties": {
  104. "pct": {
  105. "type": "float"
  106. }
  107. }
  108. }
  109. }
  110. }
  111. }
  112. },
  113. "memory": {
  114. "properties": {
  115. "available": {
  116. "properties": {
  117. "bytes": {
  118. "type": "long",
  119. "time_series_metric": "gauge"
  120. }
  121. }
  122. },
  123. "majorpagefaults": {
  124. "type": "long"
  125. },
  126. "pagefaults": {
  127. "type": "long",
  128. "time_series_metric": "gauge"
  129. },
  130. "rss": {
  131. "properties": {
  132. "bytes": {
  133. "type": "long",
  134. "time_series_metric": "gauge"
  135. }
  136. }
  137. },
  138. "usage": {
  139. "properties": {
  140. "bytes": {
  141. "type": "long",
  142. "time_series_metric": "gauge"
  143. },
  144. "limit": {
  145. "properties": {
  146. "pct": {
  147. "type": "float"
  148. }
  149. }
  150. },
  151. "node": {
  152. "properties": {
  153. "pct": {
  154. "type": "float"
  155. }
  156. }
  157. }
  158. }
  159. },
  160. "workingset": {
  161. "properties": {
  162. "bytes": {
  163. "type": "long",
  164. "time_series_metric": "gauge"
  165. }
  166. }
  167. }
  168. }
  169. },
  170. "name": {
  171. "type": "keyword"
  172. },
  173. "start_time": {
  174. "type": "date"
  175. }
  176. }
  177. },
  178. "host": {
  179. "type": "keyword",
  180. "time_series_dimension": true
  181. },
  182. "namespace": {
  183. "type": "keyword",
  184. "time_series_dimension": true
  185. },
  186. "node": {
  187. "type": "keyword",
  188. "time_series_dimension": true
  189. },
  190. "pod": {
  191. "type": "keyword",
  192. "time_series_dimension": true
  193. }
  194. }
  195. }
  196. }
  197. }
  198. }
  199. }
  200. ----
  201. [discrete]
  202. [[downsampling-manual-ingest-data]]
  203. ==== Ingest time series data
  204. Because time series data streams have been designed to
  205. <<tsds-accepted-time-range,only accept recent data>>, in this example, you'll
  206. use an ingest pipeline to time-shift the data as it gets indexed. As a result,
  207. the indexed data will have an `@timestamp` from the last 15 minutes.
  208. Create the pipeline with this request:
  209. [source,console]
  210. ----
  211. PUT _ingest/pipeline/my-timestamp-pipeline
  212. {
  213. "description": "Shifts the @timestamp to the last 15 minutes",
  214. "processors": [
  215. {
  216. "set": {
  217. "field": "ingest_time",
  218. "value": "{{_ingest.timestamp}}"
  219. }
  220. },
  221. {
  222. "script": {
  223. "lang": "painless",
  224. "source": """
  225. def delta = ChronoUnit.SECONDS.between(
  226. ZonedDateTime.parse("2022-06-21T15:49:00Z"),
  227. ZonedDateTime.parse(ctx["ingest_time"])
  228. );
  229. ctx["@timestamp"] = ZonedDateTime.parse(ctx["@timestamp"]).plus(delta,ChronoUnit.SECONDS).toString();
  230. """
  231. }
  232. }
  233. ]
  234. }
  235. ----
  236. // TEST[continued]
  237. Next, use a bulk API request to automatically create your TSDS and index a set
  238. of ten documents:
  239. [source,console]
  240. ----
  241. PUT /my-data-stream/_bulk?refresh&pipeline=my-timestamp-pipeline
  242. {"create": {}}
  243. {"@timestamp":"2022-06-21T15:49:00Z","kubernetes":{"host":"gke-apps-0","node":"gke-apps-0-0","pod":"gke-apps-0-0-0","container":{"cpu":{"usage":{"nanocores":91153,"core":{"ns":12828317850},"node":{"pct":2.77905e-05},"limit":{"pct":2.77905e-05}}},"memory":{"available":{"bytes":463314616},"usage":{"bytes":307007078,"node":{"pct":0.01770037710617187},"limit":{"pct":9.923134671484496e-05}},"workingset":{"bytes":585236},"rss":{"bytes":102728},"pagefaults":120901,"majorpagefaults":0},"start_time":"2021-03-30T07:59:06Z","name":"container-name-44"},"namespace":"namespace26"}}
  244. {"create": {}}
  245. {"@timestamp":"2022-06-21T15:45:50Z","kubernetes":{"host":"gke-apps-0","node":"gke-apps-0-0","pod":"gke-apps-0-0-0","container":{"cpu":{"usage":{"nanocores":124501,"core":{"ns":12828317850},"node":{"pct":2.77905e-05},"limit":{"pct":2.77905e-05}}},"memory":{"available":{"bytes":982546514},"usage":{"bytes":360035574,"node":{"pct":0.01770037710617187},"limit":{"pct":9.923134671484496e-05}},"workingset":{"bytes":1339884},"rss":{"bytes":381174},"pagefaults":178473,"majorpagefaults":0},"start_time":"2021-03-30T07:59:06Z","name":"container-name-44"},"namespace":"namespace26"}}
  246. {"create": {}}
  247. {"@timestamp":"2022-06-21T15:44:50Z","kubernetes":{"host":"gke-apps-0","node":"gke-apps-0-0","pod":"gke-apps-0-0-0","container":{"cpu":{"usage":{"nanocores":38907,"core":{"ns":12828317850},"node":{"pct":2.77905e-05},"limit":{"pct":2.77905e-05}}},"memory":{"available":{"bytes":862723768},"usage":{"bytes":379572388,"node":{"pct":0.01770037710617187},"limit":{"pct":9.923134671484496e-05}},"workingset":{"bytes":431227},"rss":{"bytes":386580},"pagefaults":233166,"majorpagefaults":0},"start_time":"2021-03-30T07:59:06Z","name":"container-name-44"},"namespace":"namespace26"}}
  248. {"create": {}}
  249. {"@timestamp":"2022-06-21T15:44:40Z","kubernetes":{"host":"gke-apps-0","node":"gke-apps-0-0","pod":"gke-apps-0-0-0","container":{"cpu":{"usage":{"nanocores":86706,"core":{"ns":12828317850},"node":{"pct":2.77905e-05},"limit":{"pct":2.77905e-05}}},"memory":{"available":{"bytes":567160996},"usage":{"bytes":103266017,"node":{"pct":0.01770037710617187},"limit":{"pct":9.923134671484496e-05}},"workingset":{"bytes":1724908},"rss":{"bytes":105431},"pagefaults":233166,"majorpagefaults":0},"start_time":"2021-03-30T07:59:06Z","name":"container-name-44"},"namespace":"namespace26"}}
  250. {"create": {}}
  251. {"@timestamp":"2022-06-21T15:44:00Z","kubernetes":{"host":"gke-apps-0","node":"gke-apps-0-0","pod":"gke-apps-0-0-0","container":{"cpu":{"usage":{"nanocores":150069,"core":{"ns":12828317850},"node":{"pct":2.77905e-05},"limit":{"pct":2.77905e-05}}},"memory":{"available":{"bytes":639054643},"usage":{"bytes":265142477,"node":{"pct":0.01770037710617187},"limit":{"pct":9.923134671484496e-05}},"workingset":{"bytes":1786511},"rss":{"bytes":189235},"pagefaults":138172,"majorpagefaults":0},"start_time":"2021-03-30T07:59:06Z","name":"container-name-44"},"namespace":"namespace26"}}
  252. {"create": {}}
  253. {"@timestamp":"2022-06-21T15:42:40Z","kubernetes":{"host":"gke-apps-0","node":"gke-apps-0-0","pod":"gke-apps-0-0-0","container":{"cpu":{"usage":{"nanocores":82260,"core":{"ns":12828317850},"node":{"pct":2.77905e-05},"limit":{"pct":2.77905e-05}}},"memory":{"available":{"bytes":854735585},"usage":{"bytes":309798052,"node":{"pct":0.01770037710617187},"limit":{"pct":9.923134671484496e-05}},"workingset":{"bytes":924058},"rss":{"bytes":110838},"pagefaults":259073,"majorpagefaults":0},"start_time":"2021-03-30T07:59:06Z","name":"container-name-44"},"namespace":"namespace26"}}
  254. {"create": {}}
  255. {"@timestamp":"2022-06-21T15:42:10Z","kubernetes":{"host":"gke-apps-0","node":"gke-apps-0-0","pod":"gke-apps-0-0-0","container":{"cpu":{"usage":{"nanocores":153404,"core":{"ns":12828317850},"node":{"pct":2.77905e-05},"limit":{"pct":2.77905e-05}}},"memory":{"available":{"bytes":279586406},"usage":{"bytes":214904955,"node":{"pct":0.01770037710617187},"limit":{"pct":9.923134671484496e-05}},"workingset":{"bytes":1047265},"rss":{"bytes":91914},"pagefaults":302252,"majorpagefaults":0},"start_time":"2021-03-30T07:59:06Z","name":"container-name-44"},"namespace":"namespace26"}}
  256. {"create": {}}
  257. {"@timestamp":"2022-06-21T15:40:20Z","kubernetes":{"host":"gke-apps-0","node":"gke-apps-0-0","pod":"gke-apps-0-0-0","container":{"cpu":{"usage":{"nanocores":125613,"core":{"ns":12828317850},"node":{"pct":2.77905e-05},"limit":{"pct":2.77905e-05}}},"memory":{"available":{"bytes":822782853},"usage":{"bytes":100475044,"node":{"pct":0.01770037710617187},"limit":{"pct":9.923134671484496e-05}},"workingset":{"bytes":2109932},"rss":{"bytes":278446},"pagefaults":74843,"majorpagefaults":0},"start_time":"2021-03-30T07:59:06Z","name":"container-name-44"},"namespace":"namespace26"}}
  258. {"create": {}}
  259. {"@timestamp":"2022-06-21T15:40:10Z","kubernetes":{"host":"gke-apps-0","node":"gke-apps-0-0","pod":"gke-apps-0-0-0","container":{"cpu":{"usage":{"nanocores":100046,"core":{"ns":12828317850},"node":{"pct":2.77905e-05},"limit":{"pct":2.77905e-05}}},"memory":{"available":{"bytes":567160996},"usage":{"bytes":362826547,"node":{"pct":0.01770037710617187},"limit":{"pct":9.923134671484496e-05}},"workingset":{"bytes":1986724},"rss":{"bytes":402801},"pagefaults":296495,"majorpagefaults":0},"start_time":"2021-03-30T07:59:06Z","name":"container-name-44"},"namespace":"namespace26"}}
  260. {"create": {}}
  261. {"@timestamp":"2022-06-21T15:38:30Z","kubernetes":{"host":"gke-apps-0","node":"gke-apps-0-0","pod":"gke-apps-0-0-0","container":{"cpu":{"usage":{"nanocores":40018,"core":{"ns":12828317850},"node":{"pct":2.77905e-05},"limit":{"pct":2.77905e-05}}},"memory":{"available":{"bytes":1062428344},"usage":{"bytes":265142477,"node":{"pct":0.01770037710617187},"limit":{"pct":9.923134671484496e-05}},"workingset":{"bytes":2294743},"rss":{"bytes":340623},"pagefaults":224530,"majorpagefaults":0},"start_time":"2021-03-30T07:59:06Z","name":"container-name-44"},"namespace":"namespace26"}}
  262. ----
  263. // TEST[continued]
  264. You can use the search API to check if the documents have been indexed
  265. correctly:
  266. [source,console]
  267. ----
  268. GET /my-data-stream/_search
  269. ----
  270. // TEST[continued]
  271. Run the following aggregation on the data to calculate some interesting
  272. statistics:
  273. [source,console]
  274. ----
  275. GET /my-data-stream/_search
  276. {
  277. "size": 0,
  278. "aggs": {
  279. "tsid": {
  280. "terms": {
  281. "field": "_tsid"
  282. },
  283. "aggs": {
  284. "over_time": {
  285. "date_histogram": {
  286. "field": "@timestamp",
  287. "fixed_interval": "1d"
  288. },
  289. "aggs": {
  290. "min": {
  291. "min": {
  292. "field": "kubernetes.container.memory.usage.bytes"
  293. }
  294. },
  295. "max": {
  296. "max": {
  297. "field": "kubernetes.container.memory.usage.bytes"
  298. }
  299. },
  300. "avg": {
  301. "avg": {
  302. "field": "kubernetes.container.memory.usage.bytes"
  303. }
  304. }
  305. }
  306. }
  307. }
  308. }
  309. }
  310. }
  311. ----
  312. // TEST[continued]
  313. [discrete]
  314. [[downsampling-manual-run]]
  315. ==== Downsample the TSDS
  316. A TSDS can't be downsampled directly. You need to downsample its backing indices
  317. instead. You can see the backing index for your data stream by running:
  318. [source,console]
  319. ----
  320. GET /_data_stream/my-data-stream
  321. ----
  322. // TEST[continued]
  323. This returns:
  324. [source,console-result]
  325. ----
  326. {
  327. "data_streams": [
  328. {
  329. "name": "my-data-stream",
  330. "timestamp_field": {
  331. "name": "@timestamp"
  332. },
  333. "indices": [
  334. {
  335. "index_name": ".ds-my-data-stream-2023.07.26-000001", <1>
  336. "index_uuid": "ltOJGmqgTVm4T-Buoe7Acg",
  337. "prefer_ilm": true,
  338. "managed_by": "Unmanaged"
  339. }
  340. ],
  341. "generation": 1,
  342. "status": "GREEN",
  343. "next_generation_managed_by": "Unmanaged",
  344. "prefer_ilm": true,
  345. "template": "my-data-stream-template",
  346. "hidden": false,
  347. "system": false,
  348. "allow_custom_routing": false,
  349. "replicated": false,
  350. "rollover_on_write": false,
  351. "time_series": {
  352. "temporal_ranges": [
  353. {
  354. "start": "2023-07-26T09:26:42.000Z",
  355. "end": "2023-07-26T13:26:42.000Z"
  356. }
  357. ]
  358. }
  359. }
  360. ]
  361. }
  362. ----
  363. // TESTRESPONSE[s/".ds-my-data-stream-2023.07.26-000001"/$body.data_streams.0.indices.0.index_name/]
  364. // TESTRESPONSE[s/"ltOJGmqgTVm4T-Buoe7Acg"/$body.data_streams.0.indices.0.index_uuid/]
  365. // TESTRESPONSE[s/"2023-07-26T09:26:42.000Z"/$body.data_streams.0.time_series.temporal_ranges.0.start/]
  366. // TESTRESPONSE[s/"2023-07-26T13:26:42.000Z"/$body.data_streams.0.time_series.temporal_ranges.0.end/]
  367. // TESTRESPONSE[s/"replicated": false/"replicated": false,"failure_store":{"enabled": false, "indices": [], "rollover_on_write": true}/]
  368. <1> The backing index for this data stream.
  369. Before a backing index can be downsampled, the TSDS needs to be rolled over and
  370. the old index needs to be made read-only.
  371. Roll over the TSDS using the <<indices-rollover-index,rollover API>>:
  372. [source,console]
  373. ----
  374. POST /my-data-stream/_rollover/
  375. ----
  376. // TEST[continued]
  377. Copy the name of the `old_index` from the response. In the following steps,
  378. replace the index name with that of your `old_index`.
  379. The old index needs to be set to read-only mode. Run the following request:
  380. [source,console]
  381. ----
  382. PUT /.ds-my-data-stream-2023.07.26-000001/_block/write
  383. ----
  384. // TEST[skip:We don't know the index name at test time]
  385. Next, use the <<indices-downsample-data-stream,downsample API>> to downsample
  386. the index, setting the time series interval to one hour:
  387. [source,console]
  388. ----
  389. POST /.ds-my-data-stream-2023.07.26-000001/_downsample/.ds-my-data-stream-2023.07.26-000001-downsample
  390. {
  391. "fixed_interval": "1h"
  392. }
  393. ----
  394. // TEST[skip:We don't know the index name at test time]
  395. Now you can <<modify-data-streams-api,modify the data stream>>, and replace the
  396. original index with the downsampled one:
  397. [source,console]
  398. ----
  399. POST _data_stream/_modify
  400. {
  401. "actions": [
  402. {
  403. "remove_backing_index": {
  404. "data_stream": "my-data-stream",
  405. "index": ".ds-my-data-stream-2023.07.26-000001"
  406. }
  407. },
  408. {
  409. "add_backing_index": {
  410. "data_stream": "my-data-stream",
  411. "index": ".ds-my-data-stream-2023.07.26-000001-downsample"
  412. }
  413. }
  414. ]
  415. }
  416. ----
  417. // TEST[skip:We don't know the index name at test time]
  418. You can now delete the old backing index. But be aware this will delete the
  419. original data. Don't delete the index if you may need the original data in the
  420. future.
  421. [discrete]
  422. [[downsampling-manual-view-results]]
  423. ==== View the results
  424. Re-run the earlier search query (note that when querying downsampled indices
  425. there are <<querying-downsampled-indices-notes,a few nuances to be aware of>>):
  426. [source,console]
  427. ----
  428. GET /my-data-stream/_search
  429. ----
  430. // TEST[skip:Because we've skipped the previous steps]
  431. The TSDS with the new downsampled backing index contains just one document. For
  432. counters, this document would only have the last value. For gauges, the field
  433. type is now `aggregate_metric_double`. You see the `min`, `max`, `sum`, and
  434. `value_count` statistics based off of the original sampled metrics:
  435. [source,console-result]
  436. ----
  437. {
  438. "took": 2,
  439. "timed_out": false,
  440. "_shards": {
  441. "total": 4,
  442. "successful": 4,
  443. "skipped": 0,
  444. "failed": 0
  445. },
  446. "hits": {
  447. "total": {
  448. "value": 1,
  449. "relation": "eq"
  450. },
  451. "max_score": 1,
  452. "hits": [
  453. {
  454. "_index": ".ds-my-data-stream-2023.07.26-000001-downsample",
  455. "_id": "0eL0wC_4-45SnTNFAAABiZHbD4A",
  456. "_score": 1,
  457. "_source": {
  458. "@timestamp": "2023-07-26T11:00:00.000Z",
  459. "_doc_count": 10,
  460. "ingest_time": "2023-07-26T11:26:42.715Z",
  461. "kubernetes": {
  462. "container": {
  463. "cpu": {
  464. "usage": {
  465. "core": {
  466. "ns": 12828317850
  467. },
  468. "limit": {
  469. "pct": 0.0000277905
  470. },
  471. "nanocores": {
  472. "min": 38907,
  473. "max": 153404,
  474. "sum": 992677,
  475. "value_count": 10
  476. },
  477. "node": {
  478. "pct": 0.0000277905
  479. }
  480. }
  481. },
  482. "memory": {
  483. "available": {
  484. "bytes": {
  485. "min": 279586406,
  486. "max": 1062428344,
  487. "sum": 7101494721,
  488. "value_count": 10
  489. }
  490. },
  491. "majorpagefaults": 0,
  492. "pagefaults": {
  493. "min": 74843,
  494. "max": 302252,
  495. "sum": 2061071,
  496. "value_count": 10
  497. },
  498. "rss": {
  499. "bytes": {
  500. "min": 91914,
  501. "max": 402801,
  502. "sum": 2389770,
  503. "value_count": 10
  504. }
  505. },
  506. "usage": {
  507. "bytes": {
  508. "min": 100475044,
  509. "max": 379572388,
  510. "sum": 2668170609,
  511. "value_count": 10
  512. },
  513. "limit": {
  514. "pct": 0.00009923134
  515. },
  516. "node": {
  517. "pct": 0.017700378
  518. }
  519. },
  520. "workingset": {
  521. "bytes": {
  522. "min": 431227,
  523. "max": 2294743,
  524. "sum": 14230488,
  525. "value_count": 10
  526. }
  527. }
  528. },
  529. "name": "container-name-44",
  530. "start_time": "2021-03-30T07:59:06.000Z"
  531. },
  532. "host": "gke-apps-0",
  533. "namespace": "namespace26",
  534. "node": "gke-apps-0-0",
  535. "pod": "gke-apps-0-0-0"
  536. }
  537. }
  538. }
  539. ]
  540. }
  541. }
  542. ----
  543. // TEST[skip:Because we've skipped the previous step]
  544. Re-run the earlier aggregation. Even though the aggregation runs on the
  545. downsampled TSDS that only contains 1 document, it returns the same results as
  546. the earlier aggregation on the original TSDS.
  547. [source,console]
  548. ----
  549. GET /my-data-stream/_search
  550. {
  551. "size": 0,
  552. "aggs": {
  553. "tsid": {
  554. "terms": {
  555. "field": "_tsid"
  556. },
  557. "aggs": {
  558. "over_time": {
  559. "date_histogram": {
  560. "field": "@timestamp",
  561. "fixed_interval": "1d"
  562. },
  563. "aggs": {
  564. "min": {
  565. "min": {
  566. "field": "kubernetes.container.memory.usage.bytes"
  567. }
  568. },
  569. "max": {
  570. "max": {
  571. "field": "kubernetes.container.memory.usage.bytes"
  572. }
  573. },
  574. "avg": {
  575. "avg": {
  576. "field": "kubernetes.container.memory.usage.bytes"
  577. }
  578. }
  579. }
  580. }
  581. }
  582. }
  583. }
  584. }
  585. ----
  586. // TEST[skip:Because we've skipped the previous steps]
  587. This example demonstrates how downsampling can dramatically reduce the number of
  588. documents stored for time series data, within whatever time boundaries you
  589. choose. It's also possible to perform downsampling on already downsampled data,
  590. to further reduce storage and associated costs, as the time series data ages and
  591. the data resolution becomes less critical.
  592. The recommended way to downsample a TSDS is with ILM. To learn more, try the
  593. <<downsampling-ilm,Run downsampling with ILM>> example.