所以我想获取某个时间以来的所有事件,例如"2017-03-02T21:56:53.033Z"
以来的所有事件。
我创建了一个runtime_timestamp
字段,该字段仅复制了@timestamp
字段,因为我正在将这些数据解析为C#,并且@
符号在其中不能很好地发挥作用。
这是我的Logstash过滤器,可以起作用。我知道这是一个事实。
filter {
mutate {
add_field => ["runtime_timestamp", "%{@timestamp}"]
}
}
这是我现在所拥有的,不起作用。
{
"query": {
"range": {
"runtime_timestamp":
"2017-03-02T21:56:53.033Z"
},
"_source": {
"includes": [
"runtime_timestamp",
"id_orig_p",
"id_orig_p",
"id_orig_h",
"conn_state",
"id_resp_h",
"id_resp_p",
"service",
"proto",
"tags"
]
},
"sort": [
{
"@timestamp": {
"order": "desc"
}
}
]
}
现在,我从此查询中收到以下错误。
{
"error" : {
"root_cause" : [
{
"type" : "parsing_exception",
"reason" : "[range] query does not support [runtime_timestamp]",
"line" : 5,
"col" : 9
}
],
"type" : "parsing_exception",
"reason" : "[range] query does not support [runtime_timestamp]",
"line" : 5,
"col" : 9
},
"status" : 400
}
我也用
timestamp
代替runtime_timestamp
尝试了此查询,但仍然出现相同的错误。
最佳答案
您的范围查询格式不正确。尝试以下方法(gte表示大于或等于):
{
"query": {
"range" : {
"runtime_timestamp" : {
"gte": "2017-03-02T21:56:53.033Z",
}
}
}
}
关于http - 在Logstash中按时间戳查询项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42567104/