configuring-filebeat.asciidoc 6.1 KB

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