Integrations Wazuh and ELK

Elastic Stack integration

Prerequisites

Ubuntu Server 24.04.2 - 192.168.35.133

Wazuh ELK version support: 4.0-4.5

Elasticsearch version 7.17.13

Installing Elasticsearch

Ubuntu’s default package repositories do not include Elasticsearch components. However, you can install them via APT by adding Elastic’s official package source. To enhance security and prevent package spoofing, all packages are signed with a GPG key, enabling the package manager to verify their authenticity. Before proceeding with the installation, let’s import the public GPG key and add the Elastic package source list.

curl -s https://artifacts.elastic.co/GPG-KEY-elasticsearch | gpg --no-default-keyring --keyring gnupg-ring:/usr/share/keyrings/elasticsearch.gpg --import && chmod 644 /usr/share/keyrings/elasticsearch.gpg
echo "deb [signed-by=/usr/share/keyrings/elasticsearch.gpg] https://artifacts.elastic.co/packages/7.x/apt stable main" | tee /etc/apt/sources.list.d/elastic-7.x.list
apt-get update
image.png

Install the Elasticsearch package with apt:

Next, we need download the configuration file /etc/elasticsearch/elasticsearch.yml as follows:

Now, download the configuration file for creating the certificates:

In the following steps, a file will be generated containing a folder named after the instance specified here. This folder will store the necessary certificates and keys required for secure SSL communication with the Elasticsearch node. To create these certificates, use the elasticsearch-certutil tool with the following command: This command generates a certificate authority (CA) along with SSL certificates and keys based on the details provided in instances.yml, packaging them into a ZIP archive for easy access.

This command generates a certificate authority (CA) along with SSL certificates and keys based on the details provided in instances.yml, packaging them into a ZIP archive for easy access. Extract file /usr/share/elasticsearch/certs.zip

The next step is to create the directory /etc/elasticsearch/certs, and then copy the CA file, the certificate and the key there:

Now, enable Elasticsearch to start automatically on system boot.

To generate credentials for all pre-built roles and users in the Elastic Stack, run the following command:

This command will automatically create and assign passwords for built-in users such as elastic, kibana_system, and logstash_system

To check that the installation was made successfull, run the following command:

Installing Wazuh server

The Wazuh server collects and analyzes data from deployed agents, running the Wazuh manager, API, and Filebeat. To set up Wazuh, start by adding the repository:

Next, we will install the Wazuh manager package

Now, enable Wazuh manager service to start automatically on system boot.

Installing Filebeat

Filebeat is the tool on the Wazuh server that securely forwards alerts and archived events to Elasticsearch.

Install the Filebeat package with command:

Download the pre-configured Filebeat config file used to forward Wazuh alerts to Elasticsearch:

Download the alerts template for Elasticsearch:

Download the Wazuh module for Filebeat

Next, we need to update the /etc/filebeat/filebeat.yml with nano to configure

Copy the certificates into /etc/filebeat/certs/

To enable and start the Filebeat service, run the following commands:

Next, check test the connection to Elasticsearch by running.

Kibana installation and

configuration

Kibana is a powerful and user-friendly web interface for exploring, analyzing, and visualizing data stored in Elasticsearch.

Now, we need install the Kibana package

Copy the Elasticsearch certificates into the Kibana configuration folder:

Next,download the Kibana configuration file

The next step is to open the Kibana configuration file /etc/kibana/kibana.yml

Create the /usr/share/kibana/data directory

Next, install the Wazuh Kibana plugin. The installation of the plugin must be done from the Kibana home directory as follows:

Link Kibana's socket to privileged port 443:

Now, enable and start the Kibana service

Access the web interface using the password generated during the Elasticsearch installation process:

Last updated