启用搜索和索引慢日志(按索引设置阈值)
Elasticsearch性能命令
PUT musteri/_settings
{
"index.search.slowlog.threshold.query.warn": "2s",
"index.search.slowlog.threshold.query.info": "500ms",
"index.search.slowlog.threshold.fetch.warn": "1s",
"index.indexing.slowlog.threshold.index.warn": "1s",
"index.indexing.slowlog.source": "200"
}
GET musteri/_settings/index.*slowlog*?flat_settings=true
# Set thresholds to null to turn it off:
PUT musteri/_settings
{
"index.search.slowlog.threshold.query.warn": null,
"index.search.slowlog.threshold.query.info": null,
"index.search.slowlog.threshold.fetch.warn": null,
"index.indexing.slowlog.threshold.index.warn": null,
"index.indexing.slowlog.source": null
}作用
针对给定索引,将 query 和 fetch 阶段以及索引操作中超过阈值的请求连同查询体写入慢日志。
适用场景
用于找出导致搜索变慢的查询,或捕获来自特定仪表板或客户端的重型查询。
注意
阈值按分片计量:在分片很多的索引上,每个分片都可能写自己的一行。阈值过低(0ms)会显著增加日志量和 IO;诊断后用 null 关闭。indexing.slowlog.source 会把文档 source 写入日志;若包含敏感数据请设为 false。该设置只作用于给定索引;新索引请将其加入模板。