Author Topic: ระบบเก็บ log graylog บริการดีๆ จากทางแพ็คเกตเลิฟ  (Read 7640 times)

golfreeze

  • Administrator
  • Hero Member
  • *****
  • Posts: 2140
    • View Profile
    • นั่งสมาธิ สติปัฏฐานสี่ พาเที่ยววัด แนะนำวัด แจกcd ธรรมะฟรี
    • Email
« Last Edit: กรกฎาคม 28, 2017, 06:44:31 PM by golfreeze »

golfreeze

  • Administrator
  • Hero Member
  • *****
  • Posts: 2140
    • View Profile
    • นั่งสมาธิ สติปัฏฐานสี่ พาเที่ยววัด แนะนำวัด แจกcd ธรรมะฟรี
    • Email
Re: ระบบเก็บ log graylog
« Reply #1 on: ตุลาคม 18, 2016, 01:37:26 PM »
Prerequisites
Make sure to install and configure the following software before installing and starting any Graylog services:

Java (>= 8)
MongoDB (>= 2.4)
Elasticsearch (>= 2.x)

DEB / APT

Download and install graylog-2.1-repository_latest.deb via dpkg(1) and also make sure that the apt-transport-https package is installed:

$ sudo apt-get install apt-transport-https
$ wget https://packages.graylog2.org/repo/packages/graylog-2.1-repository_latest.deb
$ sudo dpkg -i graylog-2.1-repository_latest.deb
$ sudo apt-get update
$ sudo apt-get install graylog-server


################################################################################
Graylog does NOT start automatically!

Please run the following commands if you want to start Graylog automatically on system boot:

    sudo systemctl daemon-reload
    sudo systemctl enable graylog-server.service

    sudo systemctl start graylog-server.service

################################################################################
« Last Edit: ตุลาคม 18, 2016, 01:41:25 PM by golfreeze »

golfreeze

  • Administrator
  • Hero Member
  • *****
  • Posts: 2140
    • View Profile
    • นั่งสมาธิ สติปัฏฐานสี่ พาเที่ยววัด แนะนำวัด แจกcd ธรรมะฟรี
    • Email
Re: ระบบเก็บ log graylog
« Reply #2 on: ตุลาคม 18, 2016, 01:43:16 PM »

golfreeze

  • Administrator
  • Hero Member
  • *****
  • Posts: 2140
    • View Profile
    • นั่งสมาธิ สติปัฏฐานสี่ พาเที่ยววัด แนะนำวัด แจกcd ธรรมะฟรี
    • Email
สำหรับบริการ Log System ของทาง Packetlove.com มีติดตั้งเพิ่มเติมให้กับลูกค้าครับ  ทางเราเลือกใช้งาน
ตัวGraylog2.x + Elasticsearch2.3.x + Mongo DB3.2
=> ถ้า volume log size > วันละ 10GB แนะนำให้ทำ cluster ดีกว่าครับจะเหมาะสมกว่า
แล้วแยกโหนด graylog-web ออกมาครับ

เวลาเรียก graylog-web จะเรียกผ่าน ip : 10.99.99.1 นะครับ
ดังนั้นเข้าผ่านเว็บจะเป้น
http://10.99.99.1:9000
ครับ

### ลองดูข้อจำกัดของ version ที่กระทบกันด้วยนะครับ
ถ้า graylog 2.x จะใช้งานกับ elasticsearch 2.4 ยังไม่ได้นะครับ มี bug เรื่องการแสดง log ในหน้าเว็บครับ
แต่ถ้า query ผ่าน command จะใช้งานได้ปกติครับ
แนะนำให้ downgrade ลงมานะครับ

#wget https://download.elastic.co/elasticsearch/release/org/elasticsearch/distribution/rpm/elasticsearch/2.3.5/elasticsearch-2.3.5.rpm

ทำการ stop elasticsearch 2.4
#systemctl stop elasticsearch.service

uninstall elasticsearch 2.4
#yum remove elasticsearch

ทำการลบ dir socket ของ elasticsearch version 2.4 ออกครับ
#cd /var/lib
#mv elasticsearch elasticsearch.23

ทำการติดตั้ง elasticsearch 2.3 ผ่าน rpm package
#rpm -ivh elasticsearch-2.3.5.rpm

เช็ค permission ของ /var/lib/elasticsearch ให้เรียบร้อยครับ
ทำการ start elasticsearch
#systemctl enable elasticsearch

ทำการ configure elasticsearch.xml และ start การทำงาาน พร้อม debug log
#systemctl start elasticsearch ; tail -f /var/log/elasticsearch/graylog.log

###Reference link
http://docs.graylog.org/en/2.2/pages/installation/os/ubuntu.html <= focus on ubuntu 14
https://severalnines.com/blog/high-availability-log-processing-graylog-mongodb-and-elasticsearch

สำหรับตัว configure ผมทำเป็นตัวอย่างให้ดู สองไฟล์นะครับ ถ้าบันทัดไหนไม่ได้ใช้งานจะไม่ได้เอามาแสดงนะครับผม

#### Begin Configuration of graylog service /etc/graylog/server/server.conf ########
#less server.conf | grep -v ^# | sed '/^$/d'
is_master = true
node_id_file = /etc/graylog/server/node-id
password_secret = asdfasdfasdfasdf
root_password_sha2 = asdfasdfe
root_email = "support@packetlove.com"
root_timezone = Asia/Bangkok
plugin_dir = /usr/share/graylog-server/plugin
rest_listen_uri = http://10.99.99.1:12900/
web_listen_uri = http://10.99.99.1:9000/
web_enable_cors = true
rotation_strategy = count
elasticsearch_max_docs_per_index = 20000000
elasticsearch_max_number_of_indices = 20
retention_strategy = delete
elasticsearch_shards = 4
elasticsearch_replicas = 0
allow_leading_wildcard_searches = false
allow_highlighting = false
elasticsearch_cluster_name = graylog
elasticsearch_analyzer = standard
output_batch_size = 500
output_flush_interval = 1
output_fault_count_threshold = 5
output_fault_penalty_seconds = 30
processbuffer_processors = 5
outputbuffer_processors = 3
processor_wait_strategy = blocking
ring_size = 65536
inputbuffer_ring_size = 65536
inputbuffer_processors = 2
inputbuffer_wait_strategy = blocking
message_journal_enabled = true
message_journal_dir = /var/lib/graylog-server/journal
lb_recognition_period_seconds = 3
mongodb_uri = mongodb://localhost/graylog
mongodb_max_connections = 1000
mongodb_threads_allowed_to_block_multiplier = 5
content_packs_dir = /usr/share/graylog-server/contentpacks
content_packs_auto_load = grok-patterns.json
#### End Configuration of graylog service /etc/graylog/server/server.conf ########

##### begin Configuration of /etc/elasticsearch/elasticsearch.xml ##############
cluster.name: graylog
##### End Configuration of /etc/elasticsearch/elasticsearch.xml ##############

##Port listen on graylog-server for
#Web interface on
rest_listen_uri = http://10.99.99.1:12900/
web_listen_uri = http://10.99.99.1:9000/
elastic search on 127.0.0.1:9200
elasticsearch_discovery_zen_ping_unicast_hosts   127.0.0.1:9300


###### create Input on graylog-server
Go to “System/Input”  -> “Input” -> Select input type as “Raw/Plaintext TCP”  port 1514 listen on 0.0.0.0

#### On client to send log Ubuntu client @@=tcp , @=udp
#vi /etc/rsyslog.d/50-default.conf
Add line below 
### Send log For graylog server
*.*     @@10.99.99.1:1514
#/etc/init.d/rsyslog restart
« Last Edit: กรกฎาคม 28, 2017, 07:04:58 PM by golfreeze »