Filebeat ile Log Shipping

Anil Ozturk
Devops Türkiye☁️ 🐧 🐳 ☸️
2 min readJul 12, 2019

Bu makalede daha önce server tarafını yazdığım Graylog tarafına clientlardan nasıl log forwarding yapacağımızdan bahsedeceğim.

Filebeat; clientlar üzerinde agent rolü ile loglarınızı forward etmenize yarayan bir yazılımdır, tek amacı loglarınızı hedeflediğiniz yere değişimsiz taşınmasıdır. Burda loglarınızı doğrudan hedef servera da gönderebilirsiniz arada logstash gibi bir yapı da kullanabilirsiniz. Benim tasarladığım mimari de loglarda bir işlem yapılmayacağı ve bulk olarak transfer edileceği için direkt hedef sunucuya gönderilecek.

Yeri gelmişken logstash; logların merkezi olarak toplanabilen, yapılan konfigürasyonlara göre logları işleyebilen filtreleyebilen bunlara ek olarak Elasticsearch’e bu logları indekslenmek üzere gönderen sistemdir. (bkz ELK Stack)

Not : Kurulumları Ubuntu 16.04 üzerinde yapacağım aynı zamanda forward edilen tüm loglar da Linux OS’e sahip serverlardan olacaktır.

Download Filebeat

The current Filebeat package is downloaded from the following URL.

https://artifacts.elastic.co/downloads/beats/filebeat/filebeat-7.2.0-amd64.deb

Installing Filebeat

Downloaded debian package install with the following command.

sudo dpkg -i filebeat-7.2.0-amd64.deb

Configuring File

After the filebeat installation step, the filebeat.yml file is configured with the following command.

sudo nano /etc/filebeat/filebeat.yml

Set the enabled true and add path to filename of the log to be read by filebeat. Uncomment (remove # as the first character) exclude_files: [‘.gz $’] line.

#===================== Filebeat inputs =============================
filebeat.inputs:
- type: log
enabled: true
paths:
- /path/to/file/name_of_the_log_to_be_read_by_filebeat.log
exclude_files: ['.gz$']

You need to comment (add the # as first character) entire “Elasticsearch output” field.

#— — — — — — — Elasticsearch output — — — — — — — — — — — — — — — #output.elasticsearch:# Array of hosts to connect to.#hosts: [“localhost:9200”]

You need to uncomment (remove the # as first character) only belowed lines in the “Logstash output” field. Set the Log stash ip and port address to hosts field.

# — — — — -— — — Logstash output — — — — — — — — — — — — — — — — 
output.logstash:
# The Logstash hosts
hosts: [“server_ip_address:server_ip_port”]

Starting and Checking Filebeat Service

To enable Filebeat during the operating system’s startup.

sudo systemctl enable filebeat.service
sudo systemctl start filebeat.service
sudo /etc/init.d/filebeat start
sudo service filebeat status

--

--