elasticsearch - 如何记录所有对 ElasticSearch 的请求?

标签 elasticsearch logging elasticsearch-5 elasticsearch-2.0

我在调试应用程序时遇到问题, 所以我想记录发送到 Elasticsearch 的所有请求。

我了解到可以通过 Slowlog 将时间设置为0s来实现此目的。

我在 ES 2.4.2ES 5.6.4 中都尝试过此操作,但没有记录任何请求。

ES 2.4.2中,我在logging.yml中设置:

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

ES 5.6.4中,我还将级别更改为INFO(在log4j2.properties中):

logger.index_search_slowlog_rolling.level = info
logger.index_indexing_slowlog.level = info

然后我启动 ES 并发出:

curl -XPUT 'http://localhost:9200/com.example.app.model.journal/_settings' -d '
{
    "index.search.slowlog.threshold.query.info" : "0s", 
    "index.search.slowlog.threshold.fetch.info": "0s", 
    "index.indexing.slowlog.threshold.index.info": "0s" 
}
'

(我更愿意为配置中的所有索引设置此设置 文件,可能吗?)

然后我搜索了一些数据(并得到了结果):

curl -XGET 'localhost:9200/com.example.app.model.journal/_search?pretty' -d '
{
    "query":
    {
        "match" : { "rank" : "2" } }
    }
}'

此请求未记录,在 ES 2.4.2 中创建了 Slowlog 文件 并且为空,在 ES 5.6.4 中不会创建文件。我做错了什么?

最佳答案

我找不到解决方案,因此我使用 mitmdump 作为解决方法。运行代理:

 mitmdump -v -dddd -R http://localhost:9200

将ES地址替换为代理地址:

curl -XGET 'localhost:8080/com.example.app.model.journal/_search?pretty' -d '
{
    ...   

关于elasticsearch - 如何记录所有对 ElasticSearch 的请求?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47635187/

相关文章:

ubuntu - 无法在 Elasticsearch 中创建映射

elasticsearch - 如何根据ElasticSearch字段中子字符串出现的次数进行评分

Elasticsearch Jest 更新整个文档

Elasticsearch 5 - 文本/关键字字段中不区分大小写的精确匹配

elasticsearch - ElasticSearch查询模板/功能

amazon-web-services - AWS 上的 Elasticsearch : How to fix unassigned shards?

oracle - 更新Elasticsearch中关于向我的数据库添加新文档的索引

facebook - 我可以在用户登录时始终在 Facebook 应用程序中显示权限对话框吗?

java - 文件读/写与数据库读/写

Laravel 自定义日志格式化程序