瀏覽代碼

Example of how to set slow logs dynamically per-index (#42384)

* Example of how to set slow logs dynamically per-index

* Make _settings API example more explicit

Co-Authored-By: James Rodewig <james.rodewig@elastic.co>

* Add TEST directive to fix CI

Co-Authored-By: James Rodewig <james.rodewig@elastic.co>
Luiz Guilherme Pais dos Santos 6 年之前
父節點
當前提交
4fcb951f21
共有 1 個文件被更改,包括 37 次插入2 次删除
  1. 37 2
      docs/reference/index-modules/slowlog.asciidoc

+ 37 - 2
docs/reference/index-modules/slowlog.asciidoc

@@ -26,7 +26,26 @@ index.search.slowlog.threshold.fetch.trace: 200ms
 index.search.slowlog.level: info
 --------------------------------------------------
 
-All of the above settings are _dynamic_ and are set per-index.
+All of the above settings are _dynamic_ and can be set for each index using the
+<<indices-update-settings, update indices settings>> API. For example: 
+
+[source,js]
+--------------------------------------------------
+PUT /twitter/_settings
+{
+    "index.search.slowlog.threshold.query.warn": "10s",
+    "index.search.slowlog.threshold.query.info": "5s",
+    "index.search.slowlog.threshold.query.debug": "2s",
+    "index.search.slowlog.threshold.query.trace": "500ms",
+    "index.search.slowlog.threshold.fetch.warn": "1s",
+    "index.search.slowlog.threshold.fetch.info": "800ms",
+    "index.search.slowlog.threshold.fetch.debug": "500ms",
+    "index.search.slowlog.threshold.fetch.trace": "200ms",
+    "index.search.slowlog.level": "info"
+}
+--------------------------------------------------
+// CONSOLE
+// TEST[setup:twitter]
 
 By default, none are enabled (set to `-1`). Levels (`warn`, `info`,
 `debug`, `trace`) allow to control under which logging level the log
@@ -83,7 +102,23 @@ index.indexing.slowlog.level: info
 index.indexing.slowlog.source: 1000
 --------------------------------------------------
 
-All of the above settings are _dynamic_ and are set per-index.
+All of the above settings are _dynamic_ and can be set for each index using the
+<<indices-update-settings, update indices settings>> API. For example: 
+
+[source,js]
+--------------------------------------------------
+PUT /twitter/_settings
+{
+    "index.indexing.slowlog.threshold.index.warn": "10s",
+    "index.indexing.slowlog.threshold.index.info": "5s",
+    "index.indexing.slowlog.threshold.index.debug": "2s",
+    "index.indexing.slowlog.threshold.index.trace": "500ms",
+    "index.indexing.slowlog.level": "info",
+    "index.indexing.slowlog.source": "1000"
+}
+--------------------------------------------------
+// CONSOLE
+// TEST[setup:twitter]
 
 By default Elasticsearch will log the first 1000 characters of the _source in
 the slowlog. You can change that with `index.indexing.slowlog.source`. Setting