记录Elasticsearch请求的日志

21
如何记录访问 Elasticsearch 的请求?
我在 elasticsearch/bin/service/elasticsearch.conf 中进行了设置:
wrapper.logfile=/var/log/elasticsearch/debug.log

# Log Level for log file output.  (See docs for log levels)
wrapper.logfile.loglevel=DEBUG

但是日志文件只显示:

STATUS | wrapper  | 2012/12/11 13:00:00 | TERM trapped.  Shutting down.
STATUS | wrapper  | 2012/12/11 13:00:02 | <-- Wrapper Stopped
STATUS | wrapper  | 2012/12/11 13:00:05 | --> Wrapper Started as Daemon
STATUS | wrapper  | 2012/12/11 13:00:05 | Java Service Wrapper Community Edition 64-bit 3.5.6
STATUS | wrapper  | 2012/12/11 13:00:05 |   Copyright (C) 1999-2010 Tanuki Software, Ltd. All Rights Reserved.
STATUS | wrapper  | 2012/12/11 13:00:05 |     http://wrapper.tanukisoftware.com
STATUS | wrapper  | 2012/12/11 13:00:05 | 
WARN   | wrapper  | 2012/12/11 13:00:05 | The value of wrapper.java.command does not appear to be a java binary.
WARN   | wrapper  | 2012/12/11 13:00:05 | The use of scripts is not supported. Trying to continue, but some features may not work correctly..
STATUS | wrapper  | 2012/12/11 13:00:05 | Launching a JVM...
INFO   | jvm 1    | 2012/12/11 13:00:05 | WrapperManager: Initializing...

没有关于我的请求的信息...

我使用elasticsearch 0.17.6


你能找到一个令人满意的答案吗? - Shrey
imotov的回答对我的需求来说已经足够令人满意了。 - czerasz
通过更改慢查询阈值? - Shrey
1
是的,通过将它们更改为0(我不确定,这是很久以前的事情,但基本上是一个非常低的值)。您还可以在Elasticsearch前面放置代理,该代理能够记录请求。 - czerasz
我知道如何更改阈值。想知道自从你发布这个问题以来是否引入了任何新的配置或日志参数(ES版本从0.17.6到现在的1.3.4)。谢谢。 - Shrey
3个回答

13
在elasticsearch 0.17.6中,没有可用的请求日志记录设施。版本0.18.3及以上版本支持慢速搜索操作日志记录,可以配置阈值为0ms,以记录所有分片的所有搜索请求。在版本0.19.12中,此功能还扩展到索引查询

如果您想要记录所有HTTP请求,elasticsearch-jetty插件支持此功能,并适用于elasticsearch 0.18.4及以上版本。

Elasticsearch 1.1.1与最近的jetty实现不兼容。https://groups.google.com/forum/#!topic/elasticsearch-jetty/m-5XETJEuKo 有什么想法? - Gizzmo

4
在Elasticsearch 5.x及以上版本中,首选配置日志的方法是使用API:
## Elasticsearch slow log
curl -X "PUT" "http://localhost:9200/test_resumes/_settings?preserve_existing=true" \
     -H 'Content-Type: application/json; charset=utf-8' \
     -d $'{
  "index": {
    "search.slowlog.threshold.query.trace": "0ms",
    "search.slowlog.threshold.fetch.trace": "0ms",
    "search.slowlog.level": "trace"
  }
}'

在ES 8中(可能也适用于早期版本),设置“search.slowlog.level”不再存在。现在有单独的条目分别为“search.slowlog.threshold.query.warn”,“search.slowlog.threshold.query.info”,“...debug”和“...trace”。还有“index.search.slowlog.threshold.fetch.warn”,“index.search.slowlog.threshold.fetch.info”,“...debug”和“...trace”。文档 - huha

4
在1.7.3版本中,需要修改配置文件config/elasticsearch.yml。
index.search.slowlog.threshold.query.debug: 0s
index.search.slowlog.threshold.fetch.debug: 0s
index.indexing.slowlog.threshold.index.debug: 0s

并且

config/logging.yml

  index.search.slowlog: DEBUG, index_search_slow_log_file
  index.indexing.slowlog: DEBUG, index_indexing_slow_log_file

additivity:
  index.search.slowlog: true
  index.indexing.slowlog: true

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接