Graylog Collector Sidecar Kurulumu
Bu yazımızda Graylog Collector Sidecar yapılandırması yapıyoruz.

Çalışan bir Graylog2 server adresine graylog:9000 ile bağlanıp;
-System -> Inputs -> Beats seçtikten sonra
*Bind 0.0.0.0
*Port 5044 (burada seçilen port için graylog2’nin çalıştığı ortamda port açılıyor. Docker ve k8 için port belirtilmeli)
Daha sonra collector-sidecar kullanarak /var/log/containers içersindeki logları graylog üzerine göndereceğiz. Bunun için üstte input oluşturduk.
Şimdi collector-sidecar ayarları için ;
-System -> Collectors -> Manage Configuration – > Create Configuration ile bir collector oluşturuyoruz.
Tag kısmına docker ekleyip update ediyoruz.
Bu collectorun ayarları içerisinden beats sekmesinde;
*Configure beats outputs -> create output
***Type: Filebeat beats output
***Hosts: graylog2 public ip ve portu
*Configure beats inputs -> create input
***Forward to: üstte oluşturduğumuz beats outputs
***Type: filebeat file input
**Path to logfile : [‘/var/log/containers/.log’]
filebeat kullanarak logları çekeceği için filebeat.yml için
*Define beats snippets create snippet
***Backend : filebeat
Snippet için :
filebeat:
prospectors:
- document_type: log
encoding: plain
fields:
collector_node_id: graylog-collector-sidecar
gl2_source_collector: df679aa2-ecdf-477a-9bf1-0bbd5e80b163
ignore_older: 0
input_type: log
paths:
- /var/log/containers/*.log
scan_frequency: 10s
tail_files: true
symlinks: true ## symlink olmazsa container logları okunamıyor.
output:
logstash:
hosts:
- graylogipadresi:5044 ## 5044 üstte oluşturduğumuz system-input port adresi
path:
data: /var/cache/graylog/collector-sidecar/filebeat/data
logs: /var/log/graylog/collector-sidecar
tags:
- linux
- docker
Container loglarını çekilebilmesi için ve bu üstte yapılan ayarlar için
https://github.com/Graylog2/collector-sidecar/releases
collector-sidecar-0.1.3.tar.gz
tar -xvf collector-sidecar-0.1.3.tar.gz
çıkan klasörde /graylog/collector-sidecar/0.1.3/linux/amd64/ collector-sidecar.yml oluşturuyoruz.
collector-sidecar.yml
************************************************************************************************
server_url: http://graylogserverip:9000/api/
update_interval: 30
tls_skip_verify: true
send_status: true
list_log_files:
- /var/log
node_id: graylog-collector-sidecar
collector_id: file:/etc/graylog/collector-sidecar/collector-id
log_path: /var/log/graylog/collector-sidecar
log_rotation_time: 86400
log_max_age: 604800
tags:
- linux
- docker ##BURADAKİ TAG BEATS INPUT OLUŞTURURKEN EKLEDİĞİMİZ TAG OLMALI
backends:
- name: winlogbeat
enabled: false
binary_path: C:\Program Files\graylog\collector-sidecar\winlogbeat.exe
configuration_path: C:\Program Files\graylog\collector-sidecar\generated\winlogbeat.yml
- name: filebeat
enabled: true
binary_path: /usr/bin/filebeat ##filebeat binary dosyasının yeri
configuration_path: /root/graylog/collector-sidecar/0.1.3/linux/amd64/filebeat.yml
###FILEBEAT CONF DOSYASININ YERINI BELİRTMEK İÇİN. HER NE KADAR YUKARIDA SNIPPET EKLESEKTE KENDISI OVERRIDE EDEREK OLUŞTURMASI GEREKİYOR.
graylog collector çalıştırmak için
/graylog/collector-sidecar/0.1.3/linux/amd64 klasörünün altında
./graylog-collector -c collector-sidecar.yml // -c ile collector-sidecar.yml seçilmeli
kontrol için graylog – > system – > collectors altında running ibaresi çıkacaktır.