<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Enhanced Security Monitoring : The Ultim]]></title><description><![CDATA[Enhanced Security Monitoring : The Ultim]]></description><link>https://khushiminipara.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Wed, 14 Oct 2026 09:22:09 GMT</lastBuildDate><atom:link href="https://khushiminipara.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[🛡️"Enhanced Security Monitoring: The Ultimate Guide to Wazuh and OpenSearch with Logstash" 🚀]]></title><description><![CDATA[In today's digital world, cybersecurity is critical. To combat evolving threats, integrating Wazuh with OpenSearch using Logstash is key. Wazuh excels in threat detection, while OpenSearch offers scalable data analysis. By integrating with Logstash, ...]]></description><link>https://khushiminipara.hashnode.dev/enhanced-security-monitoring-the-ultimate-guide-to-wazuh-and-opensearch-with-logstash</link><guid isPermaLink="true">https://khushiminipara.hashnode.dev/enhanced-security-monitoring-the-ultimate-guide-to-wazuh-and-opensearch-with-logstash</guid><category><![CDATA[wazuh]]></category><category><![CDATA[opensearch]]></category><category><![CDATA[#OpenSearchService]]></category><category><![CDATA[opensearch 2.x]]></category><category><![CDATA[logstash]]></category><category><![CDATA[Logs]]></category><category><![CDATA[dashboard]]></category><dc:creator><![CDATA[Khushi Minipara]]></dc:creator><pubDate>Wed, 01 May 2024 13:53:43 GMT</pubDate><content:encoded><![CDATA[<p>In today's digital world, cybersecurity is critical. To combat evolving threats, integrating Wazuh with OpenSearch using Logstash is key. Wazuh excels in threat detection, while OpenSearch offers scalable data analysis. By integrating with Logstash, organisations can streamline security monitoring, from data collection to visualisation. This blog guides you through setting up Wazuh, OpenSearch, and Logstash for enhanced cybersecurity. Let's dive in and empower your security operations!</p>
<p>Throughout this guide, we'll explore step-by-step instructions, best practices, and optimization techniques to ensure a seamless integration process.</p>
<p><img src="https://cdn.hashnode.com/res/hashnode/image/upload/v1713964818142/c1e373e0-c773-4c1a-acc0-846c58bf0b39.png" alt="Architecture Diagram" class="image--center mx-auto" /></p>
<h3 id="heading-step-1-infrastructure-requirements">Step 1 : Infrastructure Requirements.</h3>
<p>For this blog's implementation, we'll be using an Ubuntu virtual machine (VM) as the environment for deploying Wazuh, OpenSearch, and Logstash. Here are the key components of our infrastructure:</p>
<ol>
<li><p><strong>Ubuntu VM:</strong> Ensure your VM meets the minimum system requirements for running Wazuh, OpenSearch, and Logstash efficiently. This includes sufficient RAM, CPU cores, and disk space.</p>
</li>
<li><p><strong>Wazuh:</strong> As an open-source security monitoring platform, Wazuh requires specific ports for communication and data collection. By default, Wazuh uses ports such as <em>1514 (for syslog data), 55000 (for agent-manager communication), and 9200 (for OpenSearch integration)</em>. Please note that if there's a port conflict with OpenSearch, we'll adjust the port settings accordingly.</p>
</li>
<li><p><strong>OpenSearch:</strong> Similarly, OpenSearch uses ports for various services such as <em>HTTP (9200), HTTPS (9243), and the OpenSearch Dashboard port (5601</em>). It's crucial to check for port conflicts, especially if Wazuh and OpenSearch are installed on the same VM.</p>
</li>
<li><p><strong>Logstash:</strong> Logstash serves as the data processing pipeline between Wazuh and OpenSearch. It typically runs on <em>port 5044</em> for receiving data from Beats or other sources. Ensure this port is available and not in use by other services</p>
</li>
</ol>
<h3 id="heading-step-2-installation-and-configuration-of-wazuh-opensearch-and-opensearch-dashboard">Step 2: Installation and Configuration of Wazuh, OpenSearch and OpenSearch Dashboard .</h3>
<p><strong>Wazuh :</strong> For deploying Wazuh, a powerful open-source security monitoring platform, we can either use the official documentation available <a target="_blank" href="https://documentation.wazuh.com/current/installation-guide/index.html">here</a> or with the help of Ansible playbooks that are available on my <a target="_blank" href="https://github.com/Khushiminipara/Ansible/tree/main/Ansible-Playbook/Wazuh">GitHub Repository</a>. Using these playbooks you can automate the process of installation of wazuh components( User manual for running Ansible Playbook is <a target="_blank" href="https://dev.to/khush_1351/user-manual-for-automation-using-ansible--2ihf">here</a> ). In this integration I have kept Wazuh and Opensearch on different VM to avoid port conflicts.</p>
<p><strong>Opensearch :</strong> In addition to Wazuh, we'll have to install OpenSearch, a scalable and robust search and analytics engine. With OpenSearch, you can efficiently store, search, and analyze large datasets, complementing Wazuh's capabilities for enhanced security monitoring.</p>
<p>a. Download the Debian package for the desired version directly from the <a target="_blank" href="https://opensearch.org/downloads.html">OpenSearch Downloads Page</a> . The Debian Package can be downloaded for both <strong>x64</strong> and <strong>arm64</strong> architectures. The below given link is form x64 architecture.</p>
<pre><code class="lang-bash">wget https://artifacts.opensearch.org/releases/bundle/opensearch/2.13.0/opensearch-2.13.0-linux-x64.deb/
</code></pre>
<p>b. The command for installing OpenSearch using the provided Debian package and setting the initial admin password:</p>
<pre><code class="lang-bash">sudo env OPENSEARCH_INITIAL_ADMIN_PASSWORD=&lt;custom-admin-password&gt; dpkg -i opensearch-2.13.0-linux-x64.deb
</code></pre>
<p>Replace <code>&lt;custom-admin-password&gt;</code> with your desired password for the initial admin user during the installation process. This command uses <code>dpkg</code> to install the OpenSearch package from the Debian package file (<code>opensearch-2.13.0-linux-x64.deb</code>) and sets the initial admin password using the <code>OPENSEARCH_INITIAL_ADMIN_PASSWORD</code> environment variable.</p>
<p>c. Run these commands one after the other in your terminal to perform these actions sequentially: enabling OpenSearch to start on boot, starting the OpenSearch service, and checking its status to ensure it's running correctly.</p>
<pre><code class="lang-bash">sudo systemctl <span class="hljs-built_in">enable</span> opensearch  <span class="hljs-comment"># Enable OpenSearch to start automatically on boot</span>
sudo systemctl start opensearch   <span class="hljs-comment"># Start the OpenSearch service</span>
sudo systemctl status opensearch  <span class="hljs-comment"># Check the status of the OpenSearch service</span>
</code></pre>
<p>d. This command opens the <code>opensearch.yml</code> file located in the <code>/etc/opensearch/</code> directory using the <code>nano</code> editor with root privileges. You can then make the necessary changes to the OpenSearch configuration using the <code>nano</code> editor interface.</p>
<pre><code class="lang-bash">sudo nano /etc/opensearch/opensearch.yml
</code></pre>
<p>Add following lines to the OpenSearch.yml file -</p>
<pre><code class="lang-plaintext">network.host: 0.0.0.0
discovery.type: single-node
plugins.security.disabled: false
</code></pre>
<p>Save your file and close the editor.</p>
<p>e. Firstly navigate to the OpenSearch configuration directory (<code>/etc/opensearch</code>), remove any existing PEM files, generate a private key for the root certificate (<code>root-ca-key.pem</code>), and then create a self-signed root certificate (<code>root-ca.pem</code>) using OpenSSL with specific subject information (<code>-subj</code>) such as country (C), state (ST), locality (L), organization (O), organizational unit (OU), and common name (CN).</p>
<pre><code class="lang-bash"><span class="hljs-built_in">cd</span> /etc/opensearch
sudo rm -f *pem
sudo openssl genrsa -out root-ca-key.pem 2048
sudo openssl req -new -x509 -sha256 -key root-ca-key.pem -subj <span class="hljs-string">"/C=CA/ST=ONTARIO/L=TORONTO/O=ORG/OU=UNIT/CN=ROOT"</span> -out root-ca.pem -days 730
</code></pre>
<p>Now generate an admin certificate and sign it with the previously created root certificate and private key:</p>
<pre><code class="lang-bash">sudo openssl genrsa -out admin-key-temp.pem 2048
sudo openssl pkcs8 -inform PEM -outform PEM -<span class="hljs-keyword">in</span> admin-key-temp.pem -topk8 -nocrypt -v1 PBE-SHA1-3DES -out admin-key.pem   
sudo openssl req -new -key admin-key.pem -subj <span class="hljs-string">"/C=CA/ST=ONTARIO/L=TORONTO/O=ORG/OU=UNIT/CN=A"</span> -out admin.csr  
<span class="hljs-comment"># Sign the admin certificate with the root certificate and private key you created earlier.</span>
sudo openssl x509 -req -<span class="hljs-keyword">in</span> admin.csr -CA root-ca.pem -CAkey root-ca-key.pem -CAcreateserial -sha256 -out admin.pem -days 730
</code></pre>
<p>Then, create the node certificate and after the installation is successful, remove all temporary files that are not required. Later, make sure that the remaining certificates are owned by the OpenSearch user.</p>
<pre><code class="lang-bash">sudo openssl genrsa -out node1-key-temp.pem 2048
sudo openssl pkcs8 -inform PEM -outform PEM -<span class="hljs-keyword">in</span> node1-key-temp.pem -topk8 -nocrypt -v1 PBE-SHA1-3DES -out node1-key.pem
<span class="hljs-comment"># Create the CSR and replace the arguments passed to -subj so they reflect your specific host.</span>
<span class="hljs-comment"># The CN should match IP Address on which opensearch is installed.</span>
sudo openssl req -new -key node1-key.pem -subj <span class="hljs-string">"/C=CA/ST=ONTARIO/L=TORONTO/O=ORG/OU=UNIT/CN=192.168.1.10"</span> -out node1.csr  
<span class="hljs-comment"># Create an extension file that defines a SAN IP for the host. This</span>
<span class="hljs-comment"># should match the IP of the host.</span>
sudo sh -c <span class="hljs-string">'echo subjectAltName=IP:192.168.1.10 &gt; node1.ext'</span>
sudo openssl x509 -req -<span class="hljs-keyword">in</span> node1.csr -CA root-ca.pem -CAkey root-ca-key.pem -CAcreateserial -sha256 -out node1.pem -days 730 -extfile node1.ext
sudo rm -f *temp.pem *csr *ext <span class="hljs-comment">#Remove temporary files</span>
sudo chown opensearch:opensearch admin-key.pem admin.pem node1-key.pem node1.pem root-ca-key.pem root-ca.pem <span class="hljs-comment">#checking ownership</span>
</code></pre>
<p>Now run following commands after removing similar commands present in <code>opensearch.yml</code> file located in the <code>/etc/opensearch/</code> . The following commands will add this script with updated CN(do not forget to replace CN of node-key in following commands).</p>
<pre><code class="lang-bash"><span class="hljs-comment"># Before running this script, make sure to replace the CN in the </span>
<span class="hljs-comment"># node's distinguished name with a real DNS A record.</span>
<span class="hljs-built_in">echo</span> <span class="hljs-string">"plugins.security.ssl.transport.pemcert_filepath: /etc/opensearch/node1.pem"</span> | sudo tee -a /etc/opensearch/opensearch.yml
<span class="hljs-built_in">echo</span> <span class="hljs-string">"plugins.security.ssl.transport.pemkey_filepath: /etc/opensearch/node1-key.pem"</span> | sudo tee -a /etc/opensearch/opensearch.yml
<span class="hljs-built_in">echo</span> <span class="hljs-string">"plugins.security.ssl.transport.pemtrustedcas_filepath: /etc/opensearch/root-ca.pem"</span> | sudo tee -a /etc/opensearch/opensearch.yml
<span class="hljs-built_in">echo</span> <span class="hljs-string">"plugins.security.ssl.http.enabled: true"</span> | sudo tee -a /etc/opensearch/opensearch.yml
<span class="hljs-built_in">echo</span> <span class="hljs-string">"plugins.security.ssl.http.pemcert_filepath: /etc/opensearch/node1.pem"</span> | sudo tee -a /etc/opensearch/opensearch.yml
<span class="hljs-built_in">echo</span> <span class="hljs-string">"plugins.security.ssl.http.pemkey_filepath: /etc/opensearch/node1-key.pem"</span> | sudo tee -a /etc/opensearch/opensearch.yml
<span class="hljs-built_in">echo</span> <span class="hljs-string">"plugins.security.ssl.http.pemtrustedcas_filepath: /etc/opensearch/root-ca.pem"</span> | sudo tee -a /etc/opensearch/opensearch.yml
<span class="hljs-built_in">echo</span> <span class="hljs-string">"plugins.security.allow_default_init_securityindex: true"</span> | sudo tee -a /etc/opensearch/opensearch.yml
<span class="hljs-built_in">echo</span> <span class="hljs-string">"plugins.security.authcz.admin_dn:"</span> | sudo tee -a /etc/opensearch/opensearch.yml
<span class="hljs-built_in">echo</span> <span class="hljs-string">"  - 'CN=A,OU=UNIT,O=ORG,L=TORONTO,ST=ONTARIO,C=CA'"</span> | sudo tee -a /etc/opensearch/opensearch.yml
<span class="hljs-built_in">echo</span> <span class="hljs-string">"plugins.security.nodes_dn:"</span> | sudo tee -a /etc/opensearch/opensearch.yml
<span class="hljs-built_in">echo</span> <span class="hljs-string">"  - 'CN=&lt;your_ip_addr&gt;,OU=UNIT,O=ORG,L=TORONTO,ST=ONTARIO,C=CA'"</span> | sudo tee -a /etc/opensearch/opensearch.yml
<span class="hljs-built_in">echo</span> <span class="hljs-string">"plugins.security.audit.type: internal_opensearch"</span> | sudo tee -a /etc/opensearch/opensearch.yml
<span class="hljs-built_in">echo</span> <span class="hljs-string">"plugins.security.enable_snapshot_restore_privilege: true"</span> | sudo tee -a /etc/opensearch/opensearch.yml
<span class="hljs-built_in">echo</span> <span class="hljs-string">"plugins.security.check_snapshot_restore_write_privileges: true"</span> | sudo tee -a /etc/opensearch/opensearch.yml
<span class="hljs-built_in">echo</span> <span class="hljs-string">"plugins.security.restapi.roles_enabled: [\"all_access\", \"security_rest_api_access\"]"</span> | sudo tee -a /etc/opensearch/opensearch.yml
</code></pre>
<p>f. Restart OpenSearch service.</p>
<pre><code class="lang-bash">sudo systemctl restart opensearch
</code></pre>
<p><strong>OpenSearch Dashboard</strong> : In conjunction with OpenSearch, the installation of OpenSearch Dashboards will be required. OpenSearch Dashboards is an advanced visualization tool that integrates seamlessly with OpenSearch. It enables users to explore, visualize, and analyze their data in real-time.</p>
<p>a. Download the Debian package using the following command -</p>
<pre><code class="lang-bash">wget https://artifacts.opensearch.org/releases/bundle/opensearch-dashboards/2.13.0/opensearch-dashboards-2.13.0-linux-x64.deb
</code></pre>
<p>b. After the Debian package is downloaded, install the debian package.</p>
<pre><code class="lang-bash">sudo dpkg -i opensearch-dashboards-2.13.0-linux-x64.deb
</code></pre>
<p>c. Reload systemd's configuration files to recognize any changes in service files, ensuring that the system manager is up-to-date, and then enable and start OpenSearch Dashboards service.</p>
<pre><code class="lang-bash">sudo systemctl daemon-reload
sudo systemctl <span class="hljs-built_in">enable</span> opensearch-dashboards
sudo systemctl start opensearch-dashboards
sudo systemctl status opensearch-dashboards
</code></pre>
<h3 id="heading-step-3-integration-of-wazuh-and-opensearch-using-logstash">Step 3: Integration of Wazuh and OpenSearch using Logstash.</h3>
<p>Logstash serves a crucial role in integrating Wazuh and OpenSearch by facilitating data ingestion, transformation, and forwarding. It acts as a data pipeline that collects security logs from Wazuh, processes them, and sends them to OpenSearch for storage and analysis. Logstash's installation involves adding the Elastic repository, updating package lists, and then installing Logstash, enabling seamless data flow between Wazuh and OpenSearch for enhanced security monitoring and threat detection.</p>
<p>a. Logstash Installation :</p>
<p>Firstly we will use below command to fetch the GPG key used to sign the Elastic package repositories and then the other command to pipe the output to the <code>gpg</code> command, which processes the GPG key and converts it from ASCII armor to binary format (using <code>--dearmor</code>). The resulting file is saved to <code>/usr/share/keyrings/elastic-keyring.gpg</code>, which can be used to verify the packages.</p>
<pre><code class="lang-bash">wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo gpg --dearmor -o /usr/share/keyrings/elastic-keyring.gpg
</code></pre>
<p>The below command installs the <code>apt-transport-https</code> package, which allows the <code>apt</code> package manager to retrieve packages over the secure HTTPS protocol, ensuring the integrity and security of the packages being downloaded.</p>
<pre><code class="lang-bash">sudo apt-get install apt-transport-https
</code></pre>
<p>Now, we will have to add a new source list file for the Elastic 8.x packages. It saves the repository definition to <code>/etc/apt/sources.list.d/elastic-8.x.list</code></p>
<pre><code class="lang-bash"><span class="hljs-built_in">echo</span> <span class="hljs-string">"deb [signed-by=/usr/share/keyrings/elastic-keyring.gpg] https://artifacts.elastic.co/packages/8.x/apt stable main"</span> | sudo tee -a /etc/apt/sources.list.d/elastic-8.x.list
</code></pre>
<p>The below command ensures that the system's package lists are up to date and then proceeds to install Logstash, enabling data processing and integration capabilities for various data sources, including Wazuh and OpenSearch.</p>
<pre><code class="lang-bash">sudo apt-get update &amp;&amp; sudo apt-get install logstash
</code></pre>
<p>b. Install the <code>logstash-input-opensearch</code> (reading data from OpenSearch)and <code>logstash-output-opensearch</code> (writing data to OpenSearch)plugins using the following command:</p>
<pre><code class="lang-bash">sudo /usr/share/logstash/bin/logstash-plugin install logstash-input-opensearch logstash-output-opensearch
</code></pre>
<p>c. The below commands create two directories (<code>wazuh-indexer-certs</code> and <code>opensearch-certs</code>) under <code>/etc/logstash/</code> to store the necessary root certificates securely and then copies the <code>root-ca.pem</code> certificate file from the Wazuh indexer's certificate directory (<code>/etc/wazuh-indexer/certs/</code>) to the newly created <code>wazuh-indexer-certs</code> directory in Logstash (<code>/etc/logstash/</code>) <em>(my Wazuh is installed in some other VM so i copied my root certificate file at</em><code>/home/khushi</code> )and similarly copy certificate file from the OpenSearch certificate directory (<code>/etc/opensearch/</code>) to the newly created <code>opensearch-certs</code> directory in Logstash (<code>/etc/logstash/</code>).</p>
<pre><code class="lang-bash">mkdir /etc/logstash/wazuh-indexer-certs
mkdir /etc/logstash/opensearch-certs
</code></pre>
<pre><code class="lang-bash">cp /home/khushi/root-ca.pem /etc/logstash/wazuh-indexer-certs
cp /etc/opensearch/root-ca.pem /etc/logstash/opensearch-certs
</code></pre>
<p>d. The below two commands are used to grant the Logstash user read permissions (755) for the copied Wazuh Indexer and OpenSearch root certificates. This ensures that Logstash can access and use these certificates securely for communication with the respective services.</p>
<pre><code class="lang-bash">sudo chmod -R 755  /etc/logstash/wazuh-indexer-certs/root-ca.pem
sudo chmod -R 755 /etc/logstash/opensearch-certs/root-ca.pem
</code></pre>
<p>e. The command first create directory and then fetches the specified JSON template file from the Wazuh repository and saves it as <code>wazuh.json</code> in the specified directory (<code>/etc/logstash/templates/</code>). This template is used for configuring index initialization in OpenSearch via Logstash.</p>
<pre><code class="lang-bash">mkdir /etc/logstash/templates
curl -o /etc/logstash/templates/wazuh.json https://packages.wazuh.com/integrations/opensearch/4.x-2.x/dashboards/wz-os-4.x-2.x-template.json
</code></pre>
<p>f. The below commands disable history recording temporarily, set a Logstash Keystore password in the system configuration file, and then enable history recording. Additionally, they adjust file permissions and start the Logstash service, ensuring secure password storage and service functionality.</p>
<pre><code class="lang-bash"><span class="hljs-built_in">set</span> +o <span class="hljs-built_in">history</span>
<span class="hljs-built_in">echo</span> <span class="hljs-string">'LOGSTASH_KEYSTORE_PASS="&lt;MY_KEYSTORE_PASSWORD&gt;"'</span>| sudo tee /etc/sysconfig/logstash
<span class="hljs-built_in">export</span> LOGSTASH_KEYSTORE_PASS=&lt;MY_KEYSTORE_PASSWORD&gt;
<span class="hljs-built_in">set</span> -o <span class="hljs-built_in">history</span>
sudo chown root /etc/sysconfig/logstash
sudo chmod 600 /etc/sysconfig/logstash
sudo systemctl start logstash
</code></pre>
<p>Replace "&lt;MY_KEYSTORE_PASSWORD&gt;" with the password you want to store for your Keystore.</p>
<p>g. Now we will have to securely store the credentials of the Wazuh indexer and OpenSearch in the Logstash keystore. Firstly, we will create a Logstash Keystore in the specified path :</p>
<pre><code class="lang-bash">sudo -E /usr/share/logstash/bin/logstash-keystore --path.settings /etc/logstash create
</code></pre>
<p>After entering the below commands, you will be prompted to enter your credentials of OpenSearch and Wazuh indexer in the Logstash Keystore. The credentials will not be visible as you enter them so enter them very carefully.</p>
<pre><code class="lang-bash">sudo -E /usr/share/logstash/bin/logstash-keystore --path.settings /etc/logstash add OPENSEARCH_USERNAME
sudo -E /usr/share/logstash/bin/logstash-keystore --path.settings /etc/logstash add OPENSEARCH_PASSWORD
</code></pre>
<pre><code class="lang-bash">sudo -E /usr/share/logstash/bin/logstash-keystore --path.settings /etc/logstash add WAZUH_INDEXER_USERNAME
sudo -E /usr/share/logstash/bin/logstash-keystore --path.settings /etc/logstash add WAZUH_INDEXER_PASSWORD
</code></pre>
<p>h. This command creates a new configuration file named <code>wazuh-opensearch.conf</code> in the <code>/etc/logstash/conf.d/</code> directory. It's a blank file that will be used to define Logstash parameters.</p>
<pre><code class="lang-bash">sudo touch /etc/logstash/conf.d/wazuh-opensearch.conf
</code></pre>
<p>Now open the <code>wazuh-opensearch.conf</code> file in the nano text editor using below command :</p>
<pre><code class="lang-bash">sudo nano /etc/logstash/conf.d/wazuh-opensearch.conf
</code></pre>
<p>Once the editor opens try to add following configuration and modify it with your &lt;WAZUH_INDEXER_ADDRESS&gt; and &lt;OPENSEARCH_ADDRESS&gt;. If you have set some other path to the certificate file, then make sure to replace that too.</p>
<pre><code class="lang-bash">input {
  opensearch {
   hosts =&gt;  [<span class="hljs-string">"&lt;WAZUH_INDEXER_ADDRESS&gt;:9200"</span>]
   user  =&gt;  <span class="hljs-string">"<span class="hljs-variable">${WAZUH_INDEXER_USERNAME}</span>"</span>
   password  =&gt;  <span class="hljs-string">"<span class="hljs-variable">${WAZUH_INDEXER_PASSWORD}</span>"</span>
   index =&gt;  <span class="hljs-string">"wazuh-alerts-4.x-*"</span>
   ssl =&gt; <span class="hljs-literal">true</span>
   ca_file =&gt; <span class="hljs-string">"/etc/logstash/wazuh-indexer-certs/root-ca.pem"</span>
   query =&gt;  <span class="hljs-string">'{
       "query": {
          "range": {
             "@timestamp": {
                "gt": "now-1m"
             }
          }
       }
   }'</span>
   schedule =&gt; <span class="hljs-string">"* * * * *"</span>
  }
}

