首页 文章

任何人都可以提供REST API列表来查询elasticsearch吗?

提问于
浏览
1
  • 我试图通过logstash将我的日志推送到elasticsearch .

  • 我的 logstash.conf 有2个日志文件作为输入;弹性搜索作为输出;和grok作为过滤器 . 这是我的grok比赛:

grok {
  match => [ "message", "(?<timestamp>[0-9]{4}-[0-9]{2}-[0-9]{2}
[0-9]{2}:[0-9]{2}:[0-9]{2},[0-9]{3}) 
(?:\[%{GREEDYDATA:caller_thread}\]) (?:%{LOGLEVEL:level}) 
(?:%{DATA:caller_class})(?:\-%{GREEDYDATA:message})" ]
   }
  • 当弹性搜索启动时,我的所有日志都会添加到具有单独索引名称的elasticsearch服务器,如 logstash.conf 中所述 .

  • 我的疑问是我的日志如何存储在elasticsearch中?我只知道它与logstash中提到的索引名一起存储 .

'http://164.99.178.18:9200/_cat/indices?v'API给了我以下内容:

Health 状况索引pri rep docs.count docs.deleted store.size pri.store.size

yellow open   tomcat-log      5   1       6478            0      1.9mb          1.9mb 

yellow open   apache-log      5   1        212            0      137kb   
   137kb
  • 但是,如何在elasticsearch中为我的日志创建'documents','fields' .

我读到elasticsearch是基于REST的搜索引擎 . 所以,如果有任何REST API我可以用来分析我在elasticsearch中的数据 .

1 回答

  • 3

    确实 .

    curl localhost:9200/tomcat-log/_search
    

    将返回前10个文档,但也会返回索引中的文档总数 .

    curl localhost:9200/tomcat-log/_search -d '{
      "query": {
        "match": {
          "level" : "error"
        }
      }
    }'
    

    可能会给你tomcat-log中的所有文档,它们的级别等于错误 .

    看看book的这一部分 . 我会帮你的 .

相关问题