configuring-filebeat.asciidoc 6.1 KB

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