使用模式匹配从graylog2删除消息

时间:2018-09-21 08:08:22

标签: elasticsearch graylog2

我正在努力寻找一种正确的语法/查询,以基于匹配“源”字段的模式(如ES和Graylog的2.4.6)从graylog2实例删除多条消息(如在Graylog Webui中可以看到)。

我已经尝试了很多组合,但是没有用:

root@log [~]: curl -XDELETE 'http://localhost:9200/graylog_71/message/_query' -d'{"query" : {"term": { "source" : "exact_server_name_here"}}}'
{"found":false,"_index":"graylog_71","_type":"message","_id":"_query","_version":2,"_shards":{"total":1,"successful":1,"failed":0}}

另一种尝试:

root@log [~]: curl -XDELETE 'http://localhost:9200/graylog_71/message/_query' -d '                                                             
{
  "query": {
    "query_string" : {
      "query" : "exact_server_name_here"
    }
  }
}
'

我也检查了此SO帖子,该帖子虽然有效,但不符合我的需求: Delete a specific log message from Graylog

回答val评论:是的,已经安装了delete插件(我在最初的帖子中忘记提及了这一点)

我是ES新手,您是熊:)

谢谢

[编辑#1] 根据Val请求:

root@log [~]: curl 'localhost:9200/_cat/plugins?v'
name component version type url

1 个答案:

答案 0 :(得分:0)

好吧,我不好,ES新手并不能原谅一切,实际上已经安装了插件,但是需要重新启动ES使其可用(如_cat / plugin查询所示)

重新启动后,以下查询将正常运行(当然):

curl -XDELETE 'http://localhost:9200/graylog_68/message/_query' -d '
{
  "query": {
    "query_string" : {
      "query" : "source : <exact_server_name_here>"
    }
  }
}
'

感谢Val提供的指针。

相关问题