ILMを使用したダウンサンプリングの実行

これは、サンプリングされたメトリックセットのストレージサイズを削減するためのILMポリシーの一部として、ダウンサンプリングがどのように機能するかを迅速に確認できる簡略化された例です。この例では、典型的なKubernetesクラスターの監視データを使用しています。ILMを使用したダウンサンプリングをテストするには、次の手順に従ってください:

前提条件

時系列データストリームの前提条件を参照してください。

この例を実行する前に、手動でダウンサンプリングを実行する例を試してみることをお勧めします。

インデックスライフサイクルポリシーの作成

時系列データ用のILMポリシーを作成します。必須ではありませんが、時系列データストリームインデックスの管理を自動化するためにILMポリシーを推奨します。

ダウンサンプリングを有効にするには、ダウンサンプルアクションを追加し、元の時系列データを集約したいダウンサンプリング間隔にfixed_intervalを設定します。

この例では、hotフェーズのためにILMポリシーが構成されています。ダウンサンプリングは、インデックスがロールオーバーされた後、インデックスの時系列終了時間が経過した後に行われます。ソースインデックスはその時点まで主要な書き込みを受け取ることが期待されているためです。インデックスライフサイクル管理は、インデックスの終了時間が経過するまで、インデックスがもはや書き込みを受け取らないことを期待するアクションを進めません。終了時間を待つインデックスライフサイクル管理アクションは次のとおりです: - 削除 - ダウンサンプル - 強制マージ - 読み取り専用 - 検索可能スナップショット - 縮小

Python

  1. resp = client.ilm.put_lifecycle(
  2. name="datastream_policy",
  3. policy={
  4. "phases": {
  5. "hot": {
  6. "actions": {
  7. "rollover": {
  8. "max_age": "5m"
  9. },
  10. "downsample": {
  11. "fixed_interval": "1h"
  12. }
  13. }
  14. }
  15. }
  16. },
  17. )
  18. print(resp)

Ruby

  1. response = client.ilm.put_lifecycle(
  2. policy: 'datastream_policy',
  3. body: {
  4. policy: {
  5. phases: {
  6. hot: {
  7. actions: {
  8. rollover: {
  9. max_age: '5m'
  10. },
  11. downsample: {
  12. fixed_interval: '1h'
  13. }
  14. }
  15. }
  16. }
  17. }
  18. }
  19. )
  20. puts response

Js

  1. const response = await client.ilm.putLifecycle({
  2. name: "datastream_policy",
  3. policy: {
  4. phases: {
  5. hot: {
  6. actions: {
  7. rollover: {
  8. max_age: "5m",
  9. },
  10. downsample: {
  11. fixed_interval: "1h",
  12. },
  13. },
  14. },
  15. },
  16. },
  17. });
  18. console.log(response);

Console

  1. PUT _ilm/policy/datastream_policy
  2. {
  3. "policy": {
  4. "phases": {
  5. "hot": {
  6. "actions": {
  7. "rollover" : {
  8. "max_age": "5m"
  9. },
  10. "downsample": {
  11. "fixed_interval": "1h"
  12. }
  13. }
  14. }
  15. }
  16. }
  17. }

インデックステンプレートの作成

これは基本的なデータストリームのためのインデックステンプレートを作成します。インデックステンプレートの利用可能なパラメータは、時系列データストリームの設定で詳細に説明されています。

簡単のために、時系列マッピングではすべてのtime_series_metricパラメータがgauge型に設定されていますが、counterメトリックタイプも使用できます。time_series_metric値は、ダウンサンプリング中に使用される統計的表現の種類を決定します。

インデックステンプレートには、静的な時系列次元のセットが含まれています:hostnamespacenode、およびpod。時系列次元はダウンサンプリングプロセスによって変更されません。

Python

  1. resp = client.indices.put_index_template(
  2. name="datastream_template",
  3. index_patterns=[
  4. "datastream*"
  5. ],
  6. data_stream={},
  7. template={
  8. "settings": {
  9. "index": {
  10. "mode": "time_series",
  11. "number_of_replicas": 0,
  12. "number_of_shards": 2
  13. },
  14. "index.lifecycle.name": "datastream_policy"
  15. },
  16. "mappings": {
  17. "properties": {
  18. "@timestamp": {
  19. "type": "date"
  20. },
  21. "kubernetes": {
  22. "properties": {
  23. "container": {
  24. "properties": {
  25. "cpu": {
  26. "properties": {
  27. "usage": {
  28. "properties": {
  29. "core": {
  30. "properties": {
  31. "ns": {
  32. "type": "long"
  33. }
  34. }
  35. },
  36. "limit": {
  37. "properties": {
  38. "pct": {
  39. "type": "float"
  40. }
  41. }
  42. },
  43. "nanocores": {
  44. "type": "long",
  45. "time_series_metric": "gauge"
  46. },
  47. "node": {
  48. "properties": {
  49. "pct": {
  50. "type": "float"
  51. }
  52. }
  53. }
  54. }
  55. }
  56. }
  57. },
  58. "memory": {
  59. "properties": {
  60. "available": {
  61. "properties": {
  62. "bytes": {
  63. "type": "long",
  64. "time_series_metric": "gauge"
  65. }
  66. }
  67. },
  68. "majorpagefaults": {
  69. "type": "long"
  70. },
  71. "pagefaults": {
  72. "type": "long",
  73. "time_series_metric": "gauge"
  74. },
  75. "rss": {
  76. "properties": {
  77. "bytes": {
  78. "type": "long",
  79. "time_series_metric": "gauge"
  80. }
  81. }
  82. },
  83. "usage": {
  84. "properties": {
  85. "bytes": {
  86. "type": "long",
  87. "time_series_metric": "gauge"
  88. },
  89. "limit": {
  90. "properties": {
  91. "pct": {
  92. "type": "float"
  93. }
  94. }
  95. },
  96. "node": {
  97. "properties": {
  98. "pct": {
  99. "type": "float"
  100. }
  101. }
  102. }
  103. }
  104. },
  105. "workingset": {
  106. "properties": {
  107. "bytes": {
  108. "type": "long",
  109. "time_series_metric": "gauge"
  110. }
  111. }
  112. }
  113. }
  114. },
  115. "name": {
  116. "type": "keyword"
  117. },
  118. "start_time": {
  119. "type": "date"
  120. }
  121. }
  122. },
  123. "host": {
  124. "type": "keyword",
  125. "time_series_dimension": True
  126. },
  127. "namespace": {
  128. "type": "keyword",
  129. "time_series_dimension": True
  130. },
  131. "node": {
  132. "type": "keyword",
  133. "time_series_dimension": True
  134. },
  135. "pod": {
  136. "type": "keyword",
  137. "time_series_dimension": True
  138. }
  139. }
  140. }
  141. }
  142. }
  143. },
  144. )
  145. print(resp)

Ruby

  1. response = client.indices.put_index_template(
  2. name: 'datastream_template',
  3. body: {
  4. index_patterns: [
  5. 'datastream*'
  6. ],
  7. data_stream: {},
  8. template: {
  9. settings: {
  10. index: {
  11. mode: 'time_series',
  12. number_of_replicas: 0,
  13. number_of_shards: 2
  14. },
  15. 'index.lifecycle.name' => 'datastream_policy'
  16. },
  17. mappings: {
  18. properties: {
  19. "@timestamp": {
  20. type: 'date'
  21. },
  22. kubernetes: {
  23. properties: {
  24. container: {
  25. properties: {
  26. cpu: {
  27. properties: {
  28. usage: {
  29. properties: {
  30. core: {
  31. properties: {
  32. ns: {
  33. type: 'long'
  34. }
  35. }
  36. },
  37. limit: {
  38. properties: {
  39. pct: {
  40. type: 'float'
  41. }
  42. }
  43. },
  44. nanocores: {
  45. type: 'long',
  46. time_series_metric: 'gauge'
  47. },
  48. node: {
  49. properties: {
  50. pct: {
  51. type: 'float'
  52. }
  53. }
  54. }
  55. }
  56. }
  57. }
  58. },
  59. memory: {
  60. properties: {
  61. available: {
  62. properties: {
  63. bytes: {
  64. type: 'long',
  65. time_series_metric: 'gauge'
  66. }
  67. }
  68. },
  69. majorpagefaults: {
  70. type: 'long'
  71. },
  72. pagefaults: {
  73. type: 'long',
  74. time_series_metric: 'gauge'
  75. },
  76. rss: {
  77. properties: {
  78. bytes: {
  79. type: 'long',
  80. time_series_metric: 'gauge'
  81. }
  82. }
  83. },
  84. usage: {
  85. properties: {
  86. bytes: {
  87. type: 'long',
  88. time_series_metric: 'gauge'
  89. },
  90. limit: {
  91. properties: {
  92. pct: {
  93. type: 'float'
  94. }
  95. }
  96. },
  97. node: {
  98. properties: {
  99. pct: {
  100. type: 'float'
  101. }
  102. }
  103. }
  104. }
  105. },
  106. workingset: {
  107. properties: {
  108. bytes: {
  109. type: 'long',
  110. time_series_metric: 'gauge'
  111. }
  112. }
  113. }
  114. }
  115. },
  116. name: {
  117. type: 'keyword'
  118. },
  119. start_time: {
  120. type: 'date'
  121. }
  122. }
  123. },
  124. host: {
  125. type: 'keyword',
  126. time_series_dimension: true
  127. },
  128. namespace: {
  129. type: 'keyword',
  130. time_series_dimension: true
  131. },
  132. node: {
  133. type: 'keyword',
  134. time_series_dimension: true
  135. },
  136. pod: {
  137. type: 'keyword',
  138. time_series_dimension: true
  139. }
  140. }
  141. }
  142. }
  143. }
  144. }
  145. }
  146. )
  147. puts response

Js

  1. const response = await client.indices.putIndexTemplate({
  2. name: "datastream_template",
  3. index_patterns: ["datastream*"],
  4. data_stream: {},
  5. template: {
  6. settings: {
  7. index: {
  8. mode: "time_series",
  9. number_of_replicas: 0,
  10. number_of_shards: 2,
  11. },
  12. "index.lifecycle.name": "datastream_policy",
  13. },
  14. mappings: {
  15. properties: {
  16. "@timestamp": {
  17. type: "date",
  18. },
  19. kubernetes: {
  20. properties: {
  21. container: {
  22. properties: {
  23. cpu: {
  24. properties: {
  25. usage: {
  26. properties: {
  27. core: {
  28. properties: {
  29. ns: {
  30. type: "long",
  31. },
  32. },
  33. },
  34. limit: {
  35. properties: {
  36. pct: {
  37. type: "float",
  38. },
  39. },
  40. },
  41. nanocores: {
  42. type: "long",
  43. time_series_metric: "gauge",
  44. },
  45. node: {
  46. properties: {
  47. pct: {
  48. type: "float",
  49. },
  50. },
  51. },
  52. },
  53. },
  54. },
  55. },
  56. memory: {
  57. properties: {
  58. available: {
  59. properties: {
  60. bytes: {
  61. type: "long",
  62. time_series_metric: "gauge",
  63. },
  64. },
  65. },
  66. majorpagefaults: {
  67. type: "long",
  68. },
  69. pagefaults: {
  70. type: "long",
  71. time_series_metric: "gauge",
  72. },
  73. rss: {
  74. properties: {
  75. bytes: {
  76. type: "long",
  77. time_series_metric: "gauge",
  78. },
  79. },
  80. },
  81. usage: {
  82. properties: {
  83. bytes: {
  84. type: "long",
  85. time_series_metric: "gauge",
  86. },
  87. limit: {
  88. properties: {
  89. pct: {
  90. type: "float",
  91. },
  92. },
  93. },
  94. node: {
  95. properties: {
  96. pct: {
  97. type: "float",
  98. },
  99. },
  100. },
  101. },
  102. },
  103. workingset: {
  104. properties: {
  105. bytes: {
  106. type: "long",
  107. time_series_metric: "gauge",
  108. },
  109. },
  110. },
  111. },
  112. },
  113. name: {
  114. type: "keyword",
  115. },
  116. start_time: {
  117. type: "date",
  118. },
  119. },
  120. },
  121. host: {
  122. type: "keyword",
  123. time_series_dimension: true,
  124. },
  125. namespace: {
  126. type: "keyword",
  127. time_series_dimension: true,
  128. },
  129. node: {
  130. type: "keyword",
  131. time_series_dimension: true,
  132. },
  133. pod: {
  134. type: "keyword",
  135. time_series_dimension: true,
  136. },
  137. },
  138. },
  139. },
  140. },
  141. },
  142. });
  143. console.log(response);

Console

  1. PUT _index_template/datastream_template
  2. {
  3. "index_patterns": [
  4. "datastream*"
  5. ],
  6. "data_stream": {},
  7. "template": {
  8. "settings": {
  9. "index": {
  10. "mode": "time_series",
  11. "number_of_replicas": 0,
  12. "number_of_shards": 2
  13. },
  14. "index.lifecycle.name": "datastream_policy"
  15. },
  16. "mappings": {
  17. "properties": {
  18. "@timestamp": {
  19. "type": "date"
  20. },
  21. "kubernetes": {
  22. "properties": {
  23. "container": {
  24. "properties": {
  25. "cpu": {
  26. "properties": {
  27. "usage": {
  28. "properties": {
  29. "core": {
  30. "properties": {
  31. "ns": {
  32. "type": "long"
  33. }
  34. }
  35. },
  36. "limit": {
  37. "properties": {
  38. "pct": {
  39. "type": "float"
  40. }
  41. }
  42. },
  43. "nanocores": {
  44. "type": "long",
  45. "time_series_metric": "gauge"
  46. },
  47. "node": {
  48. "properties": {
  49. "pct": {
  50. "type": "float"
  51. }
  52. }
  53. }
  54. }
  55. }
  56. }
  57. },
  58. "memory": {
  59. "properties": {
  60. "available": {
  61. "properties": {
  62. "bytes": {
  63. "type": "long",
  64. "time_series_metric": "gauge"
  65. }
  66. }
  67. },
  68. "majorpagefaults": {
  69. "type": "long"
  70. },
  71. "pagefaults": {
  72. "type": "long",
  73. "time_series_metric": "gauge"
  74. },
  75. "rss": {
  76. "properties": {
  77. "bytes": {
  78. "type": "long",
  79. "time_series_metric": "gauge"
  80. }
  81. }
  82. },
  83. "usage": {
  84. "properties": {
  85. "bytes": {
  86. "type": "long",
  87. "time_series_metric": "gauge"
  88. },
  89. "limit": {
  90. "properties": {
  91. "pct": {
  92. "type": "float"
  93. }
  94. }
  95. },
  96. "node": {
  97. "properties": {
  98. "pct": {
  99. "type": "float"
  100. }
  101. }
  102. }
  103. }
  104. },
  105. "workingset": {
  106. "properties": {
  107. "bytes": {
  108. "type": "long",
  109. "time_series_metric": "gauge"
  110. }
  111. }
  112. }
  113. }
  114. },
  115. "name": {
  116. "type": "keyword"
  117. },
  118. "start_time": {
  119. "type": "date"
  120. }
  121. }
  122. },
  123. "host": {
  124. "type": "keyword",
  125. "time_series_dimension": true
  126. },
  127. "namespace": {
  128. "type": "keyword",
  129. "time_series_dimension": true
  130. },
  131. "node": {
  132. "type": "keyword",
  133. "time_series_dimension": true
  134. },
  135. "pod": {
  136. "type": "keyword",
  137. "time_series_dimension": true
  138. }
  139. }
  140. }
  141. }
  142. }
  143. }
  144. }

時系列データの取り込み

バルクAPIリクエストを使用して、TSDSを自動的に作成し、10件のドキュメントをインデックスします。

重要: このバルクリクエストを実行する前に、タイムスタンプを現在の時間の3〜5時間後に更新する必要があります。つまり、2022-06-21T15を検索し、現在の日付に置き換え、時間を現在の時間に3時間加えます。

Python

  1. resp = client.bulk(
  2. index="datastream",
  3. refresh=True,
  4. operations=[
  5. {
  6. "create": {}
  7. },
  8. {
  9. "@timestamp": "2022-06-21T15:49:00Z",
  10. "kubernetes": {
  11. "host": "gke-apps-0",
  12. "node": "gke-apps-0-0",
  13. "pod": "gke-apps-0-0-0",
  14. "container": {
  15. "cpu": {
  16. "usage": {
  17. "nanocores": 91153,
  18. "core": {
  19. "ns": 12828317850
  20. },
  21. "node": {
  22. "pct": 0.0000277905
  23. },
  24. "limit": {
  25. "pct": 0.0000277905
  26. }
  27. }
  28. },
  29. "memory": {
  30. "available": {
  31. "bytes": 463314616
  32. },
  33. "usage": {
  34. "bytes": 307007078,
  35. "node": {
  36. "pct": 0.01770037710617187
  37. },
  38. "limit": {
  39. "pct": 0.00009923134671484496
  40. }
  41. },
  42. "workingset": {
  43. "bytes": 585236
  44. },
  45. "rss": {
  46. "bytes": 102728
  47. },
  48. "pagefaults": 120901,
  49. "majorpagefaults": 0
  50. },
  51. "start_time": "2021-03-30T07:59:06Z",
  52. "name": "container-name-44"
  53. },
  54. "namespace": "namespace26"
  55. }
  56. },
  57. {
  58. "create": {}
  59. },
  60. {
  61. "@timestamp": "2022-06-21T15:45:50Z",
  62. "kubernetes": {
  63. "host": "gke-apps-0",
  64. "node": "gke-apps-0-0",
  65. "pod": "gke-apps-0-0-0",
  66. "container": {
  67. "cpu": {
  68. "usage": {
  69. "nanocores": 124501,
  70. "core": {
  71. "ns": 12828317850
  72. },
  73. "node": {
  74. "pct": 0.0000277905
  75. },
  76. "limit": {
  77. "pct": 0.0000277905
  78. }
  79. }
  80. },
  81. "memory": {
  82. "available": {
  83. "bytes": 982546514
  84. },
  85. "usage": {
  86. "bytes": 360035574,
  87. "node": {
  88. "pct": 0.01770037710617187
  89. },
  90. "limit": {
  91. "pct": 0.00009923134671484496
  92. }
  93. },
  94. "workingset": {
  95. "bytes": 1339884
  96. },
  97. "rss": {
  98. "bytes": 381174
  99. },
  100. "pagefaults": 178473,
  101. "majorpagefaults": 0
  102. },
  103. "start_time": "2021-03-30T07:59:06Z",
  104. "name": "container-name-44"
  105. },
  106. "namespace": "namespace26"
  107. }
  108. },
  109. {
  110. "create": {}
  111. },
  112. {
  113. "@timestamp": "2022-06-21T15:44:50Z",
  114. "kubernetes": {
  115. "host": "gke-apps-0",
  116. "node": "gke-apps-0-0",
  117. "pod": "gke-apps-0-0-0",
  118. "container": {
  119. "cpu": {
  120. "usage": {
  121. "nanocores": 38907,
  122. "core": {
  123. "ns": 12828317850
  124. },
  125. "node": {
  126. "pct": 0.0000277905
  127. },
  128. "limit": {
  129. "pct": 0.0000277905
  130. }
  131. }
  132. },
  133. "memory": {
  134. "available": {
  135. "bytes": 862723768
  136. },
  137. "usage": {
  138. "bytes": 379572388,
  139. "node": {
  140. "pct": 0.01770037710617187
  141. },
  142. "limit": {
  143. "pct": 0.00009923134671484496
  144. }
  145. },
  146. "workingset": {
  147. "bytes": 431227
  148. },
  149. "rss": {
  150. "bytes": 386580
  151. },
  152. "pagefaults": 233166,
  153. "majorpagefaults": 0
  154. },
  155. "start_time": "2021-03-30T07:59:06Z",
  156. "name": "container-name-44"
  157. },
  158. "namespace": "namespace26"
  159. }
  160. },
  161. {
  162. "create": {}
  163. },
  164. {
  165. "@timestamp": "2022-06-21T15:44:40Z",
  166. "kubernetes": {
  167. "host": "gke-apps-0",
  168. "node": "gke-apps-0-0",
  169. "pod": "gke-apps-0-0-0",
  170. "container": {
  171. "cpu": {
  172. "usage": {
  173. "nanocores": 86706,
  174. "core": {
  175. "ns": 12828317850
  176. },
  177. "node": {
  178. "pct": 0.0000277905
  179. },
  180. "limit": {
  181. "pct": 0.0000277905
  182. }
  183. }
  184. },
  185. "memory": {
  186. "available": {
  187. "bytes": 567160996
  188. },
  189. "usage": {
  190. "bytes": 103266017,
  191. "node": {
  192. "pct": 0.01770037710617187
  193. },
  194. "limit": {
  195. "pct": 0.00009923134671484496
  196. }
  197. },
  198. "workingset": {
  199. "bytes": 1724908
  200. },
  201. "rss": {
  202. "bytes": 105431
  203. },
  204. "pagefaults": 233166,
  205. "majorpagefaults": 0
  206. },
  207. "start_time": "2021-03-30T07:59:06Z",
  208. "name": "container-name-44"
  209. },
  210. "namespace": "namespace26"
  211. }
  212. },
  213. {
  214. "create": {}
  215. },
  216. {
  217. "@timestamp": "2022-06-21T15:44:00Z",
  218. "kubernetes": {
  219. "host": "gke-apps-0",
  220. "node": "gke-apps-0-0",
  221. "pod": "gke-apps-0-0-0",
  222. "container": {
  223. "cpu": {
  224. "usage": {
  225. "nanocores": 150069,
  226. "core": {
  227. "ns": 12828317850
  228. },
  229. "node": {
  230. "pct": 0.0000277905
  231. },
  232. "limit": {
  233. "pct": 0.0000277905
  234. }
  235. }
  236. },
  237. "memory": {
  238. "available": {
  239. "bytes": 639054643
  240. },
  241. "usage": {
  242. "bytes": 265142477,
  243. "node": {
  244. "pct": 0.01770037710617187
  245. },
  246. "limit": {
  247. "pct": 0.00009923134671484496
  248. }
  249. },
  250. "workingset": {
  251. "bytes": 1786511
  252. },
  253. "rss": {
  254. "bytes": 189235
  255. },
  256. "pagefaults": 138172,
  257. "majorpagefaults": 0
  258. },
  259. "start_time": "2021-03-30T07:59:06Z",
  260. "name": "container-name-44"
  261. },
  262. "namespace": "namespace26"
  263. }
  264. },
  265. {
  266. "create": {}
  267. },
  268. {
  269. "@timestamp": "2022-06-21T15:42:40Z",
  270. "kubernetes": {
  271. "host": "gke-apps-0",
  272. "node": "gke-apps-0-0",
  273. "pod": "gke-apps-0-0-0",
  274. "container": {
  275. "cpu": {
  276. "usage": {
  277. "nanocores": 82260,
  278. "core": {
  279. "ns": 12828317850
  280. },
  281. "node": {
  282. "pct": 0.0000277905
  283. },
  284. "limit": {
  285. "pct": 0.0000277905
  286. }
  287. }
  288. },
  289. "memory": {
  290. "available": {
  291. "bytes": 854735585
  292. },
  293. "usage": {
  294. "bytes": 309798052,
  295. "node": {
  296. "pct": 0.01770037710617187
  297. },
  298. "limit": {
  299. "pct": 0.00009923134671484496
  300. }
  301. },
  302. "workingset": {
  303. "bytes": 924058
  304. },
  305. "rss": {
  306. "bytes": 110838
  307. },
  308. "pagefaults": 259073,
  309. "majorpagefaults": 0
  310. },
  311. "start_time": "2021-03-30T07:59:06Z",
  312. "name": "container-name-44"
  313. },
  314. "namespace": "namespace26"
  315. }
  316. },
  317. {
  318. "create": {}
  319. },
  320. {
  321. "@timestamp": "2022-06-21T15:42:10Z",
  322. "kubernetes": {
  323. "host": "gke-apps-0",
  324. "node": "gke-apps-0-0",
  325. "pod": "gke-apps-0-0-0",
  326. "container": {
  327. "cpu": {
  328. "usage": {
  329. "nanocores": 153404,
  330. "core": {
  331. "ns": 12828317850
  332. },
  333. "node": {
  334. "pct": 0.0000277905
  335. },
  336. "limit": {
  337. "pct": 0.0000277905
  338. }
  339. }
  340. },
  341. "memory": {
  342. "available": {
  343. "bytes": 279586406
  344. },
  345. "usage": {
  346. "bytes": 214904955,
  347. "node": {
  348. "pct": 0.01770037710617187
  349. },
  350. "limit": {
  351. "pct": 0.00009923134671484496
  352. }
  353. },
  354. "workingset": {
  355. "bytes": 1047265
  356. },
  357. "rss": {
  358. "bytes": 91914
  359. },
  360. "pagefaults": 302252,
  361. "majorpagefaults": 0
  362. },
  363. "start_time": "2021-03-30T07:59:06Z",
  364. "name": "container-name-44"
  365. },
  366. "namespace": "namespace26"
  367. }
  368. },
  369. {
  370. "create": {}
  371. },
  372. {
  373. "@timestamp": "2022-06-21T15:40:20Z",
  374. "kubernetes": {
  375. "host": "gke-apps-0",
  376. "node": "gke-apps-0-0",
  377. "pod": "gke-apps-0-0-0",
  378. "container": {
  379. "cpu": {
  380. "usage": {
  381. "nanocores": 125613,
  382. "core": {
  383. "ns": 12828317850
  384. },
  385. "node": {
  386. "pct": 0.0000277905
  387. },
  388. "limit": {
  389. "pct": 0.0000277905
  390. }
  391. }
  392. },
  393. "memory": {
  394. "available": {
  395. "bytes": 822782853
  396. },
  397. "usage": {
  398. "bytes": 100475044,
  399. "node": {
  400. "pct": 0.01770037710617187
  401. },
  402. "limit": {
  403. "pct": 0.00009923134671484496
  404. }
  405. },
  406. "workingset": {
  407. "bytes": 2109932
  408. },
  409. "rss": {
  410. "bytes": 278446
  411. },
  412. "pagefaults": 74843,
  413. "majorpagefaults": 0
  414. },
  415. "start_time": "2021-03-30T07:59:06Z",
  416. "name": "container-name-44"
  417. },
  418. "namespace": "namespace26"
  419. }
  420. },
  421. {
  422. "create": {}
  423. },
  424. {
  425. "@timestamp": "2022-06-21T15:40:10Z",
  426. "kubernetes": {
  427. "host": "gke-apps-0",
  428. "node": "gke-apps-0-0",
  429. "pod": "gke-apps-0-0-0",
  430. "container": {
  431. "cpu": {
  432. "usage": {
  433. "nanocores": 100046,
  434. "core": {
  435. "ns": 12828317850
  436. },
  437. "node": {
  438. "pct": 0.0000277905
  439. },
  440. "limit": {
  441. "pct": 0.0000277905
  442. }
  443. }
  444. },
  445. "memory": {
  446. "available": {
  447. "bytes": 567160996
  448. },
  449. "usage": {
  450. "bytes": 362826547,
  451. "node": {
  452. "pct": 0.01770037710617187
  453. },
  454. "limit": {
  455. "pct": 0.00009923134671484496
  456. }
  457. },
  458. "workingset": {
  459. "bytes": 1986724
  460. },
  461. "rss": {
  462. "bytes": 402801
  463. },
  464. "pagefaults": 296495,
  465. "majorpagefaults": 0
  466. },
  467. "start_time": "2021-03-30T07:59:06Z",
  468. "name": "container-name-44"
  469. },
  470. "namespace": "namespace26"
  471. }
  472. },
  473. {
  474. "create": {}
  475. },
  476. {
  477. "@timestamp": "2022-06-21T15:38:30Z",
  478. "kubernetes": {
  479. "host": "gke-apps-0",
  480. "node": "gke-apps-0-0",
  481. "pod": "gke-apps-0-0-0",
  482. "container": {
  483. "cpu": {
  484. "usage": {
  485. "nanocores": 40018,
  486. "core": {
  487. "ns": 12828317850
  488. },
  489. "node": {
  490. "pct": 0.0000277905
  491. },
  492. "limit": {
  493. "pct": 0.0000277905
  494. }
  495. }
  496. },
  497. "memory": {
  498. "available": {
  499. "bytes": 1062428344
  500. },
  501. "usage": {
  502. "bytes": 265142477,
  503. "node": {
  504. "pct": 0.01770037710617187
  505. },
  506. "limit": {
  507. "pct": 0.00009923134671484496
  508. }
  509. },
  510. "workingset": {
  511. "bytes": 2294743
  512. },
  513. "rss": {
  514. "bytes": 340623
  515. },
  516. "pagefaults": 224530,
  517. "majorpagefaults": 0
  518. },
  519. "start_time": "2021-03-30T07:59:06Z",
  520. "name": "container-name-44"
  521. },
  522. "namespace": "namespace26"
  523. }
  524. }
  525. ],
  526. )
  527. print(resp)

Ruby

  1. response = client.bulk(
  2. index: 'datastream',
  3. refresh: true,
  4. body: [
  5. {
  6. create: {}
  7. },
  8. {
  9. "@timestamp": '2022-06-21T15:49:00Z',
  10. kubernetes: {
  11. host: 'gke-apps-0',
  12. node: 'gke-apps-0-0',
  13. pod: 'gke-apps-0-0-0',
  14. container: {
  15. cpu: {
  16. usage: {
  17. nanocores: 91_153,
  18. core: {
  19. ns: 12_828_317_850
  20. },
  21. node: {
  22. pct: 2.77905e-05
  23. },
  24. limit: {
  25. pct: 2.77905e-05
  26. }
  27. }
  28. },
  29. memory: {
  30. available: {
  31. bytes: 463_314_616
  32. },
  33. usage: {
  34. bytes: 307_007_078,
  35. node: {
  36. pct: 0.01770037710617187
  37. },
  38. limit: {
  39. pct: 9.923134671484496e-05
  40. }
  41. },
  42. workingset: {
  43. bytes: 585_236
  44. },
  45. rss: {
  46. bytes: 102_728
  47. },
  48. pagefaults: 120_901,
  49. majorpagefaults: 0
  50. },
  51. start_time: '2021-03-30T07:59:06Z',
  52. name: 'container-name-44'
  53. },
  54. namespace: 'namespace26'
  55. }
  56. },
  57. {
  58. create: {}
  59. },
  60. {
  61. "@timestamp": '2022-06-21T15:45:50Z',
  62. kubernetes: {
  63. host: 'gke-apps-0',
  64. node: 'gke-apps-0-0',
  65. pod: 'gke-apps-0-0-0',
  66. container: {
  67. cpu: {
  68. usage: {
  69. nanocores: 124_501,
  70. core: {
  71. ns: 12_828_317_850
  72. },
  73. node: {
  74. pct: 2.77905e-05
  75. },
  76. limit: {
  77. pct: 2.77905e-05
  78. }
  79. }
  80. },
  81. memory: {
  82. available: {
  83. bytes: 982_546_514
  84. },
  85. usage: {
  86. bytes: 360_035_574,
  87. node: {
  88. pct: 0.01770037710617187
  89. },
  90. limit: {
  91. pct: 9.923134671484496e-05
  92. }
  93. },
  94. workingset: {
  95. bytes: 1_339_884
  96. },
  97. rss: {
  98. bytes: 381_174
  99. },
  100. pagefaults: 178_473,
  101. majorpagefaults: 0
  102. },
  103. start_time: '2021-03-30T07:59:06Z',
  104. name: 'container-name-44'
  105. },
  106. namespace: 'namespace26'
  107. }
  108. },
  109. {
  110. create: {}
  111. },
  112. {
  113. "@timestamp": '2022-06-21T15:44:50Z',
  114. kubernetes: {
  115. host: 'gke-apps-0',
  116. node: 'gke-apps-0-0',
  117. pod: 'gke-apps-0-0-0',
  118. container: {
  119. cpu: {
  120. usage: {
  121. nanocores: 38_907,
  122. core: {
  123. ns: 12_828_317_850
  124. },
  125. node: {
  126. pct: 2.77905e-05
  127. },
  128. limit: {
  129. pct: 2.77905e-05
  130. }
  131. }
  132. },
  133. memory: {
  134. available: {
  135. bytes: 862_723_768
  136. },
  137. usage: {
  138. bytes: 379_572_388,
  139. node: {
  140. pct: 0.01770037710617187
  141. },
  142. limit: {
  143. pct: 9.923134671484496e-05
  144. }
  145. },
  146. workingset: {
  147. bytes: 431_227
  148. },
  149. rss: {
  150. bytes: 386_580
  151. },
  152. pagefaults: 233_166,
  153. majorpagefaults: 0
  154. },
  155. start_time: '2021-03-30T07:59:06Z',
  156. name: 'container-name-44'
  157. },
  158. namespace: 'namespace26'
  159. }
  160. },
  161. {
  162. create: {}
  163. },
  164. {
  165. "@timestamp": '2022-06-21T15:44:40Z',
  166. kubernetes: {
  167. host: 'gke-apps-0',
  168. node: 'gke-apps-0-0',
  169. pod: 'gke-apps-0-0-0',
  170. container: {
  171. cpu: {
  172. usage: {
  173. nanocores: 86_706,
  174. core: {
  175. ns: 12_828_317_850
  176. },
  177. node: {
  178. pct: 2.77905e-05
  179. },
  180. limit: {
  181. pct: 2.77905e-05
  182. }
  183. }
  184. },
  185. memory: {
  186. available: {
  187. bytes: 567_160_996
  188. },
  189. usage: {
  190. bytes: 103_266_017,
  191. node: {
  192. pct: 0.01770037710617187
  193. },
  194. limit: {
  195. pct: 9.923134671484496e-05
  196. }
  197. },
  198. workingset: {
  199. bytes: 1_724_908
  200. },
  201. rss: {
  202. bytes: 105_431
  203. },
  204. pagefaults: 233_166,
  205. majorpagefaults: 0
  206. },
  207. start_time: '2021-03-30T07:59:06Z',
  208. name: 'container-name-44'
  209. },
  210. namespace: 'namespace26'
  211. }
  212. },
  213. {
  214. create: {}
  215. },
  216. {
  217. "@timestamp": '2022-06-21T15:44:00Z',
  218. kubernetes: {
  219. host: 'gke-apps-0',
  220. node: 'gke-apps-0-0',
  221. pod: 'gke-apps-0-0-0',
  222. container: {
  223. cpu: {
  224. usage: {
  225. nanocores: 150_069,
  226. core: {
  227. ns: 12_828_317_850
  228. },
  229. node: {
  230. pct: 2.77905e-05
  231. },
  232. limit: {
  233. pct: 2.77905e-05
  234. }
  235. }
  236. },
  237. memory: {
  238. available: {
  239. bytes: 639_054_643
  240. },
  241. usage: {
  242. bytes: 265_142_477,
  243. node: {
  244. pct: 0.01770037710617187
  245. },
  246. limit: {
  247. pct: 9.923134671484496e-05
  248. }
  249. },
  250. workingset: {
  251. bytes: 1_786_511
  252. },
  253. rss: {
  254. bytes: 189_235
  255. },
  256. pagefaults: 138_172,
  257. majorpagefaults: 0
  258. },
  259. start_time: '2021-03-30T07:59:06Z',
  260. name: 'container-name-44'
  261. },
  262. namespace: 'namespace26'
  263. }
  264. },
  265. {
  266. create: {}
  267. },
  268. {
  269. "@timestamp": '2022-06-21T15:42:40Z',
  270. kubernetes: {
  271. host: 'gke-apps-0',
  272. node: 'gke-apps-0-0',
  273. pod: 'gke-apps-0-0-0',
  274. container: {
  275. cpu: {
  276. usage: {
  277. nanocores: 82_260,
  278. core: {
  279. ns: 12_828_317_850
  280. },
  281. node: {
  282. pct: 2.77905e-05
  283. },
  284. limit: {
  285. pct: 2.77905e-05
  286. }
  287. }
  288. },
  289. memory: {
  290. available: {
  291. bytes: 854_735_585
  292. },
  293. usage: {
  294. bytes: 309_798_052,
  295. node: {
  296. pct: 0.01770037710617187
  297. },
  298. limit: {
  299. pct: 9.923134671484496e-05
  300. }
  301. },
  302. workingset: {
  303. bytes: 924_058
  304. },
  305. rss: {
  306. bytes: 110_838
  307. },
  308. pagefaults: 259_073,
  309. majorpagefaults: 0
  310. },
  311. start_time: '2021-03-30T07:59:06Z',
  312. name: 'container-name-44'
  313. },
  314. namespace: 'namespace26'
  315. }
  316. },
  317. {
  318. create: {}
  319. },
  320. {
  321. "@timestamp": '2022-06-21T15:42:10Z',
  322. kubernetes: {
  323. host: 'gke-apps-0',
  324. node: 'gke-apps-0-0',
  325. pod: 'gke-apps-0-0-0',
  326. container: {
  327. cpu: {
  328. usage: {
  329. nanocores: 153_404,
  330. core: {
  331. ns: 12_828_317_850
  332. },
  333. node: {
  334. pct: 2.77905e-05
  335. },
  336. limit: {
  337. pct: 2.77905e-05
  338. }
  339. }
  340. },
  341. memory: {
  342. available: {
  343. bytes: 279_586_406
  344. },
  345. usage: {
  346. bytes: 214_904_955,
  347. node: {
  348. pct: 0.01770037710617187
  349. },
  350. limit: {
  351. pct: 9.923134671484496e-05
  352. }
  353. },
  354. workingset: {
  355. bytes: 1_047_265
  356. },
  357. rss: {
  358. bytes: 91_914
  359. },
  360. pagefaults: 302_252,
  361. majorpagefaults: 0
  362. },
  363. start_time: '2021-03-30T07:59:06Z',
  364. name: 'container-name-44'
  365. },
  366. namespace: 'namespace26'
  367. }
  368. },
  369. {
  370. create: {}
  371. },
  372. {
  373. "@timestamp": '2022-06-21T15:40:20Z',
  374. kubernetes: {
  375. host: 'gke-apps-0',
  376. node: 'gke-apps-0-0',
  377. pod: 'gke-apps-0-0-0',
  378. container: {
  379. cpu: {
  380. usage: {
  381. nanocores: 125_613,
  382. core: {
  383. ns: 12_828_317_850
  384. },
  385. node: {
  386. pct: 2.77905e-05
  387. },
  388. limit: {
  389. pct: 2.77905e-05
  390. }
  391. }
  392. },
  393. memory: {
  394. available: {
  395. bytes: 822_782_853
  396. },
  397. usage: {
  398. bytes: 100_475_044,
  399. node: {
  400. pct: 0.01770037710617187
  401. },
  402. limit: {
  403. pct: 9.923134671484496e-05
  404. }
  405. },
  406. workingset: {
  407. bytes: 2_109_932
  408. },
  409. rss: {
  410. bytes: 278_446
  411. },
  412. pagefaults: 74_843,
  413. majorpagefaults: 0
  414. },
  415. start_time: '2021-03-30T07:59:06Z',
  416. name: 'container-name-44'
  417. },
  418. namespace: 'namespace26'
  419. }
  420. },
  421. {
  422. create: {}
  423. },
  424. {
  425. "@timestamp": '2022-06-21T15:40:10Z',
  426. kubernetes: {
  427. host: 'gke-apps-0',
  428. node: 'gke-apps-0-0',
  429. pod: 'gke-apps-0-0-0',
  430. container: {
  431. cpu: {
  432. usage: {
  433. nanocores: 100_046,
  434. core: {
  435. ns: 12_828_317_850
  436. },
  437. node: {
  438. pct: 2.77905e-05
  439. },
  440. limit: {
  441. pct: 2.77905e-05
  442. }
  443. }
  444. },
  445. memory: {
  446. available: {
  447. bytes: 567_160_996
  448. },
  449. usage: {
  450. bytes: 362_826_547,
  451. node: {
  452. pct: 0.01770037710617187
  453. },
  454. limit: {
  455. pct: 9.923134671484496e-05
  456. }
  457. },
  458. workingset: {
  459. bytes: 1_986_724
  460. },
  461. rss: {
  462. bytes: 402_801
  463. },
  464. pagefaults: 296_495,
  465. majorpagefaults: 0
  466. },
  467. start_time: '2021-03-30T07:59:06Z',
  468. name: 'container-name-44'
  469. },
  470. namespace: 'namespace26'
  471. }
  472. },
  473. {
  474. create: {}
  475. },
  476. {
  477. "@timestamp": '2022-06-21T15:38:30Z',
  478. kubernetes: {
  479. host: 'gke-apps-0',
  480. node: 'gke-apps-0-0',
  481. pod: 'gke-apps-0-0-0',
  482. container: {
  483. cpu: {
  484. usage: {
  485. nanocores: 40_018,
  486. core: {
  487. ns: 12_828_317_850
  488. },
  489. node: {
  490. pct: 2.77905e-05
  491. },
  492. limit: {
  493. pct: 2.77905e-05
  494. }
  495. }
  496. },
  497. memory: {
  498. available: {
  499. bytes: 1_062_428_344
  500. },
  501. usage: {
  502. bytes: 265_142_477,
  503. node: {
  504. pct: 0.01770037710617187
  505. },
  506. limit: {
  507. pct: 9.923134671484496e-05
  508. }
  509. },
  510. workingset: {
  511. bytes: 2_294_743
  512. },
  513. rss: {
  514. bytes: 340_623
  515. },
  516. pagefaults: 224_530,
  517. majorpagefaults: 0
  518. },
  519. start_time: '2021-03-30T07:59:06Z',
  520. name: 'container-name-44'
  521. },
  522. namespace: 'namespace26'
  523. }
  524. }
  525. ]
  526. )
  527. puts response

