This role:
- installs filebeat on Ubuntu, CentOS, Windows
- copies prepared configuration file (log path, connect to elasticsearch etc.)
- Prepare server (add elastic repo)
- [Optional] Create folder(s) for custom paths
- Install filebeat
- Copy configuration file
- Minimal Version of the ansible for installation: 2.5
- Supported OS:
- CentOS
- 6, 7
- Ubuntu
- 16.04, 18.04
- Debian
- 8, 9
- Windows
- CentOS
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
-
filebeat_outputIs used to configure what output to use when sending data (elasticsearchorlogstash). Default value iselasticsearch -
elasticsearch.hostArray of hosts to connect to. Default value islocalhost -
elasticsearch.portValue for setting custom port. Default value is9200 -
logstash.hostArray of hosts to connect to. Default value islocalhost -
logstash.portValue for setting custom port. Default value is5044
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 service -
filebeat_bulk_max_sizeMaximum number of events to bulk in a single Logstash request. Default value is500 -
filebeat_workerNumber of workers per Elasticsearch host. Default value is1 -
filebeat_logging_to_syslogSend all logging output to syslog. Default value isfalse -
filebeat_logging_to_filesSend all logging output to rotating files. Default value istrue -
filebeat_rotateeverybytesDefines log file size limit. Defalt value is104857600=100MB -
filebeat_keepfilesNumber of log files to keep. Default value is30 -
filebeat_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 is15s -
filebeat_harvester_buffer_sizeDefines the buffer size. Default value is65535 -
filebeat_lognameName of the logging files. Default value is"filebeat.log"
ca-cert (only for installation with SSL)
- name: Install filebeat
hosts: all
roles:
- role: ansible-role-filebeat- name: Install filebeat
hosts: all
roles:
- role: ansible-role-filebeat
vars:
input_logpath: "/var/log/messages"
elasticsearch:
host: elasticsearch.example.com
port: 9200Apache
authors:
- Lean Delivery Team team@lean-delivery.com