<?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 Mehran Kader on Medium]]></title>
        <description><![CDATA[Stories by Mehran Kader on Medium]]></description>
        <link>https://medium.com/@kmehran.1106?source=rss-1b7be521d12c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*hXh7AZ10czPcqmyw3A_Iuw.jpeg</url>
            <title>Stories by Mehran Kader on Medium</title>
            <link>https://medium.com/@kmehran.1106?source=rss-1b7be521d12c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 22:15:47 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kmehran.1106/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[A simple guide to use PostgreSQL]]></title>
            <link>https://medium.com/misfit-technologies/a-simple-guide-to-use-postgresql-d3e457d12714?source=rss-1b7be521d12c------2</link>
            <guid isPermaLink="false">https://medium.com/p/d3e457d12714</guid>
            <category><![CDATA[relational-databases]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[postgresql]]></category>
            <category><![CDATA[postgres]]></category>
            <dc:creator><![CDATA[Mehran Kader]]></dc:creator>
            <pubDate>Wed, 29 Jul 2020 17:34:48 GMT</pubDate>
            <atom:updated>2020-07-29T17:34:48.459Z</atom:updated>
            <content:encoded><![CDATA[<p>I’ve been working with PostgreSQL for the last year, and the experience has honestly been amazing. However, every time I wanted to setup PostgreSQL on a machine, it was like trying to move through a labyrinth of blogs, documentations etc. I actually started using docker to run PostgreSQL in my mac, just to avoid the whole ordeal of navigating through psql and the Postgres command shell utilities.</p><p>Now, if you want to use docker for this, it’s as simple as the running the following command.</p><pre>docker run --name &lt;container-name&gt; \<br>-e POSTGRES_PASSWORD=&lt;password&gt; \ <br>-e POSTGRES_USER=&lt;username&gt; \<br>-d &lt;database name&gt;</pre><p>However, sometimes installing docker just for a simple project might seem overwhelming. In which case, depending on your choice of OS, you might need to follow different steps. Here, I’ll be discussing how to install PostgreSQL on Ubuntu and MacOS. Now, there are lots of ways to do this, apart from the methods I will mention below, and feel free to follow any of them. These methods have worked for me with consistency, and I personally haven’t faced any major problems.</p><h3>Installing on MacOS</h3><p>For MacOS, we’ll be using the homebrew package manager. If you haven’t installed it yet, run the following command to get it.</p><pre>/usr/bin/ruby -e &quot;$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)&quot;</pre><p>Now, use the following command to download and start PostgreSQL.</p><pre>brew update &amp;&amp; brew install postgresql<br>brew services start postgresql<br>postgres -V</pre><p>So, now we have installed PostgreSQL on MacOS! However, we need to do a few more things to start using PostgreSQL properly, like creating a user, creating a database etc. We’ll get to that in a minute, let’s first wrap up on how to install PostgreSQL in Ubuntu.</p><h3>Installing on Ubuntu</h3><p>Even though I say Ubuntu, this should work on any Debian/Ubuntu based distributions as is. However, if you are using anything other than Ubuntu, I would suggest to reference another blog or article where the distribution/os you use has been worked with.</p><pre>sudo apt-get install wget ca-certificates</pre><pre>wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -</pre><pre>sudo sh -c &#39;echo &quot;deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main&quot; &gt;&gt; /etc/apt/sources.list.d/pgdg.list&#39;</pre><pre>sudo apt-get update</pre><pre>sudo apt-get install postgresql postgresql-contrib</pre><h3>Using PostgreSQL After Setup</h3><p>If you’re on a linux system, postgres will create a system user postgres, and you will need that user to use postgres. It can be done simply by switching from your current user using</p><pre>sudo su - postgres</pre><p>Now, to login to the PostgreSQL shell (also known as psql), you need to run the following command.</p><pre>psql</pre><p>And that’s it! You’ll be logged into psql and you can now do the basic things to start. First, I would suggest creating a new superuser using the command</p><pre>CREATE ROLE &lt;username&gt; WITH SUPERUSER CREATEDB CREATEROLE LOGIN ENCRYPTED PASSWORD &#39;&lt;password&gt;&#39;;</pre><p>This will create the user with your given username and password. Now, you can login to psql with this user using the command</p><pre>psql postgres -U &lt;username&gt;</pre><p>Before we go any further, I think it’s prudent to mention a couple of things. Firstly, to login using psql, if you don’t give any extra parameters, psql will connect with the default database postgres with the default user. The default user will be postgres for Linux and your username of you MacOS. If you want to login using a specific user, you have to provide the database as well.</p><p>Now, I’ll mention a few commands which usually gets the starting done.</p><pre># to create a database<br>CREATE DATABASE &lt;database name&gt;;</pre><pre># to access a database using a specific user<br>GRANT ALL PRIVILEGES ON DATABASE &lt;database name&gt; TO &lt;username&gt;;</pre><pre># change user password. note that you cannot change the password of # the user you are currently logged into <br>ALTER USER &lt;username&gt; WITH ENCRYPTED PASSWORD &#39;&lt;password&gt;&#39;;</pre><h3>References and Credits</h3><p>The following blogs and sites have been quite helpful for installing and working with PostgreSQL.</p><ol><li><a href="https://www.codementor.io/@engineerapart/getting-started-with-postgresql-on-mac-osx-are8jcopb">Getting Started with PostgreSQL on Mac OSX</a></li><li><a href="https://computingforgeeks.com/install-postgresql-11-on-ubuntu-linux/">Install PostgreSQL 11 on Ubuntu 20.04/18.04/16.04</a></li><li><a href="http://Creating user, database and adding access on PostgreSQL">Creating user, database and adding access on PostgreSQL</a></li><li><a href="http://devopspy.com/linux/allow-remote-connections-postgresql/">Allow remote connections to PostgreSQL</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d3e457d12714" width="1" height="1" alt=""><hr><p><a href="https://medium.com/misfit-technologies/a-simple-guide-to-use-postgresql-d3e457d12714">A simple guide to use PostgreSQL</a> was originally published in <a href="https://medium.com/misfit-technologies">Misfit Technologies</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Connecting to a Serverless Aurora Database locally]]></title>
            <link>https://medium.com/misfit-technologies/connecting-to-a-serverless-aurora-database-locally-cd479cd5aa42?source=rss-1b7be521d12c------2</link>
            <guid isPermaLink="false">https://medium.com/p/cd479cd5aa42</guid>
            <category><![CDATA[rds]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[serverless]]></category>
            <dc:creator><![CDATA[Mehran Kader]]></dc:creator>
            <pubDate>Tue, 28 May 2019 05:54:21 GMT</pubDate>
            <atom:updated>2019-05-28T05:56:50.386Z</atom:updated>
            <content:encoded><![CDATA[<p>I have recently been poking around the Serverless tools that AWS provide, and wanted to setup Serverless Relational Database for a project. When setting up a normal RDS Database I was able to connect to it directly from my local PC using SequelPro using the hostname provided by AWS (along with the credentials I set up). However, that was about to change for the Serverless aurora instance, since the Serverless DB instance is hosted in a VPC without external internet access!</p><p>At first, I followed the documentations of AWS <a href="https://aws.amazon.com/getting-started/tutorials/configure-connect-serverless-mysql-database-aurora/">https://aws.amazon.com/getting-started/tutorials/configure-connect-serverless-mysql-database-aurora/</a> to setup my Serverless Aurora Instance on a separate VPC, and created a new EC2 instance which I also hosted on the same VPC. This allowed me to connect to my database from inside my EC2 instance (the AWS documentation covers to process quite nicely!). However, this did not allow me to view the database as easily using SequelPro. I heard from my mentor that I could connect to the Database by doing an SSH!</p><p>In the quick connect wizard for SequelPro there is a tab SSH, where I input the following configurations.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/946/1*adct5c_xKQpqlUcdRdUOMA.png" /><figcaption>SSH Configuration</figcaption></figure><p>In the SSH Password field I linked the .pem file used to connect to the EC2 instance. And that was it! Understand this however, for the SSH to succeed you must be able to connect to the Serverless Aurora Instance from the EC2 instance, otherwise this configuration won’t work.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cd479cd5aa42" width="1" height="1" alt=""><hr><p><a href="https://medium.com/misfit-technologies/connecting-to-a-serverless-aurora-database-locally-cd479cd5aa42">Connecting to a Serverless Aurora Database locally</a> was originally published in <a href="https://medium.com/misfit-technologies">Misfit Technologies</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Setting up a ubuntu 16.04 production server for a basic django app using nginx and gunicorn]]></title>
            <link>https://medium.com/misfit-technologies/setting-up-a-ubuntu-16-04-production-server-for-a-basic-django-app-using-nginx-and-gunicorn-d8abe6e04520?source=rss-1b7be521d12c------2</link>
            <guid isPermaLink="false">https://medium.com/p/d8abe6e04520</guid>
            <category><![CDATA[nginx]]></category>
            <category><![CDATA[ubuntu-server]]></category>
            <category><![CDATA[django]]></category>
            <dc:creator><![CDATA[Mehran Kader]]></dc:creator>
            <pubDate>Tue, 18 Sep 2018 17:25:57 GMT</pubDate>
            <atom:updated>2018-09-18T17:29:28.161Z</atom:updated>
            <content:encoded><![CDATA[<p>Django is a powerful web framework for python that can quickly get an application or website up and running! Django includes a basic development server to test the code locally, but for anything production related a more secure and powerful server will be required. In this case, we will be using an Ubuntu 16.04 server hosted on the cloud (e.g. AWS or DigitalOcean). We will need to setup Gunicorn as our application server and connect Nginx to reverse-proxy the gunicorn server. So, let’s move forward!</p><p><strong>Installing Nginx</strong></p><p>We can easily install nginx using the debian package manager using the following commands.</p><pre>sudo apt-get install nginx<br>sudo systemctl enable nginx<br>sudo systemctl start nginx</pre><p>Now, to check if nginx was installed properly, we would need to configure nginx so that our server is connected to the internet. For a basic setup, we can follow the basic steps.</p><pre>sudo nano /etc/nginx/sites-available/default</pre><pre>In the configuration file, there is a parameter within server, server_name. We need to put the IP address of our cloud server there, and easily check if the server is connected or not!</pre><pre>server {<br>    listen 80;<br>    server_name &lt;server_ip&gt;;<br>    ...<br>    ...<br>}</pre><pre>After this, run the following command.<br>sudo ln -s /etc/nginx/sites-available/default /etc/nginx/sites-enabled</pre><pre>Then we will restart our nginx server.<br>sudo systemctl restart nginx</pre><p>Now, if we type our browsers IP address in our browser, we will see a static template being served which is a default of nginx! But setting up our project so that it can be served by nginx, will be a slightly more complicated process, which we will be covering as well. So, let’s get going!</p><p><strong>Setting up our project</strong></p><p>The default nginx path is /var/www/html, and we will also be setting up our django project there. For that, we will need to give a few permissions to our user.</p><pre>sudo usermod -a -G www-data &lt;username default is ubuntu&gt;<br>sudo chown -R &lt;username default is ubuntu&gt;:www-data /var/www<br>sudo chmod 2775 /var/www<br>find /var/www -type d -exec sudo chmod 2775 {} +<br>find /var/www -type f -exec sudo chmod 0664 {} +</pre><p>Now that we have the necessary permissions, we will remove the directory /var/www/html and create a new folder within which we will hold our django project, virtual environment and environment variables. For convention, we will create the new empty directory as html within /var/www.<br>Then, we will go inside /var/www/html and clone our git repository which contains our project within this folder directly. That means, /var/www/html will act as the BASE_DIR of our django project.<br>Now, we need to install our required python packages, and this must be done in a virtual environment so as to not contaminate the server’s default python. We will be doing this using the python package manager pip for python3.</p><pre>sudo apt install python3-pip<br>sudo pip3 install virtualenv<br>virtualenv -p python3 venv # install it inside /var/www/html<br>sudo apt-get install python-dev python3-dev</pre><pre>Activate virtualenv from within /var/www/html using the command.<br>source venv/bin/activate<br>Then we will install the requirements for our project, and install gunicorn which is the key to running our application as a service within the server spontaneously.</pre><p>After setting up our project, we will need to configure a gunicorn service for our server.</p><p>Configuring Gunicorn</p><p>To configure gunicorn as a service, we will need to write a .service file within ubuntu’s system.</p><pre>sudo nano /etc/systemd/system/gunicorn.service</pre><p>Here, we will write a .service script to run gunicorn and create a .sock file within our project root directory. This .sock file will be accessed by Nginx to serve our application to the internet. A demo .service file:<br>File name: gunicorn.service -&gt; This is also the name through which the gunicorn will be enabled as a service.</p><pre>[Unit]<br>Description=gunicorn daemon<br>After=network.target</pre><pre>[Service]<br>User=ubuntu<br>Group=www-data<br>WorkingDirectory=/var/www/html</pre><pre>ExecStart=/var/www/html/venv/bin/gunicorn --workers &lt;num_workers&gt; --bind unix:/var/www/html/&lt;project_root&gt;/&lt;project_root&gt;.sock &lt;project_root&gt;.wsgi:application</pre><pre>[Install]<br>WantedBy=multi-user.target</pre><p>After this, we need to enable and start gunicorn as a service using the following commands.</p><pre>sudo systemctl enable gunicorn.service<br>sudo systemctl start gunicorn.service</pre><p>Now, we need to properly configure nginx. As we said before, nginx will be reverse proxying the gunicorn application server through the .sock file in the project root. This can be done by setting the location parameter within the nginx script. A basic demo nginx configuration:</p><pre>server {<br>    listen 80;<br>    server_name &lt;server_ip&gt;;</pre><pre>    location /static/ {<br>        autoindex on;<br>        alias /var/www/html/static/;<br>        expires 1M;<br>        access_log off;<br>        add_header Cache-Control &quot;public&quot;;<br>        proxy_ignore_headers &quot;Set-Cookie&quot;;<br>    }<br>    <br>    location / {<br>        include proxy_params;<br>        proxy_pass <a href="http://unix/var/www/html/%3Cproject_root%3E">http://unix:/var/www/html/&lt;project_root&gt;</a>/&lt;project_root_socket_gunicorn&gt;.sock;<br>    }<br>}</pre><p>Now, after we restart gunicorn and nginx, and provided that we have set up our project appropriately (setting up environment variables, adding the server IP address in ALLOWED_HOST etc.) we will be able to visit our django powered website using our server IP address!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d8abe6e04520" width="1" height="1" alt=""><hr><p><a href="https://medium.com/misfit-technologies/setting-up-a-ubuntu-16-04-production-server-for-a-basic-django-app-using-nginx-and-gunicorn-d8abe6e04520">Setting up a ubuntu 16.04 production server for a basic django app using nginx and gunicorn</a> was originally published in <a href="https://medium.com/misfit-technologies">Misfit Technologies</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Installing the ELK-stack on Ubuntu 16.04 and understanding its services]]></title>
            <link>https://medium.com/misfit-technologies/installing-the-elk-stack-on-ubuntu-16-04-and-understanding-its-services-bc3b88717a5f?source=rss-1b7be521d12c------2</link>
            <guid isPermaLink="false">https://medium.com/p/bc3b88717a5f</guid>
            <category><![CDATA[elk-stack]]></category>
            <category><![CDATA[ubuntu]]></category>
            <dc:creator><![CDATA[Mehran Kader]]></dc:creator>
            <pubDate>Mon, 27 Aug 2018 16:16:34 GMT</pubDate>
            <atom:updated>2018-08-27T16:16:34.770Z</atom:updated>
            <content:encoded><![CDATA[<p>There have been quite a few blog posts on installing and configuring the ELK stack, which were very helpful when I was trying to understand how to setup the ELK stack on a production server for the first time. In this article I’m going to be focusing on some of the challenges I faced while installing ELK-stack and how I set up ELK-stack and some of it other services (beats, elastic-apm and x-pack).</p><p><strong>Preparing the system<br></strong>Before installing the ELK-stack on any server instance, always check the RAM available to the server. The ELK stack will take up at least 2GB of RAM, so make sure your instance was created with 2GB of RAM. <br>Then, prepare the system by installing java 8. Do note, that the openjdk version must be 1.8.* for the ELK-stack to install properly. If the version is 1.9.* you will be facing problems! Install java using the commands</p><pre><strong>sudo add-apt-repository ppa:webupd8team/java <br></strong><strong>sudo apt install oracle-java8-installer </strong></pre><p>To check the version, run the command</p><pre><strong>java -version<br></strong>The result would be something like this.<strong><br></strong><strong>java version “1.8.0_162”<br>Java(TM) SE Runtime Environment (build 1.8.0_162-b12)<br>Java HotSpot(TM) 64-Bit Server VM (build 25.162-b12, mixed mode)</strong> </pre><p>If however you have installed some other version of java, that can be rectified by removing java from your system by using the command <br><strong>sudo apt-get autoremove openjdk-&lt;version&gt;-jre</strong> <br>where version is <strong>java version “1.&lt;version&gt;.0_162”</strong> from above.</p><p><strong>Installing ElasticSearch</strong><br>Here, we’ll be installing ElasticSearch using the deb package repository system. In this article, I’ll only show the commands required to install elasticsearch. If you want to know the details, please visit<br><a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/deb.html">https://www.elastic.co/guide/en/elasticsearch/reference/current/deb.html</a></p><pre> &gt; <strong>wget -qO — </strong><a href="https://artifacts.elastic.co/GPG-KEY-elasticsearch"><strong>https://artifacts.elastic.co/GPG-KEY-elasticsearch</strong></a><strong> | sudo apt-key add -</strong><br> &gt; <strong>sudo apt-get install apt-transport-https</strong><br> &gt; <strong>echo “deb </strong><a href="https://artifacts.elastic.co/packages/6.x/apt"><strong>https://artifacts.elastic.co/packages/6.x/apt</strong></a><strong> stable main” | sudo tee -a /etc/apt/sources.list.d/elastic-6.x.list</strong><br> &gt; <strong>sudo apt-get update &amp;&amp; sudo apt-get install elasticsearch</strong><br> &gt; <strong>sudo nano /etc/elasticsearch/elasticsearch.yml and configure elasticsearch</strong><br> &gt; <strong>sudo systemctl enable elasticsearch.service</strong><br> &gt; <strong>sudo systemctl start elasticsearch.service <br></strong>To check if elasticsearch was installed correctly, just enter the following curl command. <br><strong>curl -X GET “localhost:9200/” <br></strong>This will give a response like this.<br><strong>{<br>  &quot;name&quot; : &quot;Cp8oag6&quot;,<br>  &quot;cluster_name&quot; : &quot;elasticsearch&quot;,<br>  &quot;cluster_uuid&quot; : &quot;AT69_T_DTp-1qgIJlatQqA&quot;,<br>  &quot;version&quot; : {<br>    &quot;number&quot; : &quot;6.4.0&quot;,<br>    &quot;build_flavor&quot; : &quot;default&quot;,<br>    &quot;build_type&quot; : &quot;zip&quot;,<br>    &quot;build_hash&quot; : &quot;f27399d&quot;,<br>    &quot;build_date&quot; : &quot;2016-03-30T09:51:41.449Z&quot;,<br>    &quot;build_snapshot&quot; : false,<br>    &quot;lucene_version&quot; : &quot;7.4.0&quot;,<br>    &quot;minimum_wire_compatibility_version&quot; : &quot;1.2.3&quot;,<br>    &quot;minimum_index_compatibility_version&quot; : &quot;1.2.3&quot;<br>  },<br>  &quot;tagline&quot; : &quot;You Know, for Search&quot;<br>}</strong></pre><p>Also, remember to properly setup the proxy server you’re using(nginx or apache), so that the instance is accessible from other servers!</p><p><strong>Installing Kibana<br></strong>To install kibana, run the following commands. For more details, visit <a href="https://www.elastic.co/guide/en/kibana/current/deb.html">https://www.elastic.co/guide/en/kibana/current/deb.html</a></p><pre><strong>&gt; wget -qO - </strong><a href="https://artifacts.elastic.co/GPG-KEY-elasticsearch"><strong>https://artifacts.elastic.co/GPG-KEY-elasticsearch</strong></a><strong> | sudo apt-key add -  <br>&gt; sudo apt-get install apt-transport-https <br>&gt; echo &quot;deb </strong><a href="https://artifacts.elastic.co/packages/6.x/apt"><strong>https://artifacts.elastic.co/packages/6.x/apt</strong></a><strong> stable main&quot; | sudo tee -a /etc/apt/sources.list.d/elastic-6.x.list <br>&gt; sudo apt-get update &amp;&amp; sudo apt-get install kibana <br>&gt; sudo systemctl daemon-reload <br>&gt; sudo systemctl enable kibana.service</strong></pre><p><strong>Configuring Kibana</strong><br>The path of the kibana conf file is <em>/etc/kibana/kibana.yml</em> (N.B. The conf file may be located in other places for other OS).<br>For a minimal setup, we need to set the following parameters.</p><pre>server.port: 5601<br>server.host: 0.0.0.0 # so that kibana can be accessed from outside<br>elasticsearch.url: &quot;<a href="http://localhost:9200/">http://localhost:9200</a>&quot;</pre><p>This should be enough to get your kibana up and running!</p><p><strong>Understanding the ELK-stack</strong><br>Before installing Logstash, let us give an in general description of how the ELK-stack works. Firstly, ElasticSearch is similar to a noSQL database where data is stored in indices defined in Elastic. We can see the indices in Index Patterns sections of Kibana -&gt; Management. Using logstash, we can collect, parse and store logs in Elastic, and see the logs using Kibana. Kibana also provides many visualization tools for graphs and charts. In this case, the kibana end-point should be made open and protected via XPack (authentication by username and password), or made accessible only from specific IP addresses. The logstash endpoint should either be kept open or secured via ssl using XPack or only be accessed from specific ips. Thus, the basic structure of a distributed system would be to send logs from your project to logstash. In my case, I used beats to send my project logs along with some system logs. To collect and store these logs, I defined a .conf file for logstash which accepted beats inputs and sent the input to Elastic after parsing. Now, let us setup Logstash :)</p><p><strong>Installing Logstash</strong></p><pre><strong> &gt; wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -<br> &gt; sudo apt-get install apt-transport-https<br> &gt; echo &quot;deb https://artifacts.elastic.co/packages/6.x/apt stable main&quot; | sudo tee -a /etc/apt/sources.list.d/elastic-6.x.list<br> &gt; sudo apt-get update &amp;&amp; sudo apt-get install logstash<br> &gt; sudo systemctl enable logstash<br> &gt; sudo systemctl start logstash</strong><br> <br>Then go to the path <em>/etc/logstash/conf.d </em>and write a conf file which will define which inputs to parse, and where to write them.</pre><pre>Sample beats conf file.<br><strong>input {<br>    beats {<br>        port =&gt; &quot;XXXX&quot;<br>   }<br>}</strong></pre><pre><strong>filter {<br>    grok {<br>        match =&gt; { &quot;source&quot; =&gt; &quot;%{GREEDYDATA}/%{GREEDYDATA:app}.log&quot; }<br>    }<br>}</strong></pre><pre><strong>output {<br>    elasticsearch {<br>        hosts =&gt; [&quot;localhost:9200&quot;]<br>        sniffing =&gt; true<br>        manage_template =&gt; false<br>        index =&gt; &quot;%{[</strong><a href="http://twitter.com/metadata"><strong>@metadata</strong></a><strong>][beat]}-%{[</strong><a href="http://twitter.com/metadata"><strong>@metadata</strong></a><strong>][version]}-%{+YYYY.MM.dd}&quot;<br>        document_type =&gt; &quot;%{[</strong><a href="http://twitter.com/metadata"><strong>@metadata</strong></a><strong>][type]}&quot;<br>        user =&gt; &quot;username&quot; # if elasticsearch is secured via xpack<br>        password =&gt; &quot;password&quot; # &quot;&quot;&quot;<br>    }<br>}</strong></pre><p>Et voila! You have successfully configured logstash to accept input from beats, which will write the log into elasticsearch server and can be visualized from kibana. Before this however, please restart logstash and kibana services!</p><pre><strong>sudo systemctl restart kibana<br>sudo systemctl restart logstash</strong></pre><p><strong>Knowing Filebeats<br></strong>Filebeat is a lightweight shipper for forwarding and centralizing log data. It was installed in our project server (which is separate from logstash), Filebeat monitors the paths that we specified, and forwarded them to Logstash for parsing and passing to Elastic for indexing. Installing and setting up filebeats is relatively simple, just follow the instructions from here!<br><a href="https://www.elastic.co/guide/en/beats/filebeat/current/setup-repositories.html">https://www.elastic.co/guide/en/beats/filebeat/current/setup-repositories.html</a><br>Configure filebeats from the following links!</p><pre><a href="https://www.elastic.co/guide/en/beats/filebeat/current/filebeat-configuration.html">https://www.elastic.co/guide/en/beats/filebeat/current/filebeat-configuration.html</a><br><a href="https://www.elastic.co/guide/en/beats/filebeat/current/config-filebeat-logstash.html">https://www.elastic.co/guide/en/beats/filebeat/current/config-filebeat-logstash.html</a><br><a href="https://www.elastic.co/guide/en/beats/filebeat/current/filebeat-starting.html">https://www.elastic.co/guide/en/beats/filebeat/current/filebeat-starting.html</a></pre><p><strong>Securing ELK-stack via XPack<br></strong>The complete setup of XPack will be better described by the official documentation compared to whatever I might write. <a href="https://www.elastic.co/guide/en/x-pack/current/installing-xpack.html">https://www.elastic.co/guide/en/x-pack/current/installing-xpack.html</a><br>Securing ElasticSearch and Kibana is pretty straightforward.</p><pre><strong>&gt; sudo /usr/share/elasticsearch/bin/elasticsearch-plugin install x-pack<br>&gt; sudo /usr/share/elasticsearch/bin/x-pack/setup-passwords auto|interactive<br>&gt; sudo /usr/share/kibana/bin/kibana-plugin install x-pack<br></strong>Configure<strong> </strong>/etc/kibana/kibana.yml to add elasticsearch.username and <br>elasticsearch.password that you have recently setup.</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bc3b88717a5f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/misfit-technologies/installing-the-elk-stack-on-ubuntu-16-04-and-understanding-its-services-bc3b88717a5f">Installing the ELK-stack on Ubuntu 16.04 and understanding its services</a> was originally published in <a href="https://medium.com/misfit-technologies">Misfit Technologies</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>