tracers.asciidoc 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. ==== Request tracing
  2. You can trace individual requests made on the HTTP and transport layers.
  3. WARNING: Tracing can generate extremely high log volumes that can destabilize
  4. your cluster. Do not enable request tracing on busy or important clusters.
  5. [[http-rest-request-tracer]]
  6. ===== REST request tracer
  7. The HTTP layer has a dedicated tracer that logs incoming requests and the
  8. corresponding outgoing responses. Activate the tracer by setting the level of
  9. the `org.elasticsearch.http.HttpTracer` logger to `TRACE`:
  10. [source,console]
  11. --------------------------------------------------
  12. PUT _cluster/settings
  13. {
  14. "persistent" : {
  15. "logger.org.elasticsearch.http.HttpTracer" : "TRACE"
  16. }
  17. }
  18. --------------------------------------------------
  19. You can also control which URIs will be traced, using a set of include and
  20. exclude wildcard patterns. By default every request will be traced.
  21. [source,console]
  22. --------------------------------------------------
  23. PUT _cluster/settings
  24. {
  25. "persistent" : {
  26. "http.tracer.include" : "*",
  27. "http.tracer.exclude" : ""
  28. }
  29. }
  30. --------------------------------------------------
  31. By default, the tracer logs a summary of each request and response which
  32. matches these filters. To record the body of each request and response too, set
  33. the system property `es.insecure_network_trace_enabled` to `true`, and then set
  34. the levels of both the `org.elasticsearch.http.HttpTracer` and
  35. `org.elasticsearch.http.HttpBodyTracer` loggers to `TRACE`:
  36. [source,console]
  37. --------------------------------------------------
  38. PUT _cluster/settings
  39. {
  40. "persistent" : {
  41. "logger.org.elasticsearch.http.HttpTracer" : "TRACE",
  42. "logger.org.elasticsearch.http.HttpBodyTracer" : "TRACE"
  43. }
  44. }
  45. --------------------------------------------------
  46. Each message body is compressed, encoded, and split into chunks to avoid
  47. truncation:
  48. [source,text]
  49. ----
  50. [TRACE][o.e.h.HttpBodyTracer ] [master] [276] response body [part 1]: H4sIAAAAAAAA/9...
  51. [TRACE][o.e.h.HttpBodyTracer ] [master] [276] response body [part 2]: 2oJ93QyYLWWhcD...
  52. [TRACE][o.e.h.HttpBodyTracer ] [master] [276] response body (gzip compressed, base64-encoded, and split into 2 parts on preceding log lines)
  53. ----
  54. Each chunk is annotated with an internal request ID (`[276]` in this example)
  55. which you should use to correlate the chunks with the corresponding summary
  56. lines. To reconstruct the output, base64-decode the data and decompress it
  57. using `gzip`. For instance, on Unix-like systems:
  58. [source,sh]
  59. ----
  60. cat httptrace.log | sed -e 's/.*://' | base64 --decode | gzip --decompress
  61. ----
  62. WARNING: HTTP request and response bodies may contain sensitive information
  63. such as credentials and keys, so HTTP body tracing is disabled by default. You
  64. must explicitly enable it on each node by setting the system property
  65. `es.insecure_network_trace_enabled` to `true`. This feature is primarily
  66. intended for test systems which do not contain any sensitive information. If
  67. you set this property on a system which contains sensitive information, you
  68. must protect your logs from unauthorized access.
  69. [[transport-tracer]]
  70. ===== Transport tracer
  71. The transport layer has a dedicated tracer that logs incoming and outgoing
  72. requests and responses. Activate the tracer by setting the level of the
  73. `org.elasticsearch.transport.TransportService.tracer` logger to `TRACE`:
  74. [source,console]
  75. --------------------------------------------------
  76. PUT _cluster/settings
  77. {
  78. "persistent" : {
  79. "logger.org.elasticsearch.transport.TransportService.tracer" : "TRACE"
  80. }
  81. }
  82. --------------------------------------------------
  83. You can also control which actions will be traced, using a set of include and
  84. exclude wildcard patterns. By default every request will be traced except for
  85. fault detection pings:
  86. [source,console]
  87. --------------------------------------------------
  88. PUT _cluster/settings
  89. {
  90. "persistent" : {
  91. "transport.tracer.include" : "*",
  92. "transport.tracer.exclude" : "internal:coordination/fault_detection/*"
  93. }
  94. }
  95. --------------------------------------------------