| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187 | [role="xpack"][testenv="basic"][[configuring-filebeat]]=== Collecting {es} log data with {filebeat}[subs="attributes"]++++<titleabbrev>Collecting log data with {filebeat}</titleabbrev>++++You can use {filebeat} to monitor the {es} log files, collect log events, andship them to the monitoring cluster. Your recent logs are visible on the*Monitoring* page in {kib}.//NOTE: The tagged regions are re-used in the Stack Overview.. Verify that {es} is running and that the monitoring cluster is ready toreceive data from {filebeat}.+--TIP: In production environments, we strongly recommend using a separate cluster (referred to as the _monitoring cluster_) to store the data. Using a separate monitoring cluster prevents production cluster outages from impacting your ability to access your monitoring data. It also prevents monitoring activities from impacting the performance of your production cluster. See{stack-ov}/monitoring-production.html[Monitoring in a production environment].--. Enable the collection of monitoring data on your cluster.+--include::configuring-metricbeat.asciidoc[tag=enable-collection]For more information, see <<monitoring-settings>> and <<cluster-update-settings>>.--. Identify which logs you want to monitor. +--The {filebeat} {es} module can handle{stack-ov}/audit-log-output.html[audit logs],{ref}/logging.html#deprecation-logging[deprecation logs],{ref}/gc-logging.html[gc logs], {ref}/logging.html[server logs], and {ref}/index-modules-slowlog.html[slow logs].For more information about the location of your {es} logs, see the{ref}/path-settings.html[path.logs] setting.IMPORTANT: If there are both structured (`*.json`) and unstructured (plain text)versions of the logs, you must use the structured logs. Otherwise, they mightnot appear in the appropriate context in {kib}.--. {filebeat-ref}/filebeat-installation.html[Install {filebeat}] on the {es}nodes that contain logs that you want to monitor.. Identify where to send the log data.+--// tag::output-elasticsearch[]For example, specify {es} output information for your monitoring cluster inthe {filebeat} configuration file (`filebeat.yml`):[source,yaml]----------------------------------output.elasticsearch:  # Array of hosts to connect to.  hosts: ["http://es-mon-1:9200", "http://es-mon2:9200"] <1>  # Optional protocol and basic auth credentials.  #protocol: "https"  #username: "elastic"  #password: "changeme"----------------------------------<1> In this example, the data is stored on a monitoring cluster with nodes `es-mon-1` and `es-mon-2`. If you configured the monitoring cluster to use encrypted communications, youmust access it via HTTPS. For example, use a `hosts` setting like`https://es-mon-1:9200`.IMPORTANT: The {es} {monitor-features} use ingest pipelines, therefore thecluster that stores the monitoring data must have at least one <<ingest,ingest node>>. If {es} {security-features} are enabled on the monitoring cluster, you mustprovide a valid user ID and password so that {filebeat} can send metrics successfully. For more information about these configuration options, see {filebeat-ref}/elasticsearch-output.html[Configure the {es} output].// end::output-elasticsearch[]--. Optional: Identify where to visualize the data.+--// tag::setup-kibana[]{filebeat} provides example {kib} dashboards, visualizations and searches. Toload the dashboards into the appropriate {kib} instance, specify the`setup.kibana` information in the {filebeat} configuration file(`filebeat.yml`) on each node:[source,yaml]----------------------------------setup.kibana:  host: "localhost:5601"  #username: "my_kibana_user"  #password: "YOUR_PASSWORD"----------------------------------TIP: In production environments, we strongly recommend using a dedicated {kib} instance for your monitoring cluster.If {security-features} are enabled, you must provide a valid user ID andpassword so that {filebeat} can connect to {kib}: .. Create a user on the monitoring cluster that has the {stack-ov}/built-in-roles.html[`kibana_user` built-in role] or equivalentprivileges... Add the `username` and `password` settings to the {es} output information in the {filebeat} configuration file. The example shows a hard-coded password, butyou should store sensitive values in the{filebeat-ref}/keystore.html[secrets keystore].See {filebeat-ref}/setup-kibana-endpoint.html[Configure the {kib} endpoint].// end::setup-kibana[]--. Enable the {es} module and set up the initial {filebeat} environment on eachnode.+--// tag::enable-es-module[]For example:["source","sh",subs="attributes,callouts"]----------------------------------------------------------------------filebeat modules enable elasticsearchfilebeat setup -e----------------------------------------------------------------------For more information, see  {filebeat-ref}/filebeat-module-elasticsearch.html[{es} module]. // end::enable-es-module[]--. Configure the {es} module in {filebeat} on each node.+--// tag::configure-es-module[]If the logs that you want to monitor aren't in the default location, set theappropriate path variables in the `modules.d/elasticsearch.yml` file. See{filebeat-ref}/filebeat-module-elasticsearch.html#configuring-elasticsearch-module[Configure the {es} module].IMPORTANT: If there are JSON logs, configure the `var.paths` settings to pointto them instead of the plain text logs.// end::configure-es-module[]--. {filebeat-ref}/filebeat-starting.html[Start {filebeat}] on each node. +--NOTE: Depending on how you’ve installed {filebeat}, you might see errors relatedto file ownership or permissions when you try to run {filebeat} modules. See{beats-ref}/config-file-permissions.html[Config file ownership and permissions].--. Check whether the appropriate indices exist on the monitoring cluster.+--For example, use the {ref}/cat-indices.html[cat indices] command to verifythat there are new `filebeat-*` indices. TIP: If you want to use the *Monitoring* UI in {kib}, there must also be `.monitoring-*` indices. Those indices are generated when you collect metricsabout {stack} products. For example, see <<configuring-metricbeat>>.--. {kibana-ref}/monitoring-data.html[View the monitoring data in {kib}].
 |