This is the documentation for Wazuh 2.1. Check out the docs for the latest version of Wazuh!

Install Elastic Stack with Debian packages

The DEB package is suitable for Debian, Ubuntu, and other Debian-based systems.

Note

Many of the commands described below need to be executed with root user privileges.

Preparation

  1. Oracle Java JRE is required by Logstash and Elasticsearch:
  1. For Debian:
$ echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main" | tee /etc/apt/sources.list.d/webupd8team-java.list
$ echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu xenial main" | tee -a /etc/apt/sources.list.d/webupd8team-java.list
$ apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886
  1. For Ubuntu:
$ add-apt-repository ppa:webupd8team/java
  1. Once the repository is added, install Java JRE:
$ apt-get update
$ apt-get install oracle-java8-installer
  1. Install the Elastic repository and its GPG key:
$ apt-get install curl apt-transport-https
$ curl -s https://artifacts.elastic.co/GPG-KEY-elasticsearch | apt-key add -
$ echo "deb https://artifacts.elastic.co/packages/5.x/apt stable main" | tee /etc/apt/sources.list.d/elastic-5.x.list
$ apt-get update

Elasticsearch

Elasticsearch is a highly scalable full-text search and analytics engine. For more info please see Elasticsearch.

  1. Install the Elasticsearch package:
$ apt-get install elasticsearch=5.6.5
  1. Enable and start the Elasticsearch service:
  1. For Systemd:
$ systemctl daemon-reload
$ systemctl enable elasticsearch.service
$ systemctl start elasticsearch.service
  1. For SysV Init:
$ update-rc.d elasticsearch defaults 95 10
$ service elasticsearch start
  1. Load Wazuh Elasticsearch template:
$ curl https://raw.githubusercontent.com/wazuh/wazuh-kibana-app/2.1/server/startup/integration_files/template_file.json | curl -XPUT 'http://localhost:9200/_template/wazuh' -H 'Content-Type: application/json' -d @-
  1. Insert sample alert:
$ curl https://raw.githubusercontent.com/wazuh/wazuh-kibana-app/2.1/server/startup/integration_files/alert_sample.json | curl -XPUT "http://localhost:9200/wazuh-alerts-"`date +%Y.%m.%d`"/wazuh/sample" -H 'Content-Type: application/json' -d @-

Note

It is recommended to edit the default configuration to improve the Elasticsearch performance. To do so, please see Elasticsearch tuning.

Logstash

Logstash is the tool that will collect, parse, and forward to Elasticsearch for indexing and storage all logs generated by Wazuh server. For more info please see Logstash.

  1. Install the Logstash package:
$ apt-get install logstash=1:5.6.5-1
  1. Download the Wazuh config for Logstash:
$ curl -so /etc/logstash/conf.d/01-wazuh.conf https://raw.githubusercontent.com/wazuh/wazuh/2.1/extensions/logstash/01-wazuh.conf
  1. Download the Wazuh Logstash template:
$ curl -so /etc/logstash/wazuh-elastic5-template.json https://raw.githubusercontent.com/wazuh/wazuh/2.1/extensions/elasticsearch/wazuh-elastic5-template.json
  1. Follow this step only if you are using a single-host architecture:
  1. Edit /etc/logstash/conf.d/01-wazuh.conf, commenting out the entire input section titled “Remote Wazuh Manager - Filebeat input” and uncommenting the entire input section titled “Local Wazuh Manager - JSON file input”. This will set up Logstash to read the Wazuh alerts.json file directly from the local filesystem rather than expecting Filebeat on a separate server to forward the information in that file to Logstash.
  2. Because the Logstash user needs to read alerts.json file, please add it to OSSEC group by running:
$ usermod -a -G ossec logstash
  1. Enable and start the Logstash service:
  1. For Systemd:
$ systemctl daemon-reload
$ systemctl enable logstash.service
$ systemctl start logstash.service
  1. For SysV Init:
$ update-rc.d logstash defaults 95 10
$ service logstash start

Note

If you are running Wazuh server and the Elastic Stack server on separate systems (distributed architecture), then it is important to configure encryption between Filebeat and Logstash. To do so, please see Setting up SSL for Filebeat and Logstash.

Kibana

Kibana is a flexible and intuitive web interface for mining and visualizing the events and archives stored in Elasticsearch. More info at Kibana.

  1. Install the Kibana package:
$ apt-get install kibana=5.6.5
  1. Install the Wazuh App plugin for Kibana:
$ /usr/share/kibana/bin/kibana-plugin install https://packages.wazuh.com/wazuhapp/wazuhapp-2.1.1_5.6.5.zip

Warning

The Kibana plugin installation process may take several minutes. Please wait patiently.

  1. Optional. Kibana will listen only on the loopback interface (localhost) by default. To set up Kibana to listen on all interfaces, edit the file /etc/kibana/kibana.yml. Uncomment the setting server.host and change the value to:
server.host: "0.0.0.0"

Note

It is recommended to set up an Nginx proxy for Kibana in order to use SSL encryption and to enable authentication. Instructions to set the proxy up can be found at Setting up SSL and authentication for Kibana.

  1. Enable and start the Kibana service:
  1. For Systemd:
$ systemctl daemon-reload
$ systemctl enable kibana.service
$ systemctl start kibana.service
  1. For SysV Init:
$ update-rc.d kibana defaults 95 10
$ service kibana start
  1. Disable the Elastic repository:

We recommend to disable the Elasticsearch repository in order to prevent an upgrade to a newer Elastic Stack version due to possible breaking changes with our App, so you should do it as follow:

$ sed -i -r '/deb https:\/\/artifacts.elastic.co\/packages\/5.x\/apt stable main/ s/^(.*)$/#\1/g' /etc/apt/sources.list.d/elastic-5.x.list

Connecting the Wazuh App with the API

Follow the next guide in order to connect the Wazuh App with the API: