datastream操作步骤

2024-09-26 15:15:11 浏览数 (1)

代码语言:txt复制
GET _ilm/policy/demo_1
PUT _ilm/policy/demo_1
{
  "policy": {
    "phases": {
      "hot": {
        "min_age": "0",
        "actions": {
          "set_priority": {
            "priority": 100
          },
          "rollover": {
            "max_age": "3d",
            "max_docs": 3,
            "max_size": "2gb"
          }
        }
      },
      "warm": {
        "min_age": "1d",
        "actions": {
          "set_priority": {
            "priority": 50
          },
          "allocate": {
            "number_of_replicas": 0
          },
          "shrink": {
            "number_of_shards": 1
          },
          "forcemerge": {
            "max_num_segments": 1
          }
        }
      }
    }
  }
}

PUT _cluster/settings
{
    "transient": {
      "indices.lifecycle.poll_interval": "10s"
    }
}

PUT _index_template/template_demo
{
  "index_patterns": ["demo-*"],
   "priority": 200,
   "data_stream": { }, 
   "template": {
     "settings": {
       "number_of_replicas": 1,
       "number_of_shards": 3,
       "index.lifecycle.name":"demo_1"
     }
   }
}

PUT _ingest/pipeline/add-timestamp
{
  "processors": [
    {
      "set": {
        "field": "@timestamp",
        "value": "{{_ingest.timestamp}}"
      }
    }
  ]
}

PUT _data_stream/demo-ds
GET  demo-ds/_search

POST demo-ds/_doc?pipeline=add-timestamp
{
  "user":{
    "id":"zhouyinhui"
  },
  "message":"this is so coo"
}

GET demo-ds/_ilm/explain

GET demo-ds/_search

DELETE _data_stream/demo-ds

POST _index_template/_simulate_index/demo-ds


0 人点赞