Js

  1. const response = await client.bulk({
  2. index: "datastream",
  3. refresh: "true",
  4. operations: [
  5. {
  6. create: {},
  7. },
  8. {
  9. "@timestamp": "2022-06-21T15:49:00Z",
  10. kubernetes: {
  11. host: "gke-apps-0",
  12. node: "gke-apps-0-0",
  13. pod: "gke-apps-0-0-0",
  14. container: {
  15. cpu: {
  16. usage: {
  17. nanocores: 91153,
  18. core: {
  19. ns: 12828317850,
  20. },
  21. node: {
  22. pct: 0.0000277905,
  23. },
  24. limit: {
  25. pct: 0.0000277905,
  26. },
  27. },
  28. },
  29. memory: {
  30. available: {
  31. bytes: 463314616,
  32. },
  33. usage: {
  34. bytes: 307007078,
  35. node: {
  36. pct: 0.01770037710617187,
  37. },
  38. limit: {
  39. pct: 0.00009923134671484496,
  40. },
  41. },
  42. workingset: {
  43. bytes: 585236,
  44. },
  45. rss: {
  46. bytes: 102728,
  47. },
  48. pagefaults: 120901,
  49. majorpagefaults: 0,
  50. },
  51. start_time: "2021-03-30T07:59:06Z",
  52. name: "container-name-44",
  53. },
  54. namespace: "namespace26",
  55. },
  56. },
  57. {
  58. create: {},
  59. },
  60. {
  61. "@timestamp": "2022-06-21T15:45:50Z",
  62. kubernetes: {
  63. host: "gke-apps-0",
  64. node: "gke-apps-0-0",
  65. pod: "gke-apps-0-0-0",
  66. container: {
  67. cpu: {
  68. usage: {
  69. nanocores: 124501,
  70. core: {
  71. ns: 12828317850,
  72. },
  73. node: {
  74. pct: 0.0000277905,
  75. },
  76. limit: {
  77. pct: 0.0000277905,
  78. },
  79. },
  80. },
  81. memory: {
  82. available: {
  83. bytes: 982546514,
  84. },
  85. usage: {
  86. bytes: 360035574,
  87. node: {
  88. pct: 0.01770037710617187,
  89. },
  90. limit: {
  91. pct: 0.00009923134671484496,
  92. },
  93. },
  94. workingset: {
  95. bytes: 1339884,
  96. },
  97. rss: {
  98. bytes: 381174,
  99. },
  100. pagefaults: 178473,
  101. majorpagefaults: 0,
  102. },
  103. start_time: "2021-03-30T07:59:06Z",
  104. name: "container-name-44",
  105. },
  106. namespace: "namespace26",
  107. },
  108. },
  109. {
  110. create: {},
  111. },
  112. {
  113. "@timestamp": "2022-06-21T15:44:50Z",
  114. kubernetes: {
  115. host: "gke-apps-0",
  116. node: "gke-apps-0-0",
  117. pod: "gke-apps-0-0-0",
  118. container: {
  119. cpu: {
  120. usage: {
  121. nanocores: 38907,
  122. core: {
  123. ns: 12828317850,
  124. },
  125. node: {
  126. pct: 0.0000277905,
  127. },
  128. limit: {
  129. pct: 0.0000277905,
  130. },
  131. },
  132. },
  133. memory: {
  134. available: {
  135. bytes: 862723768,
  136. },
  137. usage: {
  138. bytes: 379572388,
  139. node: {
  140. pct: 0.01770037710617187,
  141. },
  142. limit: {
  143. pct: 0.00009923134671484496,
  144. },
  145. },
  146. workingset: {
  147. bytes: 431227,
  148. },
  149. rss: {
  150. bytes: 386580,
  151. },
  152. pagefaults: 233166,
  153. majorpagefaults: 0,
  154. },
  155. start_time: "2021-03-30T07:59:06Z",
  156. name: "container-name-44",
  157. },
  158. namespace: "namespace26",
  159. },
  160. },
  161. {
  162. create: {},
  163. },
  164. {
  165. "@timestamp": "2022-06-21T15:44:40Z",
  166. kubernetes: {
  167. host: "gke-apps-0",
  168. node: "gke-apps-0-0",
  169. pod: "gke-apps-0-0-0",
  170. container: {
  171. cpu: {
  172. usage: {
  173. nanocores: 86706,
  174. core: {
  175. ns: 12828317850,
  176. },
  177. node: {
  178. pct: 0.0000277905,
  179. },
  180. limit: {
  181. pct: 0.0000277905,
  182. },
  183. },
  184. },
  185. memory: {
  186. available: {
  187. bytes: 567160996,
  188. },
  189. usage: {
  190. bytes: 103266017,
  191. node: {
  192. pct: 0.01770037710617187,
  193. },
  194. limit: {
  195. pct: 0.00009923134671484496,
  196. },
  197. },
  198. workingset: {
  199. bytes: 1724908,
  200. },
  201. rss: {
  202. bytes: 105431,
  203. },
  204. pagefaults: 233166,
  205. majorpagefaults: 0,
  206. },
  207. start_time: "2021-03-30T07:59:06Z",
  208. name: "container-name-44",
  209. },
  210. namespace: "namespace26",
  211. },
  212. },
  213. {
  214. create: {},
  215. },
  216. {
  217. "@timestamp": "2022-06-21T15:44:00Z",
  218. kubernetes: {
  219. host: "gke-apps-0",
  220. node: "gke-apps-0-0",
  221. pod: "gke-apps-0-0-0",
  222. container: {
  223. cpu: {
  224. usage: {
  225. nanocores: 150069,
  226. core: {
  227. ns: 12828317850,
  228. },
  229. node: {
  230. pct: 0.0000277905,
  231. },
  232. limit: {
  233. pct: 0.0000277905,
  234. },
  235. },
  236. },
  237. memory: {
  238. available: {
  239. bytes: 639054643,
  240. },
  241. usage: {
  242. bytes: 265142477,
  243. node: {
  244. pct: 0.01770037710617187,
  245. },
  246. limit: {
  247. pct: 0.00009923134671484496,
  248. },
  249. },
  250. workingset: {
  251. bytes: 1786511,
  252. },
  253. rss: {
  254. bytes: 189235,
  255. },
  256. pagefaults: 138172,
  257. majorpagefaults: 0,
  258. },
  259. start_time: "2021-03-30T07:59:06Z",
  260. name: "container-name-44",
  261. },
  262. namespace: "namespace26",
  263. },
  264. },
  265. {
  266. create: {},
  267. },
  268. {
  269. "@timestamp": "2022-06-21T15:42:40Z",
  270. kubernetes: {
  271. host: "gke-apps-0",
  272. node: "gke-apps-0-0",
  273. pod: "gke-apps-0-0-0",
  274. container: {
  275. cpu: {
  276. usage: {
  277. nanocores: 82260,
  278. core: {
  279. ns: 12828317850,
  280. },
  281. node: {
  282. pct: 0.0000277905,
  283. },
  284. limit: {
  285. pct: 0.0000277905,
  286. },
  287. },
  288. },
  289. memory: {
  290. available: {
  291. bytes: 854735585,
  292. },
  293. usage: {
  294. bytes: 309798052,
  295. node: {
  296. pct: 0.01770037710617187,
  297. },
  298. limit: {
  299. pct: 0.00009923134671484496,
  300. },
  301. },
  302. workingset: {
  303. bytes: 924058,
  304. },
  305. rss: {
  306. bytes: 110838,
  307. },
  308. pagefaults: 259073,
  309. majorpagefaults: 0,
  310. },
  311. start_time: "2021-03-30T07:59:06Z",
  312. name: "container-name-44",
  313. },
  314. namespace: "namespace26",
  315. },
  316. },
  317. {
  318. create: {},
  319. },
  320. {
  321. "@timestamp": "2022-06-21T15:42:10Z",
  322. kubernetes: {
  323. host: "gke-apps-0",
  324. node: "gke-apps-0-0",
  325. pod: "gke-apps-0-0-0",
  326. container: {
  327. cpu: {
  328. usage: {
  329. nanocores: 153404,
  330. core: {
  331. ns: 12828317850,
  332. },
  333. node: {
  334. pct: 0.0000277905,
  335. },
  336. limit: {
  337. pct: 0.0000277905,
  338. },
  339. },
  340. },
  341. memory: {
  342. available: {
  343. bytes: 279586406,
  344. },
  345. usage: {
  346. bytes: 214904955,
  347. node: {
  348. pct: 0.01770037710617187,
  349. },
  350. limit: {
  351. pct: 0.00009923134671484496,
  352. },
  353. },
  354. workingset: {
  355. bytes: 1047265,
  356. },
  357. rss: {
  358. bytes: 91914,
  359. },
  360. pagefaults: 302252,
  361. majorpagefaults: 0,
  362. },
  363. start_time: "2021-03-30T07:59:06Z",
  364. name: "container-name-44",
  365. },
  366. namespace: "namespace26",
  367. },
  368. },
  369. {
  370. create: {},
  371. },
  372. {
  373. "@timestamp": "2022-06-21T15:40:20Z",
  374. kubernetes: {
  375. host: "gke-apps-0",
  376. node: "gke-apps-0-0",
  377. pod: "gke-apps-0-0-0",
  378. container: {
  379. cpu: {
  380. usage: {
  381. nanocores: 125613,
  382. core: {
  383. ns: 12828317850,
  384. },
  385. node: {
  386. pct: 0.0000277905,
  387. },
  388. limit: {
  389. pct: 0.0000277905,
  390. },
  391. },
  392. },
  393. memory: {
  394. available: {
  395. bytes: 822782853,
  396. },
  397. usage: {
  398. bytes: 100475044,
  399. node: {
  400. pct: 0.01770037710617187,
  401. },
  402. limit: {
  403. pct: 0.00009923134671484496,
  404. },
  405. },
  406. workingset: {
  407. bytes: 2109932,
  408. },
  409. rss: {
  410. bytes: 278446,
  411. },
  412. pagefaults: 74843,
  413. majorpagefaults: 0,
  414. },
  415. start_time: "2021-03-30T07:59:06Z",
  416. name: "container-name-44",
  417. },
  418. namespace: "namespace26",
  419. },
  420. },
  421. {
  422. create: {},
  423. },
  424. {
  425. "@timestamp": "2022-06-21T15:40:10Z",
  426. kubernetes: {
  427. host: "gke-apps-0",
  428. node: "gke-apps-0-0",
  429. pod: "gke-apps-0-0-0",
  430. container: {
  431. cpu: {
  432. usage: {
  433. nanocores: 100046,
  434. core: {
  435. ns: 12828317850,
  436. },
  437. node: {
  438. pct: 0.0000277905,
  439. },
  440. limit: {
  441. pct: 0.0000277905,
  442. },
  443. },
  444. },
  445. memory: {
  446. available: {
  447. bytes: 567160996,
  448. },
  449. usage: {
  450. bytes: 362826547,
  451. node: {
  452. pct: 0.01770037710617187,
  453. },
  454. limit: {
  455. pct: 0.00009923134671484496,
  456. },
  457. },
  458. workingset: {
  459. bytes: 1986724,
  460. },
  461. rss: {
  462. bytes: 402801,
  463. },
  464. pagefaults: 296495,
  465. majorpagefaults: 0,
  466. },
  467. start_time: "2021-03-30T07:59:06Z",
  468. name: "container-name-44",
  469. },
  470. namespace: "namespace26",
  471. },
  472. },
  473. {
  474. create: {},
  475. },
  476. {
  477. "@timestamp": "2022-06-21T15:38:30Z",
  478. kubernetes: {
  479. host: "gke-apps-0",
  480. node: "gke-apps-0-0",
  481. pod: "gke-apps-0-0-0",
  482. container: {
  483. cpu: {
  484. usage: {
  485. nanocores: 40018,
  486. core: {
  487. ns: 12828317850,
  488. },
  489. node: {
  490. pct: 0.0000277905,
  491. },
  492. limit: {
  493. pct: 0.0000277905,
  494. },
  495. },
  496. },
  497. memory: {
  498. available: {
  499. bytes: 1062428344,
  500. },
  501. usage: {
  502. bytes: 265142477,
  503. node: {
  504. pct: 0.01770037710617187,
  505. },
  506. limit: {
  507. pct: 0.00009923134671484496,
  508. },
  509. },
  510. workingset: {
  511. bytes: 2294743,
  512. },
  513. rss: {
  514. bytes: 340623,
  515. },
  516. pagefaults: 224530,
  517. majorpagefaults: 0,
  518. },
  519. start_time: "2021-03-30T07:59:06Z",
  520. name: "container-name-44",
  521. },
  522. namespace: "namespace26",
  523. },
  524. },
  525. ],
  526. });
  527. console.log(response);

