Search for a command to run...
A comprehensive guide for installing and configuring the ELK Stack (Elasticsearch, Logstash, Kibana)
The ELK Stack is a collection of three open-source products: Elasticsearch, Logstash, and Kibana. It allows you to collect any data from any source, search, analyze, and visualize it in real time.
# Install Java
sudo apt update
sudo apt install default-jre -y
# Add Elastic GPG key
wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
# Add Elastic repository
echo "deb https://artifacts.elastic.co/packages/8.x/apt stable main" | \
sudo tee /etc/apt/sources.list.d/elastic-8.x.list
# Update package list
sudo apt update
# Install Elasticsearch
sudo apt install elasticsearch -y
# Start Elasticsearch
sudo systemctl daemon-reload
sudo systemctl enable elasticsearch
sudo systemctl start elasticsearch
# Install Kibana
sudo apt install kibana -y
# Start Kibana
sudo systemctl enable kibana
sudo systemctl start kibana
# Install Logstash
sudo apt install logstash -y
# Start Logstash
sudo systemctl enable logstash
sudo systemctl start logstash
# Network settings
network.host: 0.0.0.0
http.port: 9200
# Discovery settings
discovery.type: single-node
# Memory settings
bootstrap.memory_lock: true
# Security settings
xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true
# Server settings
server.port: 5601
server.host: "0.0.0.0"
# Elasticsearch connection
elasticsearch.hosts: ["http://localhost:9200"]
# Security settings
elasticsearch.username: "kibana_system"
elasticsearch.password: "your_password"
input {
beats {
port => 5044
}
tcp {
port => 5000
codec => json
}
}
filter {
if [type] == "syslog" {
grok {
match => { "message" => "%{SYSLOGTIMESTAMP:syslog_timestamp} %{SYSLOGHOST:syslog_hostname} %{DATA:syslog_program}(?:\[%{POSINT:syslog_pid}\])?: %{GREEDYDATA:syslog_message}" }
}
date {
match => [ "syslog_timestamp", "MMM d HH:mm:ss", "MMM dd HH:mm:ss" ]
}
}
}
output {
elasticsearch {
hosts => ["localhost:9200"]
index => "logstash-%{+YYYY.MM.dd}"
}
}
sudo systemctl status elasticsearch
curl -X GET "localhost:9200/"
sudo systemctl status kibana
http://localhost:5601
sudo systemctl status logstash
sudo -u logstash /usr/share/logstash/bin/logstash --config.test_and_exit -f /etc/logstash/conf.d/logstash.conf
# Generate CA
bin/elasticsearch-certutil ca
# Generate certificates
bin/elasticsearch-certutil cert --ca elastic-stack-ca.p12
xpack.security.transport.ssl.enabled: true
xpack.security.transport.ssl.verification_mode: certificate
xpack.security.transport.ssl.keystore.path: elastic-certificates.p12
xpack.security.transport.ssl.truststore.path: elastic-certificates.p12
# For Elasticsearch
bin/elasticsearch-setup-passwords interactive
# For Kibana (in kibana.yml)
elasticsearch.username: "kibana_system"
elasticsearch.password: "your_password"
Elasticsearch Won't Start
sudo journalctl -u elasticsearch
Kibana Can't Connect to Elasticsearch
Logstash Pipeline Issues