mircomasa.filebeat
Filebeat Role
Summary
This role:
- installs filebeat on Ubuntu, CentOS, Windows
- copies prepared configuration file (log path, connect to elasticsearch etc.)
Role tasks
- Prepare server (add elastic repo)
- [Optional] Create folder(s) for custom paths
- Install filebeat
- Copy configuration file
Requirements
- Minimal Version of the ansible for installation: 2.5
- Supported OS:
- CentOS
- 6, 7
- Ubuntu
- 16.04, 18.04
- Debian
- 8, 9
- Windows
- CentOS
Role Variables
You can override any variable below by setting "variable: value" in playbook.
filebeat_versionIs used to select main Filebeat branch to be installed (5.x or 6.x current stable versions). Default value is6.filebeat_last_versionIs used to select specific Filebeat version to be installed. Default value is6.6.0elastic_gpg_keyGPG-key from elasticsearch repository. Default value ishttps://artifacts.elastic.co/GPG-KEY-elasticsearchfilebeat_node_nameName of the filebeat node. Default value is{{ inventory_hostname }}. If this options is not defined, the hostname is used.filebeat_ssl_enabledTurns on/off SSL connection between filebeat and logstash/elasticsearch. SSL options should be set by corresponding dict fields like shown below:
ssl:
key: "/etc/pki/tls/private/server.key"
certificate: "/etc/pki/tls/certs/server.crt"
certificate_authorities: "/etc/pki/CA/ca-root.pem"
in case of Windows setup:
ssl:
key: 'c:\tls\private\server.key'
certificate: 'c:\tls\certs\server.pem'
certificate_authorities: 'c:\CA\ca-root.pem'
The path section of the configuration options defines where Filebeat looks for its files. For example, Filebeat looks for the Elasticsearch template file in the configuration path and writes log files in the logs path. Filebeat looks for its registry files in the data path. Default values for Linux host are set up this way:
path:
home: /usr/share/filebeat
config: /etc/filebeat
data: /var/lib/filebeat
logs: /var/log/filebeat
in case of Windows setup default paths look like:
path:
home: 'c:\program files\filebeat'
config: 'c:\program files\filebeat'
data: 'c:\programdata\filebeat'
logs: 'c:\programdata\filebeat\logs'
win_download_pathTemp directory for Windows to download and upzip Filebeat package. Default value is'{{ ansible_env.TEMP }}/filebeat'(ansible_env.TEMP value solves idempotence issue)input_logpathPath to log files.
Default value for *NIX OS family is "/var/log/*.log"
Default value for WIN OS family is 'c:\windows\*.log'
Variable filebeat_inputs defines type of logs that will be processed by pipeline, their log paths and Elasticsearch index that should store this type of logs.
You can specify several inputs with various paths, logtypes and index names using yaml format like in example below:
filebeat_inputs:
- name: hybris
paths:
- '/var/log/console*.log'
fields:
logtype: hybris
index_name: hybris-console
- name: access
paths:
- '/var/log/access*.log'
- '/var/log/nginx_access*.log'
fields:
logtype: access
index_name: nginx-access
Output customization:
filebeat_outputIs used to configure what output to use when sending data (elasticsearchorlogstash). Default value iselasticsearchfilebeat_elasticsearch_output.hostsArray of hosts to connect to. Default value islocalhostfilebeat_elasticsearch_output.portValue for setting custom port. Default value is9200filebeat_logstash_outputsArray of hosts and ports to connect to. Default value islocalhost:5044
Advanced config parameters:
The filebeat(systemd)\initd section of the configuration options defines which init script will be used to manage filebeat service depending on the *nix OS. Custom paths will be taken into account (if configured).
filebeat_service_nameName of nssm\init script, which manages filebeat servicefilebeat_bulk_max_sizeMaximum number of events to bulk in a single Logstash request. Default value is500filebeat_workerNumber of workers per Elasticsearch host. Default value is1filebeat_logging_to_syslogSend all logging output to syslog. Default value isfalsefilebeat_logging_to_filesSend all logging output to rotating files. Default value istruefilebeat_rotateeverybytesDefines log file size limit. Defalt value is104857600=100MBfilebeat_keepfilesNumber of log files to keep. Default value is30filebeat_ignore_olderValue (any time strings like 2h, 5m can be used) above which files will be ignored. Default value is0(disabled)filebeat_scan_frequencyDefines how often filebeat checks file updates. Default value is15sfilebeat_harvester_buffer_sizeDefines the buffer size. Default value is65535filebeat_lognameName of the logging files. Default value is"filebeat.log"
Dependencies
ca-cert (only for installation with SSL)
Example Playbook
Installing Filebeat 6.x version:
- name: Install filebeat
hosts: all
roles:
- role: ansible-role-filebeat
Installing Filebeat 6.x version with custom path to log files and elasticsearch output:
- name: Install filebeat
hosts: all
roles:
- role: ansible-role-filebeat
vars:
input_logpath: "/var/log/messages"
filebeat_elasticsearch_output:
hosts:
- elasticsearch.example.com
port: 9200
License
Apache
Author Information
authors:
- Lean Delivery Team team@lean-delivery.com
ansible-galaxy install mircomasa.filebeat