GrayLog Nedir ? Nasıl Kurulur ?

Anil Ozturk
Devops Türkiye☁️ 🐧 🐳 ☸️
3 min readJul 11, 2019

Graylog; tüm loglarınızı merkezi olarak bir noktada toplama, anomalileri gözlemleme, analiz yapma ve kısmen dashboard hazırlama gibi aksiyonları yapabileceğimiz açık kaynak kodlu bir loglama yazılımıdır.

Open source olması bizleri cezbeden noktalardan :) ancak developer toolu gibi düşünülmesinden dolayı dashboard tarafı oldukça zayıf bu noktada “Kibana” farklı toollar kullanılabilir.

Mimarisinde Elasticsearch ve Mongodb bulunuyor Graylog kurulumundan önce ön gereksinimleri ve mimarideki diğer bileşenleri kuracağız.

Bu makalede Graylog server tarafının kurulum ve konfigürasyonlarından bahsetmeye çalışacağım, Graylog server a logları direk gönderebilirsiniz ya da filebeat gibi log shipping aracı kullanabilirsiniz, başka bir makalede filebeat ile client tarafından log gönderilmesini konusunu yazmayı planlıyorum.

Kurulumları Ubuntu 16.04 versiyonu üzerine yapacağım.

Not : Kurulum için hazırladığım doküman ingilizce olduğu için kurulum adımlarını da bu şekilde tamamlayacağım, teknik terimler olduğu için sıkıntı yaşanacağını düşünmüyorum.

Prerequisites :

Taking a minimal server setup as base will need this additional packages:

sudo apt-get update && sudo apt-get upgradesudo apt-get install apt-transport-https openjdk-8-jre-headless uuid-runtime pwgen

MongoDB :

The official MongoDB repository provides the most up-to-date version and is the recommended way of installing MongoDB:

sudo apt-key adv — keyserver hkp://keyserver.ubuntu.com:80 — recv DA31620334BD75D9DCB49F368818C72E52529D4echo “deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 multiverse” | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.listsudo apt-get updatesudo apt-get install -y mongodb-org

The last step is to enable MongoDB during the operating system’s startup:
sudo systemctl daemon-reload

sudo systemctl enable mongod.servicesudo systemctl restart mongod.servicesudo systemctl restart mongod.service

Elasticsearch

Graylog can be used with Elasticsearch 6.x.

wget -qO — https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add –echo “deb https://artifacts.elastic.co/packages/oss-6.x/apt stable main” | sudo tee -a /etc/apt/sources.list.d/elastic-6.x.listsudo apt-get update && sudo apt-get install elasticsearch-oss

Make sure to modify the Elasticsearch configuration file (/etc/elasticsearch/elasticsearch.yml) and set the cluster name to graylog additionally you need to uncomment (remove the # as first character) the line, and add action.auto_create_index: false to the configuration file:

cluster.name: graylogaction.auto_create_index: false

After you have modified the configuration, you can start Elasticsearch:

sudo systemctl daemon-reloadsudo systemctl enable elasticsearch.servicesudo systemctl restart elasticsearch.service

Graylog :

Now install the Graylog repository configuration and Graylog itself with the following commands:

wget https://packages.graylog2.org/repo/packages/graylog-3.0-repository_latest.debsudo dpkg -i graylog-3.0-repository_latest.debsudo apt-get update && sudo apt-get install graylog-server

Follow the instructions in your /etc/graylog/server/server.conf and add password_secret and root_password_sha2. These settings are mandatory and without them, Graylog will not start!
You need to use the following command to create your root_password_sha2:

echo -n “Enter Password: “ && head -1 </dev/stdin | tr -d ‘\n’ | sha256sum | cut -d” “ -f1

To be able to connect to Graylog you should set http_bind_address to the public host name or a public IP address of the machine you can connect to.
The next step is to enable Graylog during the operating system’s startup:

sudo systemctl daemon-reloadsudo systemctl enable graylog-server.servicesudo systemctl start graylog-server.service

The last step is to modify the heap size; firstly graylog in /etc/default/graylog-server confg file, values depends on your server resources.

GRAYLOG_SERVER_JAVA_OPTS=”-Xms1g -Xmx4g

Lastly, modify /etc/elasticsearch/jvm.options config file

# Xms represents the initial size of total heap space
# Xmx represents the maximum size of total heap space
-Xms1g
-Xmx2g

Umarım faydalı olmuştur…

--

--