<?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" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Error Insight on Medium]]></title>
        <description><![CDATA[Stories by Error Insight on Medium]]></description>
        <link>https://medium.com/@aterrorinsight?source=rss-6ef30cb4f337------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*JHKA2BLkNur5HL4uZ3Vr-A.png</url>
            <title>Stories by Error Insight on Medium</title>
            <link>https://medium.com/@aterrorinsight?source=rss-6ef30cb4f337------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 05:41:07 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@aterrorinsight/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[ELK Cluster Setup]]></title>
            <link>https://medium.com/@aterrorinsight/elk-cluster-setup-8a59b9d396fe?source=rss-6ef30cb4f337------2</link>
            <guid isPermaLink="false">https://medium.com/p/8a59b9d396fe</guid>
            <dc:creator><![CDATA[Error Insight]]></dc:creator>
            <pubDate>Fri, 12 Aug 2022 08:06:57 GMT</pubDate>
            <atom:updated>2022-08-12T08:06:57.122Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Introduction:</strong></h3><p>The <a href="https://wiki.fnis.com/display/DU/Steps+to+set+up+ELK-Stack">ELK Stack</a> is a great open-source stack for log aggregation and analytics. It stands for Elasticsearch (a NoSQL database and search server), Logstash (a log shipping and parsing service), and Kibana (a web interface that connects users with the Elasticsearch database and enables visualization and search options for system operation users).</p><p>This document has steps for setting up <strong>ElasticSearch, Logstash and Kibana In AWS platform.</strong></p><h3><strong>Prerequisite:</strong></h3><p>OS: CentOS servers.</p><p>Hardware:</p><p>instance type: t3.2xlarge</p><ul><li>Launch 3 Instances for Elastic Search in three different Availability Zone</li><li>Launch 2 Instances for Log Stash in two different Availability Zone</li><li>Launch 1 Instance for Kibana</li><li>Add below ports in the existing security group: <br> <strong>Inbound Rules:</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/778/1*qUqyUVcYrufIyCKMVH2fRw.png" /></figure><p><strong>Outbound rules :-</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/721/1*pSTq5jjF7nZDWKU13tFX6Q.png" /></figure><p><strong><em>Note</em></strong>:- Configure inbound/outbound rules according to your preference</p><h3>Install and Configure <strong>Elasticsearch</strong>:-</h3><p>Login to each Elasticsearch server and follow below steps:</p><ol><li>Set the hostname.</li></ol><p>#<strong> hostnamectl set-hostname “Server-Name”</strong></p><p>2. Create a file elastic.repo file under /etc/yum.repos.d/ folder with the following content.</p><p>#<strong> vi /etc/yum.repos.d/elastic.repo</strong></p><p>[elasticsearch-7.x]</p><p>name=Elasticsearch repository for 7.x packages</p><p>baseurl=<a href="https://artifacts.elastic.co/packages/7.x/yum">https://artifacts.elastic.co/packages/7.x/yum</a></p><p>gpgcheck=1</p><p>gpgkey=<a href="https://artifacts.elastic.co/GPG-KEY-elasticsearch">https://artifacts.elastic.co/GPG-KEY-elasticsearch</a></p><p>enabled=1</p><p>autorefresh=1</p><p>type=rpm-md</p><p>save &amp; exit the file.</p><p>3. Use below rpm command on all three servers to import Elastic’s public signing key.</p><p>#<strong> rpm — import </strong><a href="https://artifacts.elastic.co/GPG-KEY-elasticsearch"><strong>https://artifacts.elastic.co/GPG-KEY-elasticsearch</strong></a></p><p>4. Add the following lines in /etc/hosts file on all three servers</p><p><strong># vi /etc/hosts</strong></p><p>&lt;IP of ES server1&gt; &lt;Hostname of ES server1&gt;</p><p>&lt;IP of ES server2&gt; &lt;Hostname of ES server2&gt;</p><p>&lt;IP of ES server3&gt; &lt;Hostname of ES server3&gt;</p><p>5. Install Java on all three servers using yum / dnf command.</p><p># <strong>dnf install java-openjdk -y</strong></p><p>6. Install Elasticsearch using beneath dnf command on all three servers.</p><p>#<strong> dnf install elasticsearch -y</strong></p><p>7. Run below commands on all 3 servers.</p><p>#<strong>cd /usr/share/elasticsearch/bin</strong></p><p>#<strong>sudo ./elasticsearch-plugin install discovery-ec2</strong></p><p>8. Configure Elasticsearch, edit the file “/etc/elasticsearch/elasticsearch.yml” on all the three servers and add the followings.</p><p># <strong>vi /etc/elasticsearch/elasticsearch.yml</strong></p><p>…………………………………………</p><p><a href="http://cluster.name/">cluster.name</a>: elkapplicationname</p><p>network.host: &lt;Ip of current server you are in&gt;</p><p>http.port: 9200</p><p>discovery.seed_hosts: [“&lt;IP of ES server1&gt; “, “&lt;IP of ES server2&gt; “, “&lt;IP of ES server3&gt; “]</p><p>cluster.initial_master_servers: [“&lt;IP of ES server1&gt; “, “&lt;IP of ES server2&gt; “, “&lt;IP of ES server3&gt; “]</p><p>……………………………………………</p><p><strong><em>Note:</em> </strong>On Each node, add the correct current ip address in network.host parameter, all 3 ES server ip’s in discovery.seed_hosts parameter, and cluster.initial_master_servers parameter and other parameters will remain the same<strong>.</strong></p><p>9. Enable and start the Elasticsearch service on all three servers using following systemctl command.</p><p><strong># systemctl daemon-reload</strong></p><p><strong># systemctl enable elasticsearch.service</strong></p><p><strong># systemctl start elasticsearch.service</strong></p><p>10. Use below ‘ss’ command to verify whether elasticsearch node is start listening on 9200 port.</p><p># <strong>ss -tunlp | grep 9200</strong></p><p>11. Use following curl commands to verify the Elasticsearch cluster status.</p><p>#<strong>curl -X GET http://&lt; IP of ES server&gt;:9200/_cluster/health?pretty</strong></p><p>If healthy, then status will be Green and also verify no: of nodes and no: of data nodes.</p><h3>Install and Configure <strong>Logstash</strong></h3><p>Perform the following steps on both Logstash servers.</p><p>Login to both the nodes</p><ol><li>Set the hostname using following hostnamectl command.</li></ol><p># <strong>hostnamectl set-hostname “&lt;logstash servername&gt;”</strong></p><p>2. Add the following entries in /etc/hosts file in both logstash servers.</p><p>#<strong>vi /etc/hosts</strong></p><p>&lt;IP of ES server1&gt; &lt;Hostname of ES server1&gt;</p><p>&lt;IP of ES server2&gt; &lt;Hostname of ES server2&gt;</p><p>&lt;IP of ES server3&gt; &lt;Hostname of ES server3&gt;</p><p>3. Configure Logstash repository on both the nodes, create a file logstash.repo under the folder /etc/yum.repos.d/ with following content.</p><p># <strong>vi /etc/yum.repos.d/logstash.repo</strong></p><p>[elasticsearch-7.x]</p><p>name=Elasticsearch repository for 7.x packages</p><p>baseurl=<a href="https://artifacts.elastic.co/packages/7.x/yum">https://artifacts.elastic.co/packages/7.x/yum</a></p><p>gpgcheck=1</p><p>gpgkey=<a href="https://artifacts.elastic.co/GPG-KEY-elasticsearch">https://artifacts.elastic.co/GPG-KEY-elasticsearch</a></p><p>enabled=1</p><p>autorefresh=1</p><p>type=rpm-md</p><p>4. Run the following rpm command to import the signing key.</p><p>#<strong> rpm — import </strong><a href="https://artifacts.elastic.co/GPG-KEY-elasticsearch"><strong>https://artifacts.elastic.co/GPG-KEY-elasticsearch</strong></a></p><p>5. Install Java OpenJDK on both the nodes using following dnf command.</p><p># <strong>dnf install java-openjdk -y</strong></p><p>6. Run the following dnf command from both the nodes to install logstash.</p><p># <strong>dnf install logstash -y</strong></p><p>7. Create a logstash conf file, for that first we have copy sample logstash file under ‘/etc/logstash/conf.d/</p><p># <strong>cd /etc/logstash/</strong></p><p># <strong>cp logstash-sample.conf conf.d/logstash.conf</strong></p><p>8. Edit conf file and update the following content.</p><p>#<strong> vi conf.d/logstash.conf</strong></p><p>input {</p><p>beats {</p><p>port =&gt; 5044</p><p>}</p><p>}</p><p>output {</p><p>elasticsearch {</p><p>hosts =&gt; [“http:// &lt;IP of ES server1&gt;:9200”, “http:// &lt;IP of ES server2&gt;:9200”, “http:// &lt;IP of ES server3&gt;:9200”]</p><p>index =&gt; “%{[@metadata][beat]}-%{[@metadata][version]}-%{+YYYY.MM.dd}”</p><p>#user =&gt; “elastic”</p><p>#password =&gt; “changeme”</p><p>}</p><p>}</p><p><strong><em>Note:</em> </strong>Under output section, in hosts parameter specify FQDN of all three Elasticsearch nodes, other parameters leave as it is.</p><p>9. Now enable and start Logstash service, run the following systemctl commands on both the nodes.</p><p>#<strong> systemctl eanble logstash</strong></p><p># <strong>systemctl start logstash</strong></p><p>10. Use below ss command to verify whether logstash service start listening on 5044.</p><p><strong># ss -tunlp | grep 5044</strong></p><h3><strong>Install and Configure Kibana:</strong></h3><ol><li>Login to Kibana node, set the hostname with hostnamectl command.</li></ol><p># <strong>hostnamectl set-hostname “kibana”</strong></p><p>2. Edit /etc/hosts file and add the following lines.</p><p>&lt;IP of ES server1&gt; &lt;Hostname of ES server1&gt;</p><p>&lt;IP of ES server2&gt; &lt;Hostname of ES server2&gt;</p><p>&lt;IP of ES server3&gt; &lt;Hostname of ES server3&gt;</p><p>3. Setup the Kibana repository using following.</p><p>#<strong> vi /etc/yum.repos.d/kibana.repo</strong></p><p>Create this file and paste below contents in it.</p><p>[elasticsearch-7.x]</p><p>name=Elasticsearch repository for 7.x packages</p><p>baseurl=<a href="https://artifacts.elastic.co/packages/7.x/yum">https://artifacts.elastic.co/packages/7.x/yum</a></p><p>gpgcheck=1</p><p>gpgkey=<a href="https://artifacts.elastic.co/GPG-KEY-elasticsearch">https://artifacts.elastic.co/GPG-KEY-elasticsearch</a></p><p>enabled=1</p><p>autorefresh=1</p><p>type=rpm-md</p><p>Then run this command.</p><p># <strong>rpm — import </strong><a href="https://artifacts.elastic.co/GPG-KEY-elasticsearch"><strong>https://artifacts.elastic.co/GPG-KEY-elasticsearch</strong></a></p><p>4. Execute below dnf command to install kibana.</p><p>#<strong> yum install kibana -y</strong></p><p>5. Configure Kibana by editing the file “/etc/kibana/kibana.yml”.</p><p># <strong>vim /etc/kibana/kibana.yml</strong></p><p>…………</p><p>server.host: “kibana”</p><p><a href="http://server.name/">server.name</a>: “kibana”</p><p>elasticsearch.hosts: [“http:// &lt;IP of ES server1&gt;:”, “http:// &lt;IP of ES server2&gt;:9200”, “http:// &lt;IP of ES server3&gt;:9200”]</p><p>…………</p><p><strong>Note:</strong></p><p>Update server.host, <a href="http://server.name/">server.name</a> parameters with Kibana server host and name and in elasticsearch.hosts parameter specify FQDN of all three Elasticsearch nodes.</p><p>If port is commented, then uncomment it.</p><p>6. Enable and start kibana service.</p><p><strong># systemctl enable kibana</strong></p><p><strong># systemctl start kibana</strong></p><p>7. Access Kibana portal / GUI using the following URL:</p><p><a href="http://kibana:5601/"><strong><em>http://&lt;kibana-server-ip&gt;:5601</em></strong></a></p><h3><strong>Basic Authentication in ELK</strong></h3><p><strong>Login into all 3 Elastic search instances as a root user and run below 5 steps on them.</strong></p><p>1. Edit elasticsearch.yaml file append these 5 lines in that file as below</p><p><strong>#vi /etc/elasticsearch/elasticsearch.yml</strong></p><p>xpack.security.enabled: true #It enables security, transport TLS/SSL must also be enable<br> xpack.security.transport.ssl.enabled: true #ssl enabled<br> xpack.security.transport.ssl.verification_mode: certificate #changes verification mode to certificate<br> xpack.security.transport.ssl.keystore.path: elastic-certificates.p12 <br> xpack.security.transport.ssl.truststore.path: elastic-certificates.p12</p><p>2. Generate below certificates in /usr/share/elasticsearch/bin directory in any one server and then copy generated certificates to a /etc/elasticsearch directory in all the 3 nodes.</p><p><strong>cd /usr/share/elasticsearch/bin</strong></p><p><strong># ./elasticsearch-certutil ca<br> # ./elasticsearch-certutil cert — ca elastic-stack-ca.p12</strong></p><p><strong># chmod 755 elastic-certificates.p12</strong></p><p><strong># scp i &lt;pem-key&gt; elastic-certificates.p12 </strong><a href="/service/mailto:centos@10.43.48.40"><strong>centos@</strong></a><strong>&lt;ES-server-ip&gt;:/home/centos/</strong></p><p><strong># cp elastic-certificates.p12 /etc/elasticsearch</strong></p><p>3. Update password in keystore on all 3 nodes:</p><p><strong># cd /usr/share/elasticsearch/bin</strong></p><p><strong># ./elasticsearch-keystore add xpack.security.transport.ssl.keystore.secure_password<br> # ./elasticsearch-keystore add xpack.security.transport.ssl.truststore.secure_password</strong></p><p>4. Restart es on all 3 nodes</p><p><strong># systemctl stop elasticsearch.service<br> # systemctl start elasticsearch.service<br> # systemctl status elasticsearch.service</strong> # check status.</p><p>5. Gererate password for inbuilt users:</p><p><strong># ./elasticsearch-setup-passwords auto # generates updated password for user elastic, kibana, kibana_system, logstash_system, beats_system, apm_system and remote_monitoring_user.</strong></p><p><strong>Log into Kibana server as a root user and add Kibana user and password in kibana.yaml file generated for kibana user from previous step.</strong></p><p><strong># vi /etc/kibana/kibana.yml</strong></p><p>elasticsearch.username: “kibana”</p><p>elasticsearch.password: “kibana-password” # update kibana-password with password for kibana usergenerated in step 4.5</p><p>Then restart the kibana service:</p><p><strong># service kibana stop</strong></p><p><strong># service kibana start</strong></p><p><strong># service kibana status</strong></p><p>Try accessing kibana UI using elastic as user and its corresponding password generated in step5.</p><p><strong>http://&lt;kibana-server-ip&gt;:5601</strong> # access using elastic user credentials</p><p><strong>Log into 2 Logstash servers as a root user.</strong></p><p>Update the elastic user and its respective password generated in step 4.5 in logstash.conf file under output section:</p><p><strong># cd /etc/logstash/conf.d</strong></p><p><strong># vi logstash.conf</strong></p><p>user =&gt; “elastic”</p><p>password =&gt; “elastic-password”</p><p>Restart the logstash service.</p><p><strong>#systemctl stop logstash<br> #systemctl start logstash<br> #systemctl status logstash</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8a59b9d396fe" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>