如果您有一个新纪元时间戳,则无需制作和ISO8601日期。为了让Kibana识别该字段,因为日期必须是日期字段。
请注意,您必须将字段设置为日期类型之前您将任何数据输入到/ index/type。否则它将被存储为长期且不可更改。
简单的例子,可以被粘贴到marvel/sense插件:每个系列这些命令
# Make sure the index isn't there
DELETE /logger
# Create the index
PUT /logger
# Add the mapping of properties to the document type `mem`
PUT /logger/_mapping/mem
{
"mem": {
"properties": {
"timestamp": {
"type": "date"
},
"free": {
"type": "long"
}
}
}
}
# Inspect the newly created mapping
GET /logger/_mapping/mem
运行。
生成自由MEM日志
下面是一个简单的脚本回显到终端和日志到您的本地elasticsearch:
while ((1==1)); do memfree=`free -b|tail -n 1|tr -s ' ' ' '|cut -d ' ' -f4`; echo $load; curl -XPOST "localhost:9200/logger/mem" -d "{ \"timestamp\": `date +%s%3N`, \"free\": $memfree }"; sleep 1; done
检查数据弹性搜索
中粘贴此您marvel/sense
GET /logger/mem/_search
现在你可以移动到Kibana并做一些图表。 Kibana会自动检测你的日期字段。