【发布时间】:2015-06-02 21:12:40
【问题描述】:
我正在尝试确定我的 logstash 集群中最新记录的新鲜度,但我在消化 Elasticsearch DSL 时遇到了一些麻烦。
现在我正在做这样的事情来提取时间戳: curl -sX GET 'http://localhost:9200/logstash-2015.06.02/' -d'{"query": {"match_all": {} } }' | json_pp | grep 时间戳
这让我着迷; "@timestamp" : "2015-06-02T00:00:28.371+00:00",
我想直接使用 elasticsearch 查询,没有 grep hackiness。
原始 JSON(截断长度)如下所示:
{
"took" : 115,
"timed_out" : false,
"hits" : {
"hits" : [
{
"_index" : "logstash-2015.06.02",
"_source" : {
"type" : "syslog",
"@timestamp" : "2015-06-02T00:00:28.371+00:00",
"tags" : [
"sys",
"inf"
],
"message" : " 2015/06/02 00:00:28 [INFO] serf: EventMemberJoin: generichost.example.com 10.1.1.10",
"file" : "/var/log/consul.log",
"@version" : 1,
"host" : "generichost.example.com"
},
"_id" : "AU4xcf51cXOri9NL1hro",
"_score" : 1,
"_type" : "syslog"
},
],
"total" : 8605141,
"max_score" : 1
},
"_shards" : {
"total" : 50,
"successful" : 50,
"failed" : 0
}
}
任何帮助将不胜感激。我知道查询很简单,我只是不知道它是什么。
【问题讨论】:
标签: json parsing elasticsearch logstash dsl