configuring-filebeat.asciidoc 6.0 KB

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