output {
    opensearch {
      hosts =&gt; [<span class="hljs-string">"&lt;OPENSEARCH_ADDRESS&gt;"</span>]
      auth_type =&gt; {
         <span class="hljs-built_in">type</span> =&gt; <span class="hljs-string">'basic'</span>
         user =&gt; <span class="hljs-string">'${OPENSEARCH_USERNAME}'</span>
         password =&gt; <span class="hljs-string">'${OPENSEARCH_PASSWORD}'</span>
      }
      index  =&gt; <span class="hljs-string">"wazuh-alerts-4.x-%{+YYYY.MM.dd}"</span>
      cacert =&gt; <span class="hljs-string">"/etc/logstash/opensearch-certs/root-ca.pem"</span>
      ssl =&gt; <span class="hljs-literal">true</span>
      template =&gt; <span class="hljs-string">"/etc/logstash/templates/wazuh.json"</span>
      template_name =&gt; <span class="hljs-string">"wazuh"</span>
      template_overwrite =&gt; <span class="hljs-literal">true</span>
      legacy_template =&gt; <span class="hljs-literal">false</span>
    }
}
</code></pre>
<h3 id="heading-step-4-running-logstash">Step 4: Running Logstash .</h3>
<p>After configuring Logstash for Wazuh-OpenSearch integration, stop Logstash temporarily and then test your configuration by running Logstash from the CLI with your configuration file <code>wazuh-opensearch.conf</code> using below commands:</p>
<pre><code class="lang-bash">sudo systemctl stop logstash
sudo -E /usr/share/logstash/bin/logstash -f /etc/logstash/conf.d/wazuh-opensearch.conf --path.settings /etc/logstash/
</code></pre>
<p>Once confirmed, cancel the command and start Logstash as a service for better reliability. Enable Logstash and start the Logstash as a service using the below 2 commands. This setup ensures Logstash runs consistently and independently of the terminal's lifecycle, improving system stability and automation.</p>
<pre><code class="lang-bash">sudo systemctl <span class="hljs-built_in">enable</span> logstash
sudo systemctl start logstash
</code></pre>
<h3 id="heading-step-5-verify-the-integration">Step 5: Verify the Integration.</h3>
<p>Now in order to verify the integration, we will have to create the index pattern name for Wazuh alerts in OpenSearch Dashboards. The steps are as follows:</p>
<p>a. Go to <strong>Management</strong> in OpenSearch Dashboards by selecting the ☰ icon and then choosing <strong>Management</strong> &gt; <strong>Dashboards Management</strong>.</p>
<p>b. In the Management section, click on <strong>Index Patterns</strong> and then click on <strong>Create index pattern</strong>.</p>
<p>c. Enter <code>wazuh-alerts-*</code> as the index pattern name in the provided field.</p>
<p>d. Choose <code>timestamp</code> as the primary time field. This field will be used with the global time filter for time-based data visualization.</p>
<p>e. Click on <strong>Create index pattern</strong> to finalize and create the index pattern for Wazuh alerts.</p>
<p>f. To view and explore the data, navigate to the menu and select <strong>Discover</strong> under OpenSearch Dashboards. This will allow you to analyze and visualize the Wazuh alerts using the created index pattern.</p>
<p>By seamlessly transferring Wazuh alerts to OpenSearch, organizations can gain real-time visibility and actionable insights into security events. This integration would streamline incident detection and response, enhance data visualization capabilities, and strengthen overall security operations, leading to improved threat detection and mitigation strategies.</p>
]]></content:encoded></item></channel></rss>