---
title: Elasticsearch Data Stream 与索引模板管理实践
keywords: data_stream, index template, rollover, @timestamp, _data_stream
description: 创建数据流与模板,按时间写入并稳定滚动,提升日志与时序数据管理能力。
tags:
- '@timestamp'
- Elasticsearch
- _data_stream
- data_stream
- index template
- rollover
- 搜索
- 数据流
categories:
- 文章资讯
- 技术教程
---
索引模板(启用 data_stream):
PUT _index_template/logs-template
{
"index_patterns": ["logs-*"],
"data_stream": {},
"template": {
"mappings": {
"properties": {
"@timestamp": { "type": "date" },
"message": { "type": "text" }
}
}
}
}
创建数据流并写入:
PUT _data_stream/logs
POST /logs/_doc
{
"@timestamp": "2025-11-26T10:00:00Z",
"message": "service started"
}
查看数据流:
GET _data_stream/logs

发表评论 取消回复