Console

  1. PUT /datastream/_bulk?refresh
  2. {"create": {}}
  3. {"@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"}}
  4. {"create": {}}
  5. {"@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"}}
  6. {"create": {}}
  7. {"@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"}}
  8. {"create": {}}
  9. {"@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"}}
  10. {"create": {}}
  11. {"@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"}}
  12. {"create": {}}
  13. {"@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"}}
  14. {"create": {}}
  15. {"@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"}}
  16. {"create": {}}
  17. {"@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"}}
  18. {"create": {}}
  19. {"@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"}}
  20. {"create": {}}
  21. {"@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"}}

結果の表示

データストリームにドキュメントを作成して追加したので、新しいインデックスの現在の状態を確認してください。

Python

  1. resp = client.indices.get_data_stream()
  2. print(resp)

Ruby

  1. response = client.indices.get_data_stream
  2. puts response

Js

  1. const response = await client.indices.getDataStream();
  2. console.log(response);

Console

  1. GET _data_stream

ILMポリシーがまだ適用されていない場合、結果は次のようになります。元のindex_nameに注意してください:.ds-datastream-<timestamp>-000001

Console-Result

  1. {
  2. "data_streams": [
  3. {
  4. "name": "datastream",
  5. "timestamp_field": {
  6. "name": "@timestamp"
  7. },
  8. "indices": [
  9. {
  10. "index_name": ".ds-datastream-2022.08.26-000001",
  11. "index_uuid": "5g-3HrfETga-5EFKBM6R-w"
  12. },
  13. {
  14. "index_name": ".ds-datastream-2022.08.26-000002",
  15. "index_uuid": "o0yRTdhWSo2pY8XMvfwy7Q"
  16. }
  17. ],
  18. "generation": 2,
  19. "status": "GREEN",
  20. "template": "datastream_template",
  21. "ilm_policy": "datastream_policy",
  22. "hidden": false,
  23. "system": false,
  24. "allow_custom_routing": false,
  25. "replicated": false,
  26. "rollover_on_write": false,
  27. "time_series": {
  28. "temporal_ranges": [
  29. {
  30. "start": "2022-08-26T13:29:07.000Z",
  31. "end": "2022-08-26T19:29:07.000Z"
  32. }
  33. ]
  34. }
  35. }
  36. ]
  37. }

次に、検索クエリを実行します:

Python

  1. resp = client.search(
  2. index="datastream",
  3. )
  4. print(resp)

Ruby

  1. response = client.search(
  2. index: 'datastream'
  3. )
  4. puts response

Js

  1. const response = await client.search({
  2. index: "datastream",
  3. });
  4. console.log(response);

Console

  1. GET datastream/_search

クエリは、追加した10件の新しいドキュメントを返します。

Console-Result

  1. {
  2. "took": 17,
  3. "timed_out": false,
  4. "_shards": {
  5. "total": 4,
  6. "successful": 4,
  7. "skipped": 0,
  8. "failed": 0
  9. },
  10. "hits": {
  11. "total": {
  12. "value": 10,
  13. "relation": "eq"
  14. },
  15. ...

デフォルトでは、インデックスライフサイクル管理は、ポリシー基準を満たすインデックスを10分ごとにチェックします。約10分待って(コーヒーやお茶を淹れるのも良いかもしれません☕)、GET _data_streamリクエストを再実行してください。

Python

  1. resp = client.indices.get_data_stream()
  2. print(resp)

Ruby

  1. response = client.indices.get_data_stream
  2. puts response

Js

  1. const response = await client.indices.getDataStream();
  2. console.log(response);

Console

  1. GET _data_stream

ILMポリシーが適用された後、元の.ds-datastream-2022.08.26-000001インデックスは新しいダウンサンプリングされたインデックスdownsample-6tkn-.ds-datastream-2022.08.26-000001に置き換えられます。

Console-Result

  1. {
  2. "data_streams": [
  3. {
  4. "name": "datastream",
  5. "timestamp_field": {
  6. "name": "@timestamp"
  7. },
  8. "indices": [
  9. {
  10. "index_name": "downsample-6tkn-.ds-datastream-2022.08.26-000001",
  11. "index_uuid": "qRane1fQQDCNgKQhXmTIvg"
  12. },
  13. {
  14. "index_name": ".ds-datastream-2022.08.26-000002",
  15. "index_uuid": "o0yRTdhWSo2pY8XMvfwy7Q"
  16. }
  17. ],
  18. ...

データストリームに対して検索クエリを実行します(ダウンサンプリングされたインデックスをクエリする際には、注意すべきいくつかのニュアンスがあります)。

Python

  1. resp = client.search(
  2. index="datastream",
  3. )
  4. print(resp)

Ruby

  1. response = client.search(
  2. index: 'datastream'
  3. )
  4. puts response

Js

  1. const response = await client.search({
  2. index: "datastream",
  3. });
  4. console.log(response);

Console

  1. GET datastream/_search

新しいダウンサンプリングされたインデックスには、元のサンプリングされたメトリックに基づくminmaxsum、およびvalue_count統計を含む1つのドキュメントのみが含まれています。

Console-Result

  1. {
  2. "took": 6,
  3. "timed_out": false,
  4. "_shards": {
  5. "total": 4,
  6. "successful": 4,
  7. "skipped": 0,
  8. "failed": 0
  9. },
  10. "hits": {
  11. "total": {
  12. "value": 1,
  13. "relation": "eq"
  14. },
  15. "max_score": 1,
  16. "hits": [
  17. {
  18. "_index": "downsample-6tkn-.ds-datastream-2022.08.26-000001",
  19. "_id": "0eL0wC_4-45SnTNFAAABgtpz0wA",
  20. "_score": 1,
  21. "_source": {
  22. "@timestamp": "2022-08-26T14:00:00.000Z",
  23. "_doc_count": 10,
  24. "kubernetes.host": "gke-apps-0",
  25. "kubernetes.namespace": "namespace26",
  26. "kubernetes.node": "gke-apps-0-0",
  27. "kubernetes.pod": "gke-apps-0-0-0",
  28. "kubernetes.container.cpu.usage.nanocores": {
  29. "min": 38907,
  30. "max": 153404,
  31. "sum": 992677,
  32. "value_count": 10
  33. },
  34. "kubernetes.container.memory.available.bytes": {
  35. "min": 279586406,
  36. "max": 1062428344,
  37. "sum": 7101494721,
  38. "value_count": 10
  39. },
  40. "kubernetes.container.memory.pagefaults": {
  41. "min": 74843,
  42. "max": 302252,
  43. "sum": 2061071,
  44. "value_count": 10
  45. },
  46. "kubernetes.container.memory.rss.bytes": {
  47. "min": 91914,
  48. "max": 402801,
  49. "sum": 2389770,
  50. "value_count": 10
  51. },
  52. "kubernetes.container.memory.usage.bytes": {
  53. "min": 100475044,
  54. "max": 379572388,
  55. "sum": 2668170609,
  56. "value_count": 10
  57. },
  58. "kubernetes.container.memory.workingset.bytes": {
  59. "min": 431227,
  60. "max": 2294743,
  61. "sum": 14230488,
  62. "value_count": 10
  63. },
  64. "kubernetes.container.cpu.usage.core.ns": 12828317850,
  65. "kubernetes.container.cpu.usage.limit.pct": 0.000027790500098490156,
  66. "kubernetes.container.cpu.usage.node.pct": 0.000027790500098490156,
  67. "kubernetes.container.memory.majorpagefaults": 0,
  68. "kubernetes.container.memory.usage.limit.pct": 0.00009923134348355234,
  69. "kubernetes.container.memory.usage.node.pct": 0.017700377851724625,
  70. "kubernetes.container.name": "container-name-44",
  71. "kubernetes.container.start_time": "2021-03-30T07:59:06.000Z"
  72. }
  73. }
  74. ]
  75. }
  76. }

データストリーム統計APIを使用して、データストリームの統計を取得し、ストレージサイズを含めます。

Python

  1. resp = client.indices.data_streams_stats(
  2. name="datastream",
  3. human=True,
  4. )
  5. print(resp)

Ruby

  1. response = client.indices.data_streams_stats(
  2. name: 'datastream',
  3. human: true
  4. )
  5. puts response

Js

  1. const response = await client.indices.dataStreamsStats({
  2. name: "datastream",
  3. human: "true",
  4. });
  5. console.log(response);

Console

  1. GET /_data_stream/datastream/_stats?human=true

Console-Result

  1. {
  2. "_shards": {
  3. "total": 4,
  4. "successful": 4,
  5. "failed": 0
  6. },
  7. "data_stream_count": 1,
  8. "backing_indices": 2,
  9. "total_store_size": "16.6kb",
  10. "total_store_size_bytes": 17059,
  11. "data_streams": [
  12. {
  13. "data_stream": "datastream",
  14. "backing_indices": 2,
  15. "store_size": "16.6kb",
  16. "store_size_bytes": 17059,
  17. "maximum_timestamp": 1661522400000
  18. }
  19. ]
  20. }

この例は、メトリックデータのストレージサイズを削減するために、ダウンサンプリングがILMポリシーの一部としてどのように機能するかを示しています。データが古くなり、頻繁にクエリされなくなるにつれて。

また、ILMポリシーの外でダウンサンプリングがどのように機能するかを学ぶために、手動でダウンサンプリングを実行する例を試すこともできます。