Elastic Stack 5 : Install Logstash2017/05/07 |
Install Logstash which collects or manages various logs.
For description of Logstash or how to write the setting file, refer to official site below.
⇒ https://www.elastic.co/guide/en/logstash/current/index.html |
|
[1] | Install Logstash. Configure Repository for Elasticsearch before it like here. |
[root@dlp ~]# yum -y install logstash
|
[2] | Create a setting file and start Logstash. For example, create a setting that Logstash collects sshd fail logs from [/var/log/secure]. |
[root@dlp ~]#
vi /etc/logstash/conf.d/sshd.conf # create new # extract sshd fail logs from [/var/log/secure] and output to index [sshd_fail-yyyy.mm] in elasticsearch input { file { type => "seucure_log" path => "/var/log/secure" } } filter { grok { add_tag => [ "sshd_fail" ] match => { "message" => "Failed %{WORD:sshd_auth_type} for %{USERNAME:sshd_invalid_user} from %{IP:sshd_client_ip} port %{NUMBER:sshd_port} %{GREEDYDATA:sshd_protocol}" } } } output { elasticsearch { index => "sshd_fail-%{+YYYY.MM}" } } chgrp logstash /var/log/secure [root@dlp ~]# chmod 640 /var/log/secure [root@dlp ~]# systemctl start logstash [root@dlp ~]# systemctl enable logstash
|
[3] | Few minutes later, make sure logs are collected normally. |
# show index list [root@dlp ~]# curl localhost:9200/_cat/indices?v health status index uuid pri rep docs.count docs.deleted store.size pri.store.size yellow open .kibana FGjE6bGUTlioELtM_QynMQ 1 1 2 0 7.7kb 7.7kb yellow open sshd_fail-2017.05 owhoRGiwTWGdZaqKAMw66g 5 1 13 0 43.7kb 43.7kb # show document list on index [root@dlp ~]# curl localhost:9200/sshd_fail-2017.05/_search?pretty { "took" : 1, "timed_out" : false, "_shards" : { "total" : 5, "successful" : 5, "failed" : 0 }, "hits" : { "total" : 13, "max_score" : 1.0, "hits" : [ { "_index" : "sshd_fail-2017.05", "_type" : "seucure_log", ..... ..... |
[4] | To add the Index in Kibana, data is imported in it and possible to create visualization you like. |
Sponsored Link |