configuring-filebeat.asciidoc 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. [role="xpack"]
  2. [[configuring-filebeat]]
  3. == Collecting {es} log data with {filebeat}
  4. [subs="attributes"]
  5. ++++
  6. <titleabbrev>Collecting log data with {filebeat}</titleabbrev>
  7. ++++
  8. You can use {filebeat} to monitor the {es} log files, collect log events, and
  9. ship them to the monitoring cluster. Your recent logs are visible on the
  10. *Monitoring* page in {kib}.
  11. //NOTE: The tagged regions are re-used in the Stack Overview.
  12. . Verify that {es} is running and that the monitoring cluster is ready to
  13. receive data from {filebeat}.
  14. +
  15. --
  16. TIP: In production environments, we strongly recommend using a separate cluster
  17. (referred to as the _monitoring cluster_) to store the data. Using a separate
  18. monitoring cluster prevents production cluster outages from impacting your
  19. ability to access your monitoring data. It also prevents monitoring activities
  20. from impacting the performance of your production cluster. See
  21. <<monitoring-production>>.
  22. --
  23. . Identify which logs you want to monitor.
  24. +
  25. --
  26. The {filebeat} {es} module can handle
  27. <<audit-log-output,audit logs>>,
  28. <<deprecation-logging,deprecation logs>>,
  29. <<gc-logging,gc logs>>, <<logging,server logs>>, and
  30. <<index-modules-slowlog,slow logs>>.
  31. For more information about the location of your {es} logs, see the
  32. <<path-settings,path.logs>> setting.
  33. IMPORTANT: If there are both structured (`*.json`) and unstructured (plain text)
  34. versions of the logs, you must use the structured logs. Otherwise, they might
  35. not appear in the appropriate context in {kib}.
  36. --
  37. . {filebeat-ref}/filebeat-installation-configuration.html[Install {filebeat}] on the {es}
  38. nodes that contain logs that you want to monitor.
  39. . Identify where to send the log data.
  40. +
  41. --
  42. // tag::output-elasticsearch[]
  43. For example, specify {es} output information for your monitoring cluster in
  44. the {filebeat} configuration file (`filebeat.yml`):
  45. [source,yaml]
  46. ----------------------------------
  47. output.elasticsearch:
  48. # Array of hosts to connect to.
  49. hosts: ["http://es-mon-1:9200", "http://es-mon-2:9200"] <1>
  50. # Optional protocol and basic auth credentials.
  51. #protocol: "https"
  52. #username: "elastic"
  53. #password: "changeme"
  54. ----------------------------------
  55. <1> In this example, the data is stored on a monitoring cluster with nodes
  56. `es-mon-1` and `es-mon-2`.
  57. If you configured the monitoring cluster to use encrypted communications, you
  58. must access it via HTTPS. For example, use a `hosts` setting like
  59. `https://es-mon-1:9200`.
  60. IMPORTANT: The {es} {monitor-features} use ingest pipelines, therefore the
  61. cluster that stores the monitoring data must have at least one
  62. <<ingest,ingest node>>.
  63. If {es} {security-features} are enabled on the monitoring cluster, you must
  64. provide a valid user ID and password so that {filebeat} can send metrics
  65. successfully.
  66. For more information about these configuration options, see
  67. {filebeat-ref}/elasticsearch-output.html[Configure the {es} output].
  68. // end::output-elasticsearch[]
  69. --
  70. . Optional: Identify where to visualize the data.
  71. +
  72. --
  73. // tag::setup-kibana[]
  74. {filebeat} provides example {kib} dashboards, visualizations and searches. To
  75. load the dashboards into the appropriate {kib} instance, specify the
  76. `setup.kibana` information in the {filebeat} configuration file
  77. (`filebeat.yml`) on each node:
  78. [source,yaml]
  79. ----------------------------------
  80. setup.kibana:
  81. host: "localhost:5601"
  82. #username: "my_kibana_user"
  83. #password: "YOUR_PASSWORD"
  84. ----------------------------------
  85. TIP: In production environments, we strongly recommend using a dedicated {kib}
  86. instance for your monitoring cluster.
  87. If {security-features} are enabled, you must provide a valid user ID and
  88. password so that {filebeat} can connect to {kib}:
  89. .. Create a user on the monitoring cluster that has the
  90. <<built-in-roles,`kibana_admin` built-in role>> or equivalent
  91. privileges.
  92. .. Add the `username` and `password` settings to the {es} output information in
  93. the {filebeat} configuration file. The example shows a hard-coded password, but
  94. you should store sensitive values in the
  95. {filebeat-ref}/keystore.html[secrets keystore].
  96. See {filebeat-ref}/setup-kibana-endpoint.html[Configure the {kib} endpoint].
  97. // end::setup-kibana[]
  98. --
  99. . Enable the {es} module and set up the initial {filebeat} environment on each
  100. node.
  101. +
  102. --
  103. // tag::enable-es-module[]
  104. For example:
  105. ["source","sh",subs="attributes,callouts"]
  106. ----------------------------------------------------------------------
  107. filebeat modules enable elasticsearch
  108. filebeat setup -e
  109. ----------------------------------------------------------------------
  110. For more information, see
  111. {filebeat-ref}/filebeat-module-elasticsearch.html[{es} module].
  112. // end::enable-es-module[]
  113. --
  114. . Configure the {es} module in {filebeat} on each node.
  115. +
  116. --
  117. // tag::configure-es-module[]
  118. If the logs that you want to monitor aren't in the default location, set the
  119. appropriate path variables in the `modules.d/elasticsearch.yml` file. See
  120. {filebeat-ref}/filebeat-module-elasticsearch.html#configuring-elasticsearch-module[Configure the {es} module].
  121. IMPORTANT: If there are JSON logs, configure the `var.paths` settings to point
  122. to them instead of the plain text logs.
  123. // end::configure-es-module[]
  124. --
  125. . {filebeat-ref}/filebeat-starting.html[Start {filebeat}] on each node.
  126. +
  127. --
  128. NOTE: Depending on how you’ve installed {filebeat}, you might see errors related
  129. to file ownership or permissions when you try to run {filebeat} modules. See
  130. {beats-ref}/config-file-permissions.html[Config file ownership and permissions].
  131. --
  132. . Check whether the appropriate indices exist on the monitoring cluster.
  133. +
  134. --
  135. For example, use the <<cat-indices,cat indices>> command to verify
  136. that there are new `filebeat-*` indices.
  137. TIP: If you want to use the *Monitoring* UI in {kib}, there must also be
  138. `.monitoring-*` indices. Those indices are generated when you collect metrics
  139. about {stack} products. For example, see <<configuring-metricbeat>>.
  140. --
  141. . {kibana-ref}/monitoring-data.html[View the monitoring data in {kib}].