2017-03-02 79 views
0

因此,我想从某个时间以来获取所有事件,例如自"2017-03-02T21:56:53.033Z"以来。通过Logstash中的时间戳查询项目

我做了一个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 
} 

我代替runtime_timestamp尝试这种查询也与timestamp,我仍然得到同样的错误。

回答

1

您的范围查询格式不正确。试试这个(gte意味着大于或等于):

{ 
    "query": { 
     "range" : { 
      "runtime_timestamp" : { 
       "gte": "2017-03-02T21:56:53.033Z", 
      } 
     } 
    } 
} 
+0

这解决了我的问题,谢谢! – BenjaFriend