GNU/Linux >> Linux Esercitazione >  >> Cent OS

Come installare ELK Stack su RHEL 8

L'ELK Stack, noto anche come Elastic Stack, è composto da Elasticsearch, Logstash, Kibana e Beats. Permette di raccogliere, analizzare e visualizzare log provenienti da più sistemi.

Componenti

Elasticsearch: motore di ricerca e analisi.
Logstash: elabora e invia i log a Elasticsearch.
Kibana: interfaccia di visualizzazione.
Beats: agent che raccolgono e inviano log.

Prerequisiti: Java

yum -y install java
java -version

Repository Elastic

rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch

Crea il repository:

cat << EOF > /etc/yum.repos.d/elastic.repo
[elasticsearch-7.x]
name=Elasticsearch repository for 7.x packages
baseurl=https://artifacts.elastic.co/packages/oss-7.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=1
autorefresh=1
type=rpm-md
EOF

Installa Elasticsearch

yum install -y elasticsearch-oss

Modifica la configurazione:

vi /etc/elasticsearch/elasticsearch.yml

Imposta:

cluster.name: elkstack
node.name: elk.itzgeek.local
network.host: 192.168.1.10
discovery.seed_hosts: ["elk.itzgeek.local"]
cluster.initial_master_nodes: ["elk.itzgeek.local"]

Avvia il servizio:

systemctl daemon-reload
systemctl enable elasticsearch
systemctl start elasticsearch

Verifica:

curl -X GET https://192.168.1.10:9200

Installa Logstash

yum -y install logstash-oss

Crea la configurazione:

vi /etc/logstash/conf.d/beats.conf
input {
  beats {
    port => 5044
  }
}

filter {
  if [type] == "syslog" {
    grok {
      match => { "message" => "%{SYSLOGLINE}" }
    }
    date {
      match => [ "timestamp", "MMM d HH:mm:ss", "MMM dd HH:mm:ss" ]
    }
  }
}

output {
  elasticsearch {
    hosts => ["192.168.1.10:9200"]
    index => "%{[@metadata][beat]}-%{+YYYY.MM.dd}"
  }
}

Avvia Logstash:

systemctl start logstash
systemctl enable logstash

Installa Kibana

yum -y install kibana-oss
vi /etc/kibana/kibana.yml

Imposta:

server.host: "0.0.0.0"
elasticsearch.hosts: ["https://192.168.1.10:9200"]

Avvia Kibana:

systemctl start kibana
systemctl enable kibana

Firewall

firewall-cmd --permanent --add-port=5044/tcp
firewall-cmd --permanent --add-port=5601/tcp
firewall-cmd --reload

Installa Filebeat sul client

yum -y install filebeat
vi /etc/filebeat/filebeat.yml

Commenta la sezione output.elasticsearch e configura output.logstash:

output.logstash:
  hosts: ["192.168.1.10:5044"]

Configura gli input per raccogliere i log, ad esempio /var/log/messages, poi riavvia:

systemctl restart filebeat
systemctl enable filebeat

Accedi a Kibana

https://INDIRIZZO_IP:5601/

Crea un index pattern filebeat-* e usa Discover per visualizzare i log.

Cent OS
  1. Come installare ELK Stack su CentOS 8

  2. Come installare Graylog2 su CentOS 7 / RHEL 7

  3. Come installare Elasticsearch su CentOS 8/RHEL 8

  4. Installare Elasticsearch su CentOS o RHEL 8

  5. Installare e configurare lo stack ELK su CentOS 7

Come installare lo stack ELK su Debian 10 / Debian 9

Come installare ELK Stack su Ubuntu 18.04

Come installare ELK Stack su AlmaLinux 8

Come installare ELK Stack su CentOS 7

Come installare lo stack ELK su CentOS 8

Come installare lo stack ELK su Debian 8