将Elasticsearch慢日志设置恢复为默认值

时间:2019-01-11 11:03:56

标签: elasticsearch logging

我希望能够将一段时间的慢日志时间设置为0,然后将设置重置为默认值。 我用

curl -X PUT -H "Content-Type: application/json" -d '{"index.search.slowlog.threshold.query.warn": "0s"}' "<ADDRESS>:9200/index/_settings"

激活慢日志。会添加

"search": {
   "slowlog": {
      "threshold": {
         "query": {
           "warn": "0s"
         }
      }
   }
}

进入设置。我可以做

curl -X PUT -H "Content-Type: application/json" -d '{"index.search.slowlog.threshold.query.warn": "-1"}' "<ADDRESS>:9200/index/_settings"

禁用慢速日志,但这将新设置保留在原处,我希望这些设置恢复到干预之前的状态。

是否可以将设置恢复为默认值? (理想情况下,删除整个新块,使设置与以前完全一样。)

2 个答案:

答案 0 :(得分:1)

无法实现您想要的,相反,您可以查看https://www.elastic.co/guide/en/elasticsearch/reference/current/index-modules-slowlog.html并查看慢日志设置的默认值是什么,然后在要还原慢日志设置时,只需使用来更新日志设置默认值。

答案 1 :(得分:0)

您可以通过将 null 作为设置的值来重置为默认值。

curl -X PUT -H "Content-Type: application/json" \
  -d '{"index.search.slowlog.threshold.query.warn": null}' \
  "<ADDRESS>:9200/index/_settings"

用于通过 API 更新索引设置的 Elasticsearch 文档 https://www.elastic.co/guide/en/elasticsearch/reference/7.12/indices-update-settings.html#reset-index-setting

相关问题