ILMを使用したダウンサンプリングの実行
これは、サンプリングされたメトリックセットのストレージサイズを削減するためのILMポリシーの一部として、ダウンサンプリングがどのように機能するかを迅速に確認できる簡略化された例です。この例では、典型的なKubernetesクラスターの監視データを使用しています。ILMを使用したダウンサンプリングをテストするには、次の手順に従ってください:
- 1. 前提条件を確認します。
- 2. インデックスライフサイクルポリシーを作成します。
- 3. インデックステンプレートを作成します。
- 4. 時系列データを取り込むします。
- 5. 結果を表示します。
前提条件
時系列データストリームの前提条件を参照してください。
この例を実行する前に、手動でダウンサンプリングを実行する例を試してみることをお勧めします。
インデックスライフサイクルポリシーの作成
時系列データ用のILMポリシーを作成します。必須ではありませんが、時系列データストリームインデックスの管理を自動化するためにILMポリシーを推奨します。
ダウンサンプリングを有効にするには、ダウンサンプルアクションを追加し、元の時系列データを集約したいダウンサンプリング間隔にfixed_interval
を設定します。
この例では、hot
フェーズのためにILMポリシーが構成されています。ダウンサンプリングは、インデックスがロールオーバーされた後、インデックスの時系列終了時間が経過した後に行われます。ソースインデックスはその時点まで主要な書き込みを受け取ることが期待されているためです。インデックスライフサイクル管理は、インデックスの終了時間が経過するまで、インデックスがもはや書き込みを受け取らないことを期待するアクションを進めません。終了時間を待つインデックスライフサイクル管理アクションは次のとおりです: - 削除 - ダウンサンプル - 強制マージ - 読み取り専用 - 検索可能スナップショット - 縮小
Python
resp = client.ilm.put_lifecycle(
name="datastream_policy",
policy={
"phases": {
"hot": {
"actions": {
"rollover": {
"max_age": "5m"
},
"downsample": {
"fixed_interval": "1h"
}
}
}
}
},
)
print(resp)
Ruby
response = client.ilm.put_lifecycle(
policy: 'datastream_policy',
body: {
policy: {
phases: {
hot: {
actions: {
rollover: {
max_age: '5m'
},
downsample: {
fixed_interval: '1h'
}
}
}
}
}
}
)
puts response
Js
const response = await client.ilm.putLifecycle({
name: "datastream_policy",
policy: {
phases: {
hot: {
actions: {
rollover: {
max_age: "5m",
},
downsample: {
fixed_interval: "1h",
},
},
},
},
},
});
console.log(response);
Console
PUT _ilm/policy/datastream_policy
{
"policy": {
"phases": {
"hot": {
"actions": {
"rollover" : {
"max_age": "5m"
},
"downsample": {
"fixed_interval": "1h"
}
}
}
}
}
}
インデックステンプレートの作成
これは基本的なデータストリームのためのインデックステンプレートを作成します。インデックステンプレートの利用可能なパラメータは、時系列データストリームの設定で詳細に説明されています。
簡単のために、時系列マッピングではすべてのtime_series_metric
パラメータがgauge
型に設定されていますが、counter
メトリックタイプも使用できます。time_series_metric
値は、ダウンサンプリング中に使用される統計的表現の種類を決定します。
インデックステンプレートには、静的な時系列次元のセットが含まれています:host
、namespace
、node
、およびpod
。時系列次元はダウンサンプリングプロセスによって変更されません。
Python
resp = client.indices.put_index_template(
name="datastream_template",
index_patterns=[
"datastream*"
],
data_stream={},
template={
"settings": {
"index": {
"mode": "time_series",
"number_of_replicas": 0,
"number_of_shards": 2
},
"index.lifecycle.name": "datastream_policy"
},
"mappings": {
"properties": {
"@timestamp": {
"type": "date"
},
"kubernetes": {
"properties": {
"container": {
"properties": {
"cpu": {
"properties": {
"usage": {
"properties": {
"core": {
"properties": {
"ns": {
"type": "long"
}
}
},
"limit": {
"properties": {
"pct": {
"type": "float"
}
}
},
"nanocores": {
"type": "long",
"time_series_metric": "gauge"
},
"node": {
"properties": {
"pct": {
"type": "float"
}
}
}
}
}
}
},
"memory": {
"properties": {
"available": {
"properties": {
"bytes": {
"type": "long",
"time_series_metric": "gauge"
}
}
},
"majorpagefaults": {
"type": "long"
},
"pagefaults": {
"type": "long",
"time_series_metric": "gauge"
},
"rss": {
"properties": {
"bytes": {
"type": "long",
"time_series_metric": "gauge"
}
}
},
"usage": {
"properties": {
"bytes": {
"type": "long",
"time_series_metric": "gauge"
},
"limit": {
"properties": {
"pct": {
"type": "float"
}
}
},
"node": {
"properties": {
"pct": {
"type": "float"
}
}
}
}
},
"workingset": {
"properties": {
"bytes": {
"type": "long",
"time_series_metric": "gauge"
}
}
}
}
},
"name": {
"type": "keyword"
},
"start_time": {
"type": "date"
}
}
},
"host": {
"type": "keyword",
"time_series_dimension": True
},
"namespace": {
"type": "keyword",
"time_series_dimension": True
},
"node": {
"type": "keyword",
"time_series_dimension": True
},
"pod": {
"type": "keyword",
"time_series_dimension": True
}
}
}
}
}
},
)
print(resp)
Ruby
response = client.indices.put_index_template(
name: 'datastream_template',
body: {
index_patterns: [
'datastream*'
],
data_stream: {},
template: {
settings: {
index: {
mode: 'time_series',
number_of_replicas: 0,
number_of_shards: 2
},
'index.lifecycle.name' => 'datastream_policy'
},
mappings: {
properties: {
"@timestamp": {
type: 'date'
},
kubernetes: {
properties: {
container: {
properties: {
cpu: {
properties: {
usage: {
properties: {
core: {
properties: {
ns: {
type: 'long'
}
}
},
limit: {
properties: {
pct: {
type: 'float'
}
}
},
nanocores: {
type: 'long',
time_series_metric: 'gauge'
},
node: {
properties: {
pct: {
type: 'float'
}
}
}
}
}
}
},
memory: {
properties: {
available: {
properties: {
bytes: {
type: 'long',
time_series_metric: 'gauge'
}
}
},
majorpagefaults: {
type: 'long'
},
pagefaults: {
type: 'long',
time_series_metric: 'gauge'
},
rss: {
properties: {
bytes: {
type: 'long',
time_series_metric: 'gauge'
}
}
},
usage: {
properties: {
bytes: {
type: 'long',
time_series_metric: 'gauge'
},
limit: {
properties: {
pct: {
type: 'float'
}
}
},
node: {
properties: {
pct: {
type: 'float'
}
}
}
}
},
workingset: {
properties: {
bytes: {
type: 'long',
time_series_metric: 'gauge'
}
}
}
}
},
name: {
type: 'keyword'
},
start_time: {
type: 'date'
}
}
},
host: {
type: 'keyword',
time_series_dimension: true
},
namespace: {
type: 'keyword',
time_series_dimension: true
},
node: {
type: 'keyword',
time_series_dimension: true
},
pod: {
type: 'keyword',
time_series_dimension: true
}
}
}
}
}
}
}
)
puts response
Js
const response = await client.indices.putIndexTemplate({
name: "datastream_template",
index_patterns: ["datastream*"],
data_stream: {},
template: {
settings: {
index: {
mode: "time_series",
number_of_replicas: 0,
number_of_shards: 2,
},
"index.lifecycle.name": "datastream_policy",
},
mappings: {
properties: {
"@timestamp": {
type: "date",
},
kubernetes: {
properties: {
container: {
properties: {
cpu: {
properties: {
usage: {
properties: {
core: {
properties: {
ns: {
type: "long",
},
},
},
limit: {
properties: {
pct: {
type: "float",
},
},
},
nanocores: {
type: "long",
time_series_metric: "gauge",
},
node: {
properties: {
pct: {
type: "float",
},
},
},
},
},
},
},
memory: {
properties: {
available: {
properties: {
bytes: {
type: "long",
time_series_metric: "gauge",
},
},
},
majorpagefaults: {
type: "long",
},
pagefaults: {
type: "long",
time_series_metric: "gauge",
},
rss: {
properties: {
bytes: {
type: "long",
time_series_metric: "gauge",
},
},
},
usage: {
properties: {
bytes: {
type: "long",
time_series_metric: "gauge",
},
limit: {
properties: {
pct: {
type: "float",
},
},
},
node: {
properties: {
pct: {
type: "float",
},
},
},
},
},
workingset: {
properties: {
bytes: {
type: "long",
time_series_metric: "gauge",
},
},
},
},
},
name: {
type: "keyword",
},
start_time: {
type: "date",
},
},
},
host: {
type: "keyword",
time_series_dimension: true,
},
namespace: {
type: "keyword",
time_series_dimension: true,
},
node: {
type: "keyword",
time_series_dimension: true,
},
pod: {
type: "keyword",
time_series_dimension: true,
},
},
},
},
},
},
});
console.log(response);
Console
PUT _index_template/datastream_template
{
"index_patterns": [
"datastream*"
],
"data_stream": {},
"template": {
"settings": {
"index": {
"mode": "time_series",
"number_of_replicas": 0,
"number_of_shards": 2
},
"index.lifecycle.name": "datastream_policy"
},
"mappings": {
"properties": {
"@timestamp": {
"type": "date"
},
"kubernetes": {
"properties": {
"container": {
"properties": {
"cpu": {
"properties": {
"usage": {
"properties": {
"core": {
"properties": {
"ns": {
"type": "long"
}
}
},
"limit": {
"properties": {
"pct": {
"type": "float"
}
}
},
"nanocores": {
"type": "long",
"time_series_metric": "gauge"
},
"node": {
"properties": {
"pct": {
"type": "float"
}
}
}
}
}
}
},
"memory": {
"properties": {
"available": {
"properties": {
"bytes": {
"type": "long",
"time_series_metric": "gauge"
}
}
},
"majorpagefaults": {
"type": "long"
},
"pagefaults": {
"type": "long",
"time_series_metric": "gauge"
},
"rss": {
"properties": {
"bytes": {
"type": "long",
"time_series_metric": "gauge"
}
}
},
"usage": {
"properties": {
"bytes": {
"type": "long",
"time_series_metric": "gauge"
},
"limit": {
"properties": {
"pct": {
"type": "float"
}
}
},
"node": {
"properties": {
"pct": {
"type": "float"
}
}
}
}
},
"workingset": {
"properties": {
"bytes": {
"type": "long",
"time_series_metric": "gauge"
}
}
}
}
},
"name": {
"type": "keyword"
},
"start_time": {
"type": "date"
}
}
},
"host": {
"type": "keyword",
"time_series_dimension": true
},
"namespace": {
"type": "keyword",
"time_series_dimension": true
},
"node": {
"type": "keyword",
"time_series_dimension": true
},
"pod": {
"type": "keyword",
"time_series_dimension": true
}
}
}
}
}
}
}
時系列データの取り込み
バルクAPIリクエストを使用して、TSDSを自動的に作成し、10件のドキュメントをインデックスします。
重要: このバルクリクエストを実行する前に、タイムスタンプを現在の時間の3〜5時間後に更新する必要があります。つまり、2022-06-21T15
を検索し、現在の日付に置き換え、時間を現在の時間に3時間加えます。
Python
resp = client.bulk(
index="datastream",
refresh=True,
operations=[
{
"create": {}
},
{
"@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": 0.0000277905
},
"limit": {
"pct": 0.0000277905
}
}
},
"memory": {
"available": {
"bytes": 463314616
},
"usage": {
"bytes": 307007078,
"node": {
"pct": 0.01770037710617187
},
"limit": {
"pct": 0.00009923134671484496
}
},
"workingset": {
"bytes": 585236
},
"rss": {
"bytes": 102728
},
"pagefaults": 120901,
"majorpagefaults": 0
},
"start_time": "2021-03-30T07:59:06Z",
"name": "container-name-44"
},
"namespace": "namespace26"
}
},
{
"create": {}
},
{
"@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": 0.0000277905
},
"limit": {
"pct": 0.0000277905
}
}
},
"memory": {
"available": {
"bytes": 982546514
},
"usage": {
"bytes": 360035574,
"node": {
"pct": 0.01770037710617187
},
"limit": {
"pct": 0.00009923134671484496
}
},
"workingset": {
"bytes": 1339884
},
"rss": {
"bytes": 381174
},
"pagefaults": 178473,
"majorpagefaults": 0
},
"start_time": "2021-03-30T07:59:06Z",
"name": "container-name-44"
},
"namespace": "namespace26"
}
},
{
"create": {}
},
{
"@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": 0.0000277905
},
"limit": {
"pct": 0.0000277905
}
}
},
"memory": {
"available": {
"bytes": 862723768
},
"usage": {
"bytes": 379572388,
"node": {
"pct": 0.01770037710617187
},
"limit": {
"pct": 0.00009923134671484496
}
},
"workingset": {
"bytes": 431227
},
"rss": {
"bytes": 386580
},
"pagefaults": 233166,
"majorpagefaults": 0
},
"start_time": "2021-03-30T07:59:06Z",
"name": "container-name-44"
},
"namespace": "namespace26"
}
},
{
"create": {}
},
{
"@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": 0.0000277905
},
"limit": {
"pct": 0.0000277905
}
}
},
"memory": {
"available": {
"bytes": 567160996
},
"usage": {
"bytes": 103266017,
"node": {
"pct": 0.01770037710617187
},
"limit": {
"pct": 0.00009923134671484496
}
},
"workingset": {
"bytes": 1724908
},
"rss": {
"bytes": 105431
},
"pagefaults": 233166,
"majorpagefaults": 0
},
"start_time": "2021-03-30T07:59:06Z",
"name": "container-name-44"
},
"namespace": "namespace26"
}
},
{
"create": {}
},
{
"@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": 0.0000277905
},
"limit": {
"pct": 0.0000277905
}
}
},
"memory": {
"available": {
"bytes": 639054643
},
"usage": {
"bytes": 265142477,
"node": {
"pct": 0.01770037710617187
},
"limit": {
"pct": 0.00009923134671484496
}
},
"workingset": {
"bytes": 1786511
},
"rss": {
"bytes": 189235
},
"pagefaults": 138172,
"majorpagefaults": 0
},
"start_time": "2021-03-30T07:59:06Z",
"name": "container-name-44"
},
"namespace": "namespace26"
}
},
{
"create": {}
},
{
"@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": 0.0000277905
},
"limit": {
"pct": 0.0000277905
}
}
},
"memory": {
"available": {
"bytes": 854735585
},
"usage": {
"bytes": 309798052,
"node": {
"pct": 0.01770037710617187
},
"limit": {
"pct": 0.00009923134671484496
}
},
"workingset": {
"bytes": 924058
},
"rss": {
"bytes": 110838
},
"pagefaults": 259073,
"majorpagefaults": 0
},
"start_time": "2021-03-30T07:59:06Z",
"name": "container-name-44"
},
"namespace": "namespace26"
}
},
{
"create": {}
},
{
"@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": 0.0000277905
},
"limit": {
"pct": 0.0000277905
}
}
},
"memory": {
"available": {
"bytes": 279586406
},
"usage": {
"bytes": 214904955,
"node": {
"pct": 0.01770037710617187
},
"limit": {
"pct": 0.00009923134671484496
}
},
"workingset": {
"bytes": 1047265
},
"rss": {
"bytes": 91914
},
"pagefaults": 302252,
"majorpagefaults": 0
},
"start_time": "2021-03-30T07:59:06Z",
"name": "container-name-44"
},
"namespace": "namespace26"
}
},
{
"create": {}
},
{
"@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": 0.0000277905
},
"limit": {
"pct": 0.0000277905
}
}
},
"memory": {
"available": {
"bytes": 822782853
},
"usage": {
"bytes": 100475044,
"node": {
"pct": 0.01770037710617187
},
"limit": {
"pct": 0.00009923134671484496
}
},
"workingset": {
"bytes": 2109932
},
"rss": {
"bytes": 278446
},
"pagefaults": 74843,
"majorpagefaults": 0
},
"start_time": "2021-03-30T07:59:06Z",
"name": "container-name-44"
},
"namespace": "namespace26"
}
},
{
"create": {}
},
{
"@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": 0.0000277905
},
"limit": {
"pct": 0.0000277905
}
}
},
"memory": {
"available": {
"bytes": 567160996
},
"usage": {
"bytes": 362826547,
"node": {
"pct": 0.01770037710617187
},
"limit": {
"pct": 0.00009923134671484496
}
},
"workingset": {
"bytes": 1986724
},
"rss": {
"bytes": 402801
},
"pagefaults": 296495,
"majorpagefaults": 0
},
"start_time": "2021-03-30T07:59:06Z",
"name": "container-name-44"
},
"namespace": "namespace26"
}
},
{
"create": {}
},
{
"@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": 0.0000277905
},
"limit": {
"pct": 0.0000277905
}
}
},
"memory": {
"available": {
"bytes": 1062428344
},
"usage": {
"bytes": 265142477,
"node": {
"pct": 0.01770037710617187
},
"limit": {
"pct": 0.00009923134671484496
}
},
"workingset": {
"bytes": 2294743
},
"rss": {
"bytes": 340623
},
"pagefaults": 224530,
"majorpagefaults": 0
},
"start_time": "2021-03-30T07:59:06Z",
"name": "container-name-44"
},
"namespace": "namespace26"
}
}
],
)
print(resp)
Ruby
response = client.bulk(
index: 'datastream',
refresh: true,
body: [
{
create: {}
},
{
"@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: 91_153,
core: {
ns: 12_828_317_850
},
node: {
pct: 2.77905e-05
},
limit: {
pct: 2.77905e-05
}
}
},
memory: {
available: {
bytes: 463_314_616
},
usage: {
bytes: 307_007_078,
node: {
pct: 0.01770037710617187
},
limit: {
pct: 9.923134671484496e-05
}
},
workingset: {
bytes: 585_236
},
rss: {
bytes: 102_728
},
pagefaults: 120_901,
majorpagefaults: 0
},
start_time: '2021-03-30T07:59:06Z',
name: 'container-name-44'
},
namespace: 'namespace26'
}
},
{
create: {}
},
{
"@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: 124_501,
core: {
ns: 12_828_317_850
},
node: {
pct: 2.77905e-05
},
limit: {
pct: 2.77905e-05
}
}
},
memory: {
available: {
bytes: 982_546_514
},
usage: {
bytes: 360_035_574,
node: {
pct: 0.01770037710617187
},
limit: {
pct: 9.923134671484496e-05
}
},
workingset: {
bytes: 1_339_884
},
rss: {
bytes: 381_174
},
pagefaults: 178_473,
majorpagefaults: 0
},
start_time: '2021-03-30T07:59:06Z',
name: 'container-name-44'
},
namespace: 'namespace26'
}
},
{
create: {}
},
{
"@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: 38_907,
core: {
ns: 12_828_317_850
},
node: {
pct: 2.77905e-05
},
limit: {
pct: 2.77905e-05
}
}
},
memory: {
available: {
bytes: 862_723_768
},
usage: {
bytes: 379_572_388,
node: {
pct: 0.01770037710617187
},
limit: {
pct: 9.923134671484496e-05
}
},
workingset: {
bytes: 431_227
},
rss: {
bytes: 386_580
},
pagefaults: 233_166,
majorpagefaults: 0
},
start_time: '2021-03-30T07:59:06Z',
name: 'container-name-44'
},
namespace: 'namespace26'
}
},
{
create: {}
},
{
"@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: 86_706,
core: {
ns: 12_828_317_850
},
node: {
pct: 2.77905e-05
},
limit: {
pct: 2.77905e-05
}
}
},
memory: {
available: {
bytes: 567_160_996
},
usage: {
bytes: 103_266_017,
node: {
pct: 0.01770037710617187
},
limit: {
pct: 9.923134671484496e-05
}
},
workingset: {
bytes: 1_724_908
},
rss: {
bytes: 105_431
},
pagefaults: 233_166,
majorpagefaults: 0
},
start_time: '2021-03-30T07:59:06Z',
name: 'container-name-44'
},
namespace: 'namespace26'
}
},
{
create: {}
},
{
"@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: 150_069,
core: {
ns: 12_828_317_850
},
node: {
pct: 2.77905e-05
},
limit: {
pct: 2.77905e-05
}
}
},
memory: {
available: {
bytes: 639_054_643
},
usage: {
bytes: 265_142_477,
node: {
pct: 0.01770037710617187
},
limit: {
pct: 9.923134671484496e-05
}
},
workingset: {
bytes: 1_786_511
},
rss: {
bytes: 189_235
},
pagefaults: 138_172,
majorpagefaults: 0
},
start_time: '2021-03-30T07:59:06Z',
name: 'container-name-44'
},
namespace: 'namespace26'
}
},
{
create: {}
},
{
"@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: 82_260,
core: {
ns: 12_828_317_850
},
node: {
pct: 2.77905e-05
},
limit: {
pct: 2.77905e-05
}
}
},
memory: {
available: {
bytes: 854_735_585
},
usage: {
bytes: 309_798_052,
node: {
pct: 0.01770037710617187
},
limit: {
pct: 9.923134671484496e-05
}
},
workingset: {
bytes: 924_058
},
rss: {
bytes: 110_838
},
pagefaults: 259_073,
majorpagefaults: 0
},
start_time: '2021-03-30T07:59:06Z',
name: 'container-name-44'
},
namespace: 'namespace26'
}
},
{
create: {}
},
{
"@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: 153_404,
core: {
ns: 12_828_317_850
},
node: {
pct: 2.77905e-05
},
limit: {
pct: 2.77905e-05
}
}
},
memory: {
available: {
bytes: 279_586_406
},
usage: {
bytes: 214_904_955,
node: {
pct: 0.01770037710617187
},
limit: {
pct: 9.923134671484496e-05
}
},
workingset: {
bytes: 1_047_265
},
rss: {
bytes: 91_914
},
pagefaults: 302_252,
majorpagefaults: 0
},
start_time: '2021-03-30T07:59:06Z',
name: 'container-name-44'
},
namespace: 'namespace26'
}
},
{
create: {}
},
{
"@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: 125_613,
core: {
ns: 12_828_317_850
},
node: {
pct: 2.77905e-05
},
limit: {
pct: 2.77905e-05
}
}
},
memory: {
available: {
bytes: 822_782_853
},
usage: {
bytes: 100_475_044,
node: {
pct: 0.01770037710617187
},
limit: {
pct: 9.923134671484496e-05
}
},
workingset: {
bytes: 2_109_932
},
rss: {
bytes: 278_446
},
pagefaults: 74_843,
majorpagefaults: 0
},
start_time: '2021-03-30T07:59:06Z',
name: 'container-name-44'
},
namespace: 'namespace26'
}
},
{
create: {}
},
{
"@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: 100_046,
core: {
ns: 12_828_317_850
},
node: {
pct: 2.77905e-05
},
limit: {
pct: 2.77905e-05
}
}
},
memory: {
available: {
bytes: 567_160_996
},
usage: {
bytes: 362_826_547,
node: {
pct: 0.01770037710617187
},
limit: {
pct: 9.923134671484496e-05
}
},
workingset: {
bytes: 1_986_724
},
rss: {
bytes: 402_801
},
pagefaults: 296_495,
majorpagefaults: 0
},
start_time: '2021-03-30T07:59:06Z',
name: 'container-name-44'
},
namespace: 'namespace26'
}
},
{
create: {}
},
{
"@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: 40_018,
core: {
ns: 12_828_317_850
},
node: {
pct: 2.77905e-05
},
limit: {
pct: 2.77905e-05
}
}
},
memory: {
available: {
bytes: 1_062_428_344
},
usage: {
bytes: 265_142_477,
node: {
pct: 0.01770037710617187
},
limit: {
pct: 9.923134671484496e-05
}
},
workingset: {
bytes: 2_294_743
},
rss: {
bytes: 340_623
},
pagefaults: 224_530,
majorpagefaults: 0
},
start_time: '2021-03-30T07:59:06Z',
name: 'container-name-44'
},
namespace: 'namespace26'
}
}
]
)
puts response
Js
const response = await client.bulk({
index: "datastream",
refresh: "true",
operations: [
{
create: {},
},
{
"@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: 0.0000277905,
},
limit: {
pct: 0.0000277905,
},
},
},
memory: {
available: {
bytes: 463314616,
},
usage: {
bytes: 307007078,
node: {
pct: 0.01770037710617187,
},
limit: {
pct: 0.00009923134671484496,
},
},
workingset: {
bytes: 585236,
},
rss: {
bytes: 102728,
},
pagefaults: 120901,
majorpagefaults: 0,
},
start_time: "2021-03-30T07:59:06Z",
name: "container-name-44",
},
namespace: "namespace26",
},
},
{
create: {},
},
{
"@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: 0.0000277905,
},
limit: {
pct: 0.0000277905,
},
},
},
memory: {
available: {
bytes: 982546514,
},
usage: {
bytes: 360035574,
node: {
pct: 0.01770037710617187,
},
limit: {
pct: 0.00009923134671484496,
},
},
workingset: {
bytes: 1339884,
},
rss: {
bytes: 381174,
},
pagefaults: 178473,
majorpagefaults: 0,
},
start_time: "2021-03-30T07:59:06Z",
name: "container-name-44",
},
namespace: "namespace26",
},
},
{
create: {},
},
{
"@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: 0.0000277905,
},
limit: {
pct: 0.0000277905,
},
},
},
memory: {
available: {
bytes: 862723768,
},
usage: {
bytes: 379572388,
node: {
pct: 0.01770037710617187,
},
limit: {
pct: 0.00009923134671484496,
},
},
workingset: {
bytes: 431227,
},
rss: {
bytes: 386580,
},
pagefaults: 233166,
majorpagefaults: 0,
},
start_time: "2021-03-30T07:59:06Z",
name: "container-name-44",
},
namespace: "namespace26",
},
},
{
create: {},
},
{
"@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: 0.0000277905,
},
limit: {
pct: 0.0000277905,
},
},
},
memory: {
available: {
bytes: 567160996,
},
usage: {
bytes: 103266017,
node: {
pct: 0.01770037710617187,
},
limit: {
pct: 0.00009923134671484496,
},
},
workingset: {
bytes: 1724908,
},
rss: {
bytes: 105431,
},
pagefaults: 233166,
majorpagefaults: 0,
},
start_time: "2021-03-30T07:59:06Z",
name: "container-name-44",
},
namespace: "namespace26",
},
},
{
create: {},
},
{
"@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: 0.0000277905,
},
limit: {
pct: 0.0000277905,
},
},
},
memory: {
available: {
bytes: 639054643,
},
usage: {
bytes: 265142477,
node: {
pct: 0.01770037710617187,
},
limit: {
pct: 0.00009923134671484496,
},
},
workingset: {
bytes: 1786511,
},
rss: {
bytes: 189235,
},
pagefaults: 138172,
majorpagefaults: 0,
},
start_time: "2021-03-30T07:59:06Z",
name: "container-name-44",
},
namespace: "namespace26",
},
},
{
create: {},
},
{
"@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: 0.0000277905,
},
limit: {
pct: 0.0000277905,
},
},
},
memory: {
available: {
bytes: 854735585,
},
usage: {
bytes: 309798052,
node: {
pct: 0.01770037710617187,
},
limit: {
pct: 0.00009923134671484496,
},
},
workingset: {
bytes: 924058,
},
rss: {
bytes: 110838,
},
pagefaults: 259073,
majorpagefaults: 0,
},
start_time: "2021-03-30T07:59:06Z",
name: "container-name-44",
},
namespace: "namespace26",
},
},
{
create: {},
},
{
"@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: 0.0000277905,
},
limit: {
pct: 0.0000277905,
},
},
},
memory: {
available: {
bytes: 279586406,
},
usage: {
bytes: 214904955,
node: {
pct: 0.01770037710617187,
},
limit: {
pct: 0.00009923134671484496,
},
},
workingset: {
bytes: 1047265,
},
rss: {
bytes: 91914,
},
pagefaults: 302252,
majorpagefaults: 0,
},
start_time: "2021-03-30T07:59:06Z",
name: "container-name-44",
},
namespace: "namespace26",
},
},
{
create: {},
},
{
"@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: 0.0000277905,
},
limit: {
pct: 0.0000277905,
},
},
},
memory: {
available: {
bytes: 822782853,
},
usage: {
bytes: 100475044,
node: {
pct: 0.01770037710617187,
},
limit: {
pct: 0.00009923134671484496,
},
},
workingset: {
bytes: 2109932,
},
rss: {
bytes: 278446,
},
pagefaults: 74843,
majorpagefaults: 0,
},
start_time: "2021-03-30T07:59:06Z",
name: "container-name-44",
},
namespace: "namespace26",
},
},
{
create: {},
},
{
"@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: 0.0000277905,
},
limit: {
pct: 0.0000277905,
},
},
},
memory: {
available: {
bytes: 567160996,
},
usage: {
bytes: 362826547,
node: {
pct: 0.01770037710617187,
},
limit: {
pct: 0.00009923134671484496,
},
},
workingset: {
bytes: 1986724,
},
rss: {
bytes: 402801,
},
pagefaults: 296495,
majorpagefaults: 0,
},
start_time: "2021-03-30T07:59:06Z",
name: "container-name-44",
},
namespace: "namespace26",
},
},
{
create: {},
},
{
"@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: 0.0000277905,
},
limit: {
pct: 0.0000277905,
},
},
},
memory: {
available: {
bytes: 1062428344,
},
usage: {
bytes: 265142477,
node: {
pct: 0.01770037710617187,
},
limit: {
pct: 0.00009923134671484496,
},
},
workingset: {
bytes: 2294743,
},
rss: {
bytes: 340623,
},
pagefaults: 224530,
majorpagefaults: 0,
},
start_time: "2021-03-30T07:59:06Z",
name: "container-name-44",
},
namespace: "namespace26",
},
},
],
});
console.log(response);
Console
PUT /datastream/_bulk?refresh
{"create": {}}
{"@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"}}
{"create": {}}
{"@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"}}
{"create": {}}
{"@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"}}
{"create": {}}
{"@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"}}
{"create": {}}
{"@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"}}
{"create": {}}
{"@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"}}
{"create": {}}
{"@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"}}
{"create": {}}
{"@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"}}
{"create": {}}
{"@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"}}
{"create": {}}
{"@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
resp = client.indices.get_data_stream()
print(resp)
Ruby
response = client.indices.get_data_stream
puts response
Js
const response = await client.indices.getDataStream();
console.log(response);
Console
GET _data_stream
ILMポリシーがまだ適用されていない場合、結果は次のようになります。元のindex_name
に注意してください:.ds-datastream-<timestamp>-000001
。
Console-Result
{
"data_streams": [
{
"name": "datastream",
"timestamp_field": {
"name": "@timestamp"
},
"indices": [
{
"index_name": ".ds-datastream-2022.08.26-000001",
"index_uuid": "5g-3HrfETga-5EFKBM6R-w"
},
{
"index_name": ".ds-datastream-2022.08.26-000002",
"index_uuid": "o0yRTdhWSo2pY8XMvfwy7Q"
}
],
"generation": 2,
"status": "GREEN",
"template": "datastream_template",
"ilm_policy": "datastream_policy",
"hidden": false,
"system": false,
"allow_custom_routing": false,
"replicated": false,
"rollover_on_write": false,
"time_series": {
"temporal_ranges": [
{
"start": "2022-08-26T13:29:07.000Z",
"end": "2022-08-26T19:29:07.000Z"
}
]
}
}
]
}
次に、検索クエリを実行します:
Python
resp = client.search(
index="datastream",
)
print(resp)
Ruby
response = client.search(
index: 'datastream'
)
puts response
Js
const response = await client.search({
index: "datastream",
});
console.log(response);
Console
GET datastream/_search
Console-Result
{
"took": 17,
"timed_out": false,
"_shards": {
"total": 4,
"successful": 4,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 10,
"relation": "eq"
},
...
デフォルトでは、インデックスライフサイクル管理は、ポリシー基準を満たすインデックスを10分ごとにチェックします。約10分待って(コーヒーやお茶を淹れるのも良いかもしれません☕)、GET _data_stream
リクエストを再実行してください。
Python
resp = client.indices.get_data_stream()
print(resp)
Ruby
response = client.indices.get_data_stream
puts response
Js
const response = await client.indices.getDataStream();
console.log(response);
Console
GET _data_stream
ILMポリシーが適用された後、元の.ds-datastream-2022.08.26-000001
インデックスは新しいダウンサンプリングされたインデックスdownsample-6tkn-.ds-datastream-2022.08.26-000001
に置き換えられます。
Console-Result
{
"data_streams": [
{
"name": "datastream",
"timestamp_field": {
"name": "@timestamp"
},
"indices": [
{
"index_name": "downsample-6tkn-.ds-datastream-2022.08.26-000001",
"index_uuid": "qRane1fQQDCNgKQhXmTIvg"
},
{
"index_name": ".ds-datastream-2022.08.26-000002",
"index_uuid": "o0yRTdhWSo2pY8XMvfwy7Q"
}
],
...
データストリームに対して検索クエリを実行します(ダウンサンプリングされたインデックスをクエリする際には、注意すべきいくつかのニュアンスがあります)。
Python
resp = client.search(
index="datastream",
)
print(resp)
Ruby
response = client.search(
index: 'datastream'
)
puts response
Js
const response = await client.search({
index: "datastream",
});
console.log(response);
Console
GET datastream/_search
新しいダウンサンプリングされたインデックスには、元のサンプリングされたメトリックに基づくmin
、max
、sum
、およびvalue_count
統計を含む1つのドキュメントのみが含まれています。
Console-Result
{
"took": 6,
"timed_out": false,
"_shards": {
"total": 4,
"successful": 4,
"skipped": 0,
"failed": 0
},
"hits": {
"total": {
"value": 1,
"relation": "eq"
},
"max_score": 1,
"hits": [
{
"_index": "downsample-6tkn-.ds-datastream-2022.08.26-000001",
"_id": "0eL0wC_4-45SnTNFAAABgtpz0wA",
"_score": 1,
"_source": {
"@timestamp": "2022-08-26T14:00:00.000Z",
"_doc_count": 10,
"kubernetes.host": "gke-apps-0",
"kubernetes.namespace": "namespace26",
"kubernetes.node": "gke-apps-0-0",
"kubernetes.pod": "gke-apps-0-0-0",
"kubernetes.container.cpu.usage.nanocores": {
"min": 38907,
"max": 153404,
"sum": 992677,
"value_count": 10
},
"kubernetes.container.memory.available.bytes": {
"min": 279586406,
"max": 1062428344,
"sum": 7101494721,
"value_count": 10
},
"kubernetes.container.memory.pagefaults": {
"min": 74843,
"max": 302252,
"sum": 2061071,
"value_count": 10
},
"kubernetes.container.memory.rss.bytes": {
"min": 91914,
"max": 402801,
"sum": 2389770,
"value_count": 10
},
"kubernetes.container.memory.usage.bytes": {
"min": 100475044,
"max": 379572388,
"sum": 2668170609,
"value_count": 10
},
"kubernetes.container.memory.workingset.bytes": {
"min": 431227,
"max": 2294743,
"sum": 14230488,
"value_count": 10
},
"kubernetes.container.cpu.usage.core.ns": 12828317850,
"kubernetes.container.cpu.usage.limit.pct": 0.000027790500098490156,
"kubernetes.container.cpu.usage.node.pct": 0.000027790500098490156,
"kubernetes.container.memory.majorpagefaults": 0,
"kubernetes.container.memory.usage.limit.pct": 0.00009923134348355234,
"kubernetes.container.memory.usage.node.pct": 0.017700377851724625,
"kubernetes.container.name": "container-name-44",
"kubernetes.container.start_time": "2021-03-30T07:59:06.000Z"
}
}
]
}
}
データストリーム統計APIを使用して、データストリームの統計を取得し、ストレージサイズを含めます。
Python
resp = client.indices.data_streams_stats(
name="datastream",
human=True,
)
print(resp)
Ruby
response = client.indices.data_streams_stats(
name: 'datastream',
human: true
)
puts response
Js
const response = await client.indices.dataStreamsStats({
name: "datastream",
human: "true",
});
console.log(response);
Console
GET /_data_stream/datastream/_stats?human=true
Console-Result
{
"_shards": {
"total": 4,
"successful": 4,
"failed": 0
},
"data_stream_count": 1,
"backing_indices": 2,
"total_store_size": "16.6kb",
"total_store_size_bytes": 17059,
"data_streams": [
{
"data_stream": "datastream",
"backing_indices": 2,
"store_size": "16.6kb",
"store_size_bytes": 17059,
"maximum_timestamp": 1661522400000
}
]
}
この例は、メトリックデータのストレージサイズを削減するために、ダウンサンプリングがILMポリシーの一部としてどのように機能するかを示しています。データが古くなり、頻繁にクエリされなくなるにつれて。
また、ILMポリシーの外でダウンサンプリングがどのように機能するかを学ぶために、手動でダウンサンプリングを実行する例を試すこともできます。