slowlog.asciidoc 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. [[index-modules-slowlog]]
  2. == Slow Log
  3. [float]
  4. [[search-slow-log]]
  5. === Search Slow Log
  6. Shard level slow search log allows to log slow search (query and fetch
  7. phases) into a dedicated log file.
  8. Thresholds can be set for both the query phase of the execution, and
  9. fetch phase, here is a sample:
  10. [source,yaml]
  11. --------------------------------------------------
  12. index.search.slowlog.threshold.query.warn: 10s
  13. index.search.slowlog.threshold.query.info: 5s
  14. index.search.slowlog.threshold.query.debug: 2s
  15. index.search.slowlog.threshold.query.trace: 500ms
  16. index.search.slowlog.threshold.fetch.warn: 1s
  17. index.search.slowlog.threshold.fetch.info: 800ms
  18. index.search.slowlog.threshold.fetch.debug: 500ms
  19. index.search.slowlog.threshold.fetch.trace: 200ms
  20. --------------------------------------------------
  21. All of the above settings are _dynamic_ and are set per-index.
  22. By default, none are enabled (set to `-1`). Levels (`warn`, `info`,
  23. `debug`, `trace`) allow to control under which logging level the log
  24. will be logged. Not all are required to be configured (for example, only
  25. `warn` threshold can be set). The benefit of several levels is the
  26. ability to quickly "grep" for specific thresholds breached.
  27. The logging is done on the shard level scope, meaning the execution of a
  28. search request within a specific shard. It does not encompass the whole
  29. search request, which can be broadcast to several shards in order to
  30. execute. Some of the benefits of shard level logging is the association
  31. of the actual execution on the specific machine, compared with request
  32. level.
  33. The logging file is configured by default using the following
  34. configuration (found in `log4j2.properties`):
  35. [source,properties]
  36. --------------------------------------------------
  37. appender.index_search_slowlog_rolling.type = RollingFile
  38. appender.index_search_slowlog_rolling.name = index_search_slowlog_rolling
  39. appender.index_search_slowlog_rolling.fileName = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}_index_search_slowlog.log
  40. appender.index_search_slowlog_rolling.layout.type = PatternLayout
  41. appender.index_search_slowlog_rolling.layout.pattern = [%d{ISO8601}][%-5p][%-25c] %marker%.-10000m%n
  42. appender.index_search_slowlog_rolling.filePattern = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}_index_search_slowlog-%i.log.gz
  43. appender.index_search_slowlog_rolling.policies.type = Policies
  44. appender.index_search_slowlog_rolling.policies.size.type = SizeBasedTriggeringPolicy
  45. appender.index_search_slowlog_rolling.policies.size.size = 1GB
  46. appender.index_search_slowlog_rolling.strategy.type = DefaultRolloverStrategy
  47. appender.index_search_slowlog_rolling.strategy.max = 4
  48. logger.index_search_slowlog_rolling.name = index.search.slowlog
  49. logger.index_search_slowlog_rolling.level = trace
  50. logger.index_search_slowlog_rolling.appenderRef.index_search_slowlog_rolling.ref = index_search_slowlog_rolling
  51. logger.index_search_slowlog_rolling.additivity = false
  52. --------------------------------------------------
  53. [float]
  54. [[index-slow-log]]
  55. === Index Slow log
  56. The indexing slow log, similar in functionality to the search slow
  57. log. The log file name ends with `_index_indexing_slowlog.log`. Log and
  58. the thresholds are configured in the same way as the search slowlog.
  59. Index slowlog sample:
  60. [source,yaml]
  61. --------------------------------------------------
  62. index.indexing.slowlog.threshold.index.warn: 10s
  63. index.indexing.slowlog.threshold.index.info: 5s
  64. index.indexing.slowlog.threshold.index.debug: 2s
  65. index.indexing.slowlog.threshold.index.trace: 500ms
  66. index.indexing.slowlog.level: info
  67. index.indexing.slowlog.source: 1000
  68. --------------------------------------------------
  69. All of the above settings are _dynamic_ and are set per-index.
  70. By default Elasticsearch will log the first 1000 characters of the _source in
  71. the slowlog. You can change that with `index.indexing.slowlog.source`. Setting
  72. it to `false` or `0` will skip logging the source entirely an setting it to
  73. `true` will log the entire source regardless of size. The original `_source` is
  74. reformatted by default to make sure that it fits on a single log line. If preserving
  75. the original document format is important, you can turn off reformatting by setting
  76. `index.indexing.slowlog.reformat` to `false`, which will cause the source to be
  77. logged "as is" and can potentially span multiple log lines.
  78. The index slow log file is configured by default in the `log4j2.properties`
  79. file:
  80. [source,properties]
  81. --------------------------------------------------
  82. appender.index_indexing_slowlog_rolling.type = RollingFile
  83. appender.index_indexing_slowlog_rolling.name = index_indexing_slowlog_rolling
  84. appender.index_indexing_slowlog_rolling.fileName = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}_index_indexing_slowlog.log
  85. appender.index_indexing_slowlog_rolling.layout.type = PatternLayout
  86. appender.index_indexing_slowlog_rolling.layout.pattern = [%d{ISO8601}][%-5p][%-25c] %marker%.-10000m%n
  87. appender.index_indexing_slowlog_rolling.filePattern = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}_index_indexing_slowlog-%i.log.gz
  88. appender.index_indexing_slowlog_rolling.policies.type = Policies
  89. appender.index_indexing_slowlog_rolling.policies.size.type = SizeBasedTriggeringPolicy
  90. appender.index_indexing_slowlog_rolling.policies.size.size = 1GB
  91. appender.index_indexing_slowlog_rolling.strategy.type = DefaultRolloverStrategy
  92. appender.index_indexing_slowlog_rolling.strategy.max = 4
  93. logger.index_indexing_slowlog.name = index.indexing.slowlog.index
  94. logger.index_indexing_slowlog.level = trace
  95. logger.index_indexing_slowlog.appenderRef.index_indexing_slowlog_rolling.ref = index_indexing_slowlog_rolling
  96. logger.index_indexing_slowlog.additivity = false
  97. --------------------------------------------------