Erinevus lehekülje "ELK Stack põhine logiserver" redaktsioonide vahel
80. rida: | 80. rida: | ||
# ln -s /etc/init.d/logstash /etc/runlevels/default/ | # ln -s /etc/init.d/logstash /etc/runlevels/default/ | ||
# ln -s /etc/init.d/elasticsearch /etc/runlevels/default/ | # ln -s /etc/init.d/elasticsearch /etc/runlevels/default/ | ||
+ | |||
+ | = Paigaldamine Arch linuxis = | ||
+ | |||
+ | pacman -S elasticsearch nginx | ||
+ | |||
+ | logstash paneb java ka peale ise | ||
+ | |||
+ | aurista installida logstash kibana | ||
+ | |||
+ | systemctl enable elasticsearch | ||
+ | systemctl enable logstash | ||
+ | systemctl enable logstash-web | ||
+ | systemctl enable kibana | ||
+ | systemctl enable nginx | ||
+ | |||
+ | /etc/logstash/conf.d/logstash-simple.conf | ||
+ | |||
+ | input { | ||
+ | file { | ||
+ | path => "/var/log/faillog" | ||
+ | start_position => beginning | ||
+ | } | ||
+ | |||
+ | # network syslog input | ||
+ | syslog { | ||
+ | host => "0.0.0.0" | ||
+ | port => 514 | ||
+ | } | ||
+ | |||
+ | } | ||
+ | |||
+ | output { | ||
+ | elasticsearch { host => localhost } | ||
+ | } | ||
+ | |||
+ | |||
+ | /etc/nginx/nginx.conf | ||
+ | |||
+ | # Nginx proxy for Elasticsearch + Kibana | ||
+ | # | ||
+ | server { | ||
+ | listen 80; | ||
+ | server_name localhost; | ||
+ | access_log /var/log/nginx-logstash.log; | ||
+ | |||
+ | #auth_basic "Restricted Access"; | ||
+ | #auth_basic_user_file /etc/webapps/kibana/htpasswd.users; | ||
+ | |||
+ | location / { | ||
+ | proxy_pass http://localhost:5601; | ||
+ | proxy_http_version 1.1; | ||
+ | proxy_set_header Upgrade $http_upgrade; | ||
+ | proxy_set_header Connection 'upgrade'; | ||
+ | proxy_set_header Host $host; | ||
+ | proxy_cache_bypass $http_upgrade; | ||
+ | } | ||
+ | } | ||
= Kliendid = | = Kliendid = |
Redaktsioon: 12. jaanuar 2016, kell 15:53
Sisukord
Sissejuhatus
ELK stack nimi tuleb selle komponentide esitähtedest: Elasticsearch-Logstash-Kibana. Selle näol on tegemist logiserveri lahendusega, mis pakub indekseerimist ja põhjalikke otsinguid võimaldavat veebiliidest.
ELK stack koosneb kolmest komponendist
- Logstash: mis kuulab 5000 pordil ja võtab logid serveritest vastu
- Elasticsearch: tegeleb logi salvestamise ja indekseerimisega
- Kibana: weebiliides mis võimaldab otsingu ja visualiseerimisega
_____ ELK logiserver 192.168.1.10 | | :5000/tcp |_____| :5000/udp | | -|---------|----------|----....---|-- | | | __|__ __|__ __|__ | | | | | | (logi ELKi edastavad serverid) |_____| |_____| |_____| smtp www dns
Paigaldamine gentoos
Paigaldame vajalikud paketid
# emerge app-admin/logstash-bin app-misc/elasticsearch www-apps/kibana-bin virtual/jdk
Ning seejärel java versioon paika
# java-config --set-system-vm icedtea-bin-7"
Seejärel tuleb tekitada vajalikud konfifailid
/etc/elasticsearch/logging.yml /etc/elasticsearch/elasticsearch.in.sh /etc/elasticsearch/elasticsearch.yml /etc/logstash/conf.d/agent.conf
Esimesed kolm võivad olla vaikimisi süsteemi näidetekausta paigaldatud ja muutmist ei nõua. Logstashi agent.conf konfifail võiks välja näha järgnev
input {
tcp {
port => 5000
type => syslog
}
udp {
port => 5000
type => syslog
}
}
filter {
if [type] == "syslog" {
grok {
match => { "message" => "<%{POSINT:syslog_pri}>%{SYSLOGTIMESTAMP:syslog_timestamp} %{SYSLOGHOST:syslog_hostname} %{DATA:syslog_program}(?:\[%{POSINT:syslog_pid}\])?: %{GREEDYDATA:syslog_message}" }
}
}
}
output {
elasticsearch { host => localhost }
stdout { codec => rubydebug }
}
Võimalik on inputi ahelasse defineerida ka serveri enda lokaalsed logid nt sektsiooniga
file { type => "logserver" path => [ "/var/log/syslog", "/var/log/*.log" ] }
Teenused automaatselt startima
# ln -s /etc/init.d/kibana /etc/runlevels/default/ # ln -s /etc/init.d/logstash /etc/runlevels/default/ # ln -s /etc/init.d/elasticsearch /etc/runlevels/default/
Paigaldamine Arch linuxis
pacman -S elasticsearch nginx
logstash paneb java ka peale ise
aurista installida logstash kibana
systemctl enable elasticsearch systemctl enable logstash systemctl enable logstash-web systemctl enable kibana systemctl enable nginx
/etc/logstash/conf.d/logstash-simple.conf
input { file { path => "/var/log/faillog" start_position => beginning } # network syslog input syslog { host => "0.0.0.0" port => 514 } } output { elasticsearch { host => localhost } }
/etc/nginx/nginx.conf
# Nginx proxy for Elasticsearch + Kibana # server { listen 80; server_name localhost; access_log /var/log/nginx-logstash.log; #auth_basic "Restricted Access"; #auth_basic_user_file /etc/webapps/kibana/htpasswd.users; location / { proxy_pass http://localhost:5601; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; } }
Kliendid
TODO
Syslog-ng puhul võib seadistada
destination loghost { udp("192.168.1.10"); }; log { source(src); filter(f_mail); destination(mail); destination(loghost); flags(final); };
Kibana
Kibana veebiliides töötab pordil 5601
Lingid
https://secure.trifork.com/dl/goto-berlin-2014/GOTO_Night/logstash-kibana-intro.pdf
https://www.digitalocean.com/community/tutorials/how-to-use-kibana-dashboards-and-visualizations