<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.itcollege.ee/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Mdhasan</id>
	<title>ICO wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.itcollege.ee/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Mdhasan"/>
	<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php/Special:Contributions/Mdhasan"/>
	<updated>2026-05-05T22:03:53Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123823</id>
		<title>Logging and monitoring with Elastic stack on Ubuntu 16.04</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123823"/>
		<updated>2017-06-21T22:47:27Z</updated>

		<summary type="html">&lt;p&gt;Mdhasan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
Logging and monitoring of IT systems is very important part of information security. Proper system logs and monitoring can prevent cyber attacks or service failure. In this wiki we will learn how configure logging and monitoring with ELK stack in Ubuntu server 16.04 and the alternatives of ELK stack Graylogs.      &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Elasticsearch&#039;&#039;&#039; is an open source search engine based on Lucene, developed in java. It provides a distributed and multitenant [https://en.wikipedia.org/wiki/Full-text_search full-text search engine] with an HTTP Dashboard web-interface (Kibana) and JSON documents scheme. Elasticsearch is a scalable search engine that can be used to search for all types of documents, including log file. Elasticsearch is the heart of the &#039;Elastic Stack&#039; or ELK Stack.&amp;lt;ref&amp;gt;[https://www.elastic.co/products/elasticsearch] Elastic Search Homepage&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Logstash&#039;&#039;&#039; is an open source, server-side data processing pipeline that ingests data from a multitude of sources simultaneously, transforms it, and then sends it to Elasticsearch.&amp;lt;ref&amp;gt;[https://www.elastic.co/products/logstash] Logstash homepage&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Kibana&#039;&#039;&#039; is a data visualization interface for Elasticsearch. Kibana provides a pretty dashboard (web interfaces), it allows you to manage and visualize all data from Elasticsearch on your own. &amp;lt;ref&amp;gt;[https://www.elastic.co/products/kibana] kibana homepage&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Prerequisite ==&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit server with 4GB of RAM, hostname - elk-master&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit client with 1 GB of RAM, hostname - elk-client&lt;br /&gt;
&lt;br /&gt;
Following installation steps from 1 to 4 is collected from &lt;br /&gt;
&lt;br /&gt;
[http://www.howtoforge.com HowToFroge.com]&amp;lt;ref&amp;gt;[http://thehackernews.com/2013/10/importance-of-logs-and-log-management.html]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Virtual Box setup ==&lt;br /&gt;
&lt;br /&gt;
As we are going to use Ubuntu server 16.04, which has no Graphical user interface (GUI). It is better to add a GUI client to Ubuntu server and ssh to virtual box setup. Here I will show to how to connect to Ubuntu server from a Ubuntu desktop client via SSH in Virtual box. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Step 1 - Virtual box Networking&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
- For both Server and Client &lt;br /&gt;
&lt;br /&gt;
- Select the virtual Machine&lt;br /&gt;
&lt;br /&gt;
- go to settings &amp;gt; network&lt;br /&gt;
&lt;br /&gt;
- set Adapter 1 as Internal network (It is better to setup static IP for adapter 1)&lt;br /&gt;
&lt;br /&gt;
- Also Add another network NAT (So the server could have internet access )&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Step 2 - Setup static IP in Ubuntu server (elk-master)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
- Become a root user &amp;lt;code&amp;gt; sudo -i &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Enable SSH by running following commands&amp;lt;ref&amp;gt;[https://askubuntu.com/questions/218344/why-am-i-getting-a-port-22-connection-refused-error open port 22 ]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; &lt;br /&gt;
sudo apt-get update&lt;br /&gt;
&lt;br /&gt;
sudo apt-get install openssh-server&lt;br /&gt;
&lt;br /&gt;
sudo ufw allow 22&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Set up static IP&lt;br /&gt;
&lt;br /&gt;
run this command &amp;lt;code&amp;gt; nano /etc/network/interfaces &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you set a static IP for primary network as screenshot:&lt;br /&gt;
&lt;br /&gt;
[[File:Static-ip-elk-master.PNG]]&lt;br /&gt;
&lt;br /&gt;
- Now go to &amp;lt;code&amp;gt;nano /etc/hosts &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add IP addresses of elk-master and elk-client as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
192.168.2.105 elk-master&lt;br /&gt;
192.168.2.106 elk-client&lt;br /&gt;
&amp;lt;/pre&amp;gt;[[File:Elk-master-hostd.PNG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Step 2 - Setup static IP for Ubuntu Desktop(elk-client)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
- Open terminal &lt;br /&gt;
&lt;br /&gt;
- log in as root user &lt;br /&gt;
&lt;br /&gt;
- Run following command for Openssh&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; &lt;br /&gt;
sudo apt-get update&lt;br /&gt;
&lt;br /&gt;
sudo apt-get install openssh-server&lt;br /&gt;
&lt;br /&gt;
sudo ufw allow 22&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Go to &amp;lt;code&amp;gt; nano /etc/network/interfaces &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Set static IP (example: 192.168.2.106) like ubuntu server &lt;br /&gt;
&lt;br /&gt;
- restart the Ubuntu desktop &lt;br /&gt;
&lt;br /&gt;
- Now ping ELK-MASTER by running this command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; ping elk-master &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Ping-elk-master.PNG]]&lt;br /&gt;
&lt;br /&gt;
- Connect to elk-master via ssh by this command here naz is the username for elk-master&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; ssh naz@elk-master &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Ssh-to-elk-master.PNG]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If you have follow the above steps for virtual box, now you are ready to install the ELK stack.&lt;br /&gt;
&lt;br /&gt;
== Step 1 - Install Java ==&lt;br /&gt;
&lt;br /&gt;
Java is required for the Elastic stack deployment. Elasticsearch requires Java 8. It is recommended to use the Oracle JDK 1.8. We will install Java 8 from a PPA repository.&lt;br /&gt;
&lt;br /&gt;
Install the new package &#039;&#039;&#039;&#039;python-software-properties&#039;&#039;&#039;&#039; so we can add a new repository easily with an apt command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y python-software-properties software-properties-common apt-transport-https&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the new Java 8 PPA repository with the &#039;add-apt-repository&#039; command, then update the repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo add-apt-repository ppa:webupd8team/java -y &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install Java 8 from the PPA webpub8 repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y oracle-java8-installer&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 2 - Install and Configure Elasticsearch ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Elasticsearch. Install Elasticsearch from the elastic repository and configure it to run on the localhost IP.&lt;br /&gt;
&lt;br /&gt;
Before installing Elasticsearch, add the elastic repository key to the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add - &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add elastic 5.x repository to the &#039;sources.list.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; echo &amp;quot;deb https://artifacts.elastic.co/packages/5.x/apt stable main&amp;quot; | sudo tee -a /etc/apt/sources.list.d/elastic-5.x.list &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Update the repository and install Elasticsearch 5.1 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Elasticsearch is installed. Now go to the configuration directory and edit the elasticsaerch.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; cd /etc/elasticsearch/ &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano elasticsearch.yml &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enable memory lock for Elasticsearch by removing the comment on line 43. We do this to disable swapping memory for Elasticsearchto avoid overloading the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; bootstrap.memory_lock: true &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the &#039;Network&#039; block, uncomment the network.host and http.port lines.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;network.host: localhost&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;http.port: 9200&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Now edit the elasticsearch service file for the memory lock mlockall configuration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /usr/lib/systemd/system/elasticsearch.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment LimitMEMLOCK line.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;LimitMEMLOCK=infinity&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit.&lt;br /&gt;
&lt;br /&gt;
Edit the default configuration for Elasticsearch in the /etc/default directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano /etc/default/elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment line 60 and make sure the value is &#039;unlimited&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;MAX_LOCKED_MEMORY=unlimited&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
The Elasticsearch configuration is finished. Elasticsearch will run under localhost IP address with port 9200 and we disabled swap memory by enabling mlockall on the Ubuntu server.&lt;br /&gt;
&lt;br /&gt;
Reload the Elasticsearch service file and enable it to run on the boot time, then start the service.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl daemon-reload&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable elasticsearch&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start elasticsearch&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Wait a sec for Elasticsearch to run, then check the open port on the server, make sure the &#039;state&#039; for port 9200 is &#039;LISTEN&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;netstat -plntu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then check the memory lock to ensure that mlockall is enabled. Also check that Elasticsearch is running with the commands below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
curl -XGET &#039;localhost:9200/_nodes?filter_path=**.mlockall&amp;amp;pretty&#039;&lt;br /&gt;
&lt;br /&gt;
curl -XGET &#039;localhost:9200/?pretty&#039;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see the results below.&lt;br /&gt;
&lt;br /&gt;
== Step 3 - Install and Configure Kibana with Nginx ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Kibana behind a Nginx web server. Kibana will listen on the localhost IP address only and Nginx acts as the reverse proxy for the Kibana application.&lt;br /&gt;
&lt;br /&gt;
Install Kibana with this apt command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y kibana&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the kibana.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /etc/kibana/kibana.yml&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment the server.port, server.hos and elasticsearch.url lines.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
server.port: 5601&lt;br /&gt;
&lt;br /&gt;
server.host: &amp;quot;localhost&amp;quot;&lt;br /&gt;
&lt;br /&gt;
elasticsearch.url: &amp;quot;http://localhost:9200&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Add Kibana to run at boot and start it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl enable kibana&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start kibana&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana will run on port 5601 as node application.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
netstat -plntu&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana installation is done, now we need to install Nginx and configure it as a reverse proxy to be able to access Kibana from the public IP address.&lt;br /&gt;
&lt;br /&gt;
Next, install the Nginx and apache2-utils packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo apt-get install -y nginx apache2-utils&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Apache2-utils is a package that contains tools for the webserver that work with Nginx as well, we will use htpasswd basic authentication for Kibana.&lt;br /&gt;
&lt;br /&gt;
Nginx has been installed. Now we need to create a new virtual host configuration file in the Nginx sites-available directory. Create a new file &#039;kibana&#039; with nano.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/nginx/&lt;br /&gt;
vim sites-available/kibana&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
    listen 80;&lt;br /&gt;
 &lt;br /&gt;
    server_name elk-stack.co;&lt;br /&gt;
 &lt;br /&gt;
    auth_basic &amp;quot;Restricted Access&amp;quot;;&lt;br /&gt;
    auth_basic_user_file /etc/nginx/.kibana-user;&lt;br /&gt;
 &lt;br /&gt;
    location / {&lt;br /&gt;
        proxy_pass http://localhost:5601;&lt;br /&gt;
        proxy_http_version 1.1;&lt;br /&gt;
        proxy_set_header Upgrade $http_upgrade;&lt;br /&gt;
        proxy_set_header Connection &#039;upgrade&#039;;&lt;br /&gt;
        proxy_set_header Host $host;&lt;br /&gt;
        proxy_cache_bypass $http_upgrade;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano&lt;br /&gt;
&lt;br /&gt;
Create a new basic authentication file with the htpasswd command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo htpasswd -c /etc/nginx/.kibana-user admin&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
TYPE YOUR PASSWORD&lt;br /&gt;
&lt;br /&gt;
Activate the kibana virtual host by creating a symbolic link from the kibana file in &#039;sites-available&#039; to the &#039;sites-enabled&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ln -s /etc/nginx/sites-available/kibana /etc/nginx/sites-enabled/ &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Test the nginx configuration and make sure there is no error, then add nginx to run at boot time and restart nginx.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
nginx -t&lt;br /&gt;
&lt;br /&gt;
systemctl enable nginx&lt;br /&gt;
&lt;br /&gt;
systemctl restart nginx&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Step 4 - Install and Configure Logstash == &lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Logsatash to centralize server logs from client sources with filebeat, then filter and transform all data (Syslog) and transport it to the stash (Elasticsearch).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install Logstash 5 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y logstash&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Edit the hosts file with nano.&lt;br /&gt;
&lt;br /&gt;
nano /etc/hosts&lt;br /&gt;
&lt;br /&gt;
Add the server IP address and hostname.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;10.0.2.15    elk-master&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the hosts file and exit the editor.&lt;br /&gt;
&lt;br /&gt;
Now generate a new SSL certificate file with OpenSSL so the client sources can identify the elastic server.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/logstash/&lt;br /&gt;
&lt;br /&gt;
openssl req -subj /CN=elk-master -x509 -days 3650 -batch -nodes -newkey rsa:4096 -keyout logstash.key -out logstash.crt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change the &#039;/CN&#039; value to the elastic server hostname.&lt;br /&gt;
&lt;br /&gt;
Certificate files will be created in the &#039;/etc/logstash/&#039; directory.&lt;br /&gt;
&lt;br /&gt;
Next, we will create the configuration files for logstash. We will create a configuration file &#039;filebeat-input.conf&#039; as input file from filebeat, &#039;syslog-filter.conf&#039; for syslog processing, and then a &#039;output-elasticsearch.conf&#039; file to define the Elasticsearch output.&lt;br /&gt;
&lt;br /&gt;
Go to the logstash configuration directory and create the new configuration files in the &#039;conf.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/logstash/&lt;br /&gt;
&lt;br /&gt;
nano conf.d/filebeat-input.conf&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Input configuration, paste configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input {&lt;br /&gt;
  beats {&lt;br /&gt;
    port =&amp;gt; 5443&lt;br /&gt;
    type =&amp;gt; syslog&lt;br /&gt;
    ssl =&amp;gt; true&lt;br /&gt;
    ssl_certificate =&amp;gt; &amp;quot;/etc/logstash/logstash.crt&amp;quot;&lt;br /&gt;
    ssl_key =&amp;gt; &amp;quot;/etc/logstash/logstash.key&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Create the syslog-filter.conf file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano conf.d/syslog-filter.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
filter {&lt;br /&gt;
  if [type] == &amp;quot;syslog&amp;quot; {&lt;br /&gt;
    grok {&lt;br /&gt;
      match =&amp;gt; { &amp;quot;message&amp;quot; =&amp;gt; &amp;quot;%{SYSLOGTIMESTAMP:syslog_timestamp} %{SYSLOGHOST:syslog_hostname} %{DATA:syslog_program}(?:\[%{POSINT:syslog_pid}\])?: %{GREEDYDATA:syslog_message}&amp;quot; }&lt;br /&gt;
      add_field =&amp;gt; [ &amp;quot;received_at&amp;quot;, &amp;quot;%{@timestamp}&amp;quot; ]&lt;br /&gt;
      add_field =&amp;gt; [ &amp;quot;received_from&amp;quot;, &amp;quot;%{host}&amp;quot; ]&lt;br /&gt;
    }&lt;br /&gt;
    date {&lt;br /&gt;
      match =&amp;gt; [ &amp;quot;syslog_timestamp&amp;quot;, &amp;quot;MMM  d HH:mm:ss&amp;quot;, &amp;quot;MMM dd HH:mm:ss&amp;quot; ]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We use a filter plugin named &#039;grok&#039; to parse the syslog files.&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Create the output configuration file &#039;output-elasticsearch.conf&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano conf.d/output-elasticsearch.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
output {&lt;br /&gt;
  elasticsearch { hosts =&amp;gt; [&amp;quot;localhost:9200&amp;quot;]&lt;br /&gt;
    hosts =&amp;gt; &amp;quot;localhost:9200&amp;quot;&lt;br /&gt;
    manage_template =&amp;gt; false&lt;br /&gt;
    index =&amp;gt; &amp;quot;%{[@metadata][beat]}-%{+YYYY.MM.dd}&amp;quot;&lt;br /&gt;
    document_type =&amp;gt; &amp;quot;%{[@metadata][type]}&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
When this is done, add logstash to start at boot time and start the service.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable logstash&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start logstash&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Alternatives of ELK stack (Graylog2) ==&lt;br /&gt;
&lt;br /&gt;
Graylog is a powerful tool for logs management that gives you lots of options on analyzing incoming logs from different servers. The way Graylog works is pretty much similar to ELK. In addition to the very Graylog server, which consists of the application and the web interface server, you will also need to have MongoDB and Elasticsearch in order to make the whole stack fully operable. &amp;lt;ref&amp;gt;[https://www.graylog.org/features garylog]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;ELK stack vs Graylog2&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
ELK stack and Graylog both almost same in terms of features. Graylog can’t read from syslog files, so you need to send your messages to Graylog directly.&amp;lt;ref&amp;gt;[https://medium.com/jetruby/log-management-graylog-vs-elk-fc93428e0f66 medium.co]&amp;lt;/ref&amp;gt;. Logstash’s weak spot has always been performance and resource consumption. Graylog also has built is user permissions management, this feature is not available in Kibana. In Graylog you can also configure it to receive alerts via emails. Graylog uses good-ol [https://en.wikipedia.org/wiki/Representational_state_transfer REST API].&lt;br /&gt;
&lt;br /&gt;
== Summary ==&lt;br /&gt;
&lt;br /&gt;
Right now ELK stack is the most popular log management platform.&amp;lt;ref&amp;gt;[https://logz.io/learn/complete-guide-elk-stack/ number of downloads]&amp;lt;/ref&amp;gt;. ELK Stack also very useful tools for database log analysis like Redis and MySQL. &amp;lt;ref&amp;gt;[https://logz.io/blog/redis-performance-monitoring-elk-stack/ redis performance]&amp;lt;/ref&amp;gt; Another popular uses of ELK is social media data analysis like Slack or Twitter.&amp;lt;ref&amp;gt;[https://logz.io/blog/interpreting-your-slack-data-with-the-elk-stack/ Slack data]&amp;lt;/ref&amp;gt; ELK stack through have some disadvantageous like it requires lot of resources. But the versatile uses of ELK stack makes it one of most flexible data and log management tools. It&#039;s competitor Graylog also has quite a number advantages over ELK stack.   &lt;br /&gt;
&lt;br /&gt;
== References ==&lt;/div&gt;</summary>
		<author><name>Mdhasan</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123822</id>
		<title>Logging and monitoring with Elastic stack on Ubuntu 16.04</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123822"/>
		<updated>2017-06-21T22:35:49Z</updated>

		<summary type="html">&lt;p&gt;Mdhasan: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
Logging and monitoring of IT systems is very important part of information security. Proper system logs and monitoring can prevent cyber attacks or service failure. In this wiki we will learn how configure logging and monitoring with ELK stack in Ubuntu server 16.04 and the alternatives of ELK stack Graylogs.      &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Elasticsearch&#039;&#039;&#039; is an open source search engine based on Lucene, developed in java. It provides a distributed and multitenant [https://en.wikipedia.org/wiki/Full-text_search full-text search engine] with an HTTP Dashboard web-interface (Kibana) and JSON documents scheme. Elasticsearch is a scalable search engine that can be used to search for all types of documents, including log file. Elasticsearch is the heart of the &#039;Elastic Stack&#039; or ELK Stack.&amp;lt;ref&amp;gt;[https://www.elastic.co/products/elasticsearch] Elastic Search Homepage&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Logstash&#039;&#039;&#039; is an open source, server-side data processing pipeline that ingests data from a multitude of sources simultaneously, transforms it, and then sends it to Elasticsearch.&amp;lt;ref&amp;gt;[https://www.elastic.co/products/logstash] Logstash homepage&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Kibana&#039;&#039;&#039; is a data visualization interface for Elasticsearch. Kibana provides a pretty dashboard (web interfaces), it allows you to manage and visualize all data from Elasticsearch on your own. &amp;lt;ref&amp;gt;[https://www.elastic.co/products/kibana] kibana homepage&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Prerequisite ==&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit server with 4GB of RAM, hostname - elk-master&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit client with 1 GB of RAM, hostname - elk-client&lt;br /&gt;
&lt;br /&gt;
Following installation steps from 1 to 4 is collected from &lt;br /&gt;
&lt;br /&gt;
[http://www.howtoforge.com HowToFroge.com]&amp;lt;ref&amp;gt;[http://thehackernews.com/2013/10/importance-of-logs-and-log-management.html]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Virtual Box setup ==&lt;br /&gt;
&lt;br /&gt;
As we are going to use Ubuntu server 16.04, which has no Graphical user interface (GUI). It is better to add a GUI client to Ubuntu server and ssh to virtual box setup. Here I will show to how to connect to Ubuntu server from a Ubuntu desktop client via SSH in Virtual box. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Step 1 - Virtual box Networking&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
- For both Server and Client &lt;br /&gt;
&lt;br /&gt;
- Select the virtual Machine&lt;br /&gt;
&lt;br /&gt;
- go to settings &amp;gt; network&lt;br /&gt;
&lt;br /&gt;
- set Adapter 1 as Internal network (It is better to setup static IP for adapter 1)&lt;br /&gt;
&lt;br /&gt;
- Also Add another network NAT (So the server could have internet access )&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Step 2 - Setup static IP in Ubuntu server (elk-master)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
- Become a root user &amp;lt;code&amp;gt; sudo -i &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Enable SSH by running following commands&amp;lt;ref&amp;gt;[https://askubuntu.com/questions/218344/why-am-i-getting-a-port-22-connection-refused-error open port 22 ]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; &lt;br /&gt;
sudo apt-get update&lt;br /&gt;
&lt;br /&gt;
sudo apt-get install openssh-server&lt;br /&gt;
&lt;br /&gt;
sudo ufw allow 22&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Set up static IP&lt;br /&gt;
&lt;br /&gt;
run this command &amp;lt;code&amp;gt; nano /etc/network/interfaces &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you set a static IP for primary network as screenshot:&lt;br /&gt;
&lt;br /&gt;
[[File:Static-ip-elk-master.PNG]]&lt;br /&gt;
&lt;br /&gt;
- Now go to &amp;lt;code&amp;gt;nano /etc/hosts &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add IP addresses of elk-master and elk-client as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
192.168.2.105 elk-master&lt;br /&gt;
192.168.2.106 elk-client&lt;br /&gt;
&amp;lt;/pre&amp;gt;[[File:Elk-master-hostd.PNG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Step 2 - Setup static IP for Ubuntu Desktop(elk-client)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
- Open terminal &lt;br /&gt;
&lt;br /&gt;
- log in as root user &lt;br /&gt;
&lt;br /&gt;
- Run following command for Openssh&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; &lt;br /&gt;
sudo apt-get update&lt;br /&gt;
&lt;br /&gt;
sudo apt-get install openssh-server&lt;br /&gt;
&lt;br /&gt;
sudo ufw allow 22&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Go to &amp;lt;code&amp;gt; nano /etc/network/interfaces &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Set static IP (example: 192.168.2.106) like ubuntu server &lt;br /&gt;
&lt;br /&gt;
- restart the Ubuntu desktop &lt;br /&gt;
&lt;br /&gt;
- Now ping ELK-MASTER by running this command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; ping elk-master &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Ping-elk-master.PNG]]&lt;br /&gt;
&lt;br /&gt;
- Connect to elk-master via ssh by this command here naz is the username for elk-master&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; ssh naz@elk-master &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Ssh-to-elk-master.PNG]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If you have follow the above steps for virtual box, now you are ready to install the ELK stack.&lt;br /&gt;
&lt;br /&gt;
== Step 1 - Install Java ==&lt;br /&gt;
&lt;br /&gt;
Java is required for the Elastic stack deployment. Elasticsearch requires Java 8. It is recommended to use the Oracle JDK 1.8. We will install Java 8 from a PPA repository.&lt;br /&gt;
&lt;br /&gt;
Install the new package &#039;&#039;&#039;&#039;python-software-properties&#039;&#039;&#039;&#039; so we can add a new repository easily with an apt command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y python-software-properties software-properties-common apt-transport-https&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the new Java 8 PPA repository with the &#039;add-apt-repository&#039; command, then update the repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo add-apt-repository ppa:webupd8team/java -y &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install Java 8 from the PPA webpub8 repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y oracle-java8-installer&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 2 - Install and Configure Elasticsearch ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Elasticsearch. Install Elasticsearch from the elastic repository and configure it to run on the localhost IP.&lt;br /&gt;
&lt;br /&gt;
Before installing Elasticsearch, add the elastic repository key to the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add - &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add elastic 5.x repository to the &#039;sources.list.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; echo &amp;quot;deb https://artifacts.elastic.co/packages/5.x/apt stable main&amp;quot; | sudo tee -a /etc/apt/sources.list.d/elastic-5.x.list &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Update the repository and install Elasticsearch 5.1 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Elasticsearch is installed. Now go to the configuration directory and edit the elasticsaerch.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; cd /etc/elasticsearch/ &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano elasticsearch.yml &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enable memory lock for Elasticsearch by removing the comment on line 43. We do this to disable swapping memory for Elasticsearchto avoid overloading the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; bootstrap.memory_lock: true &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the &#039;Network&#039; block, uncomment the network.host and http.port lines.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;network.host: localhost&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;http.port: 9200&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Now edit the elasticsearch service file for the memory lock mlockall configuration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /usr/lib/systemd/system/elasticsearch.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment LimitMEMLOCK line.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;LimitMEMLOCK=infinity&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit.&lt;br /&gt;
&lt;br /&gt;
Edit the default configuration for Elasticsearch in the /etc/default directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano /etc/default/elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment line 60 and make sure the value is &#039;unlimited&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;MAX_LOCKED_MEMORY=unlimited&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
The Elasticsearch configuration is finished. Elasticsearch will run under localhost IP address with port 9200 and we disabled swap memory by enabling mlockall on the Ubuntu server.&lt;br /&gt;
&lt;br /&gt;
Reload the Elasticsearch service file and enable it to run on the boot time, then start the service.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl daemon-reload&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable elasticsearch&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start elasticsearch&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Wait a sec for Elasticsearch to run, then check the open port on the server, make sure the &#039;state&#039; for port 9200 is &#039;LISTEN&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;netstat -plntu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then check the memory lock to ensure that mlockall is enabled. Also check that Elasticsearch is running with the commands below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
curl -XGET &#039;localhost:9200/_nodes?filter_path=**.mlockall&amp;amp;pretty&#039;&lt;br /&gt;
&lt;br /&gt;
curl -XGET &#039;localhost:9200/?pretty&#039;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see the results below.&lt;br /&gt;
&lt;br /&gt;
== Step 3 - Install and Configure Kibana with Nginx ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Kibana behind a Nginx web server. Kibana will listen on the localhost IP address only and Nginx acts as the reverse proxy for the Kibana application.&lt;br /&gt;
&lt;br /&gt;
Install Kibana with this apt command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y kibana&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the kibana.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /etc/kibana/kibana.yml&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment the server.port, server.hos and elasticsearch.url lines.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
server.port: 5601&lt;br /&gt;
&lt;br /&gt;
server.host: &amp;quot;localhost&amp;quot;&lt;br /&gt;
&lt;br /&gt;
elasticsearch.url: &amp;quot;http://localhost:9200&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Add Kibana to run at boot and start it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl enable kibana&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start kibana&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana will run on port 5601 as node application.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
netstat -plntu&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana installation is done, now we need to install Nginx and configure it as a reverse proxy to be able to access Kibana from the public IP address.&lt;br /&gt;
&lt;br /&gt;
Next, install the Nginx and apache2-utils packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo apt-get install -y nginx apache2-utils&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Apache2-utils is a package that contains tools for the webserver that work with Nginx as well, we will use htpasswd basic authentication for Kibana.&lt;br /&gt;
&lt;br /&gt;
Nginx has been installed. Now we need to create a new virtual host configuration file in the Nginx sites-available directory. Create a new file &#039;kibana&#039; with nano.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/nginx/&lt;br /&gt;
vim sites-available/kibana&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
    listen 80;&lt;br /&gt;
 &lt;br /&gt;
    server_name elk-stack.co;&lt;br /&gt;
 &lt;br /&gt;
    auth_basic &amp;quot;Restricted Access&amp;quot;;&lt;br /&gt;
    auth_basic_user_file /etc/nginx/.kibana-user;&lt;br /&gt;
 &lt;br /&gt;
    location / {&lt;br /&gt;
        proxy_pass http://localhost:5601;&lt;br /&gt;
        proxy_http_version 1.1;&lt;br /&gt;
        proxy_set_header Upgrade $http_upgrade;&lt;br /&gt;
        proxy_set_header Connection &#039;upgrade&#039;;&lt;br /&gt;
        proxy_set_header Host $host;&lt;br /&gt;
        proxy_cache_bypass $http_upgrade;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano&lt;br /&gt;
&lt;br /&gt;
Create a new basic authentication file with the htpasswd command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo htpasswd -c /etc/nginx/.kibana-user admin&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
TYPE YOUR PASSWORD&lt;br /&gt;
&lt;br /&gt;
Activate the kibana virtual host by creating a symbolic link from the kibana file in &#039;sites-available&#039; to the &#039;sites-enabled&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ln -s /etc/nginx/sites-available/kibana /etc/nginx/sites-enabled/ &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Test the nginx configuration and make sure there is no error, then add nginx to run at boot time and restart nginx.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
nginx -t&lt;br /&gt;
&lt;br /&gt;
systemctl enable nginx&lt;br /&gt;
&lt;br /&gt;
systemctl restart nginx&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Step 4 - Install and Configure Logstash == &lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Logsatash to centralize server logs from client sources with filebeat, then filter and transform all data (Syslog) and transport it to the stash (Elasticsearch).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install Logstash 5 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y logstash&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Edit the hosts file with nano.&lt;br /&gt;
&lt;br /&gt;
nano /etc/hosts&lt;br /&gt;
&lt;br /&gt;
Add the server IP address and hostname.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;10.0.2.15    elk-master&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the hosts file and exit the editor.&lt;br /&gt;
&lt;br /&gt;
Now generate a new SSL certificate file with OpenSSL so the client sources can identify the elastic server.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/logstash/&lt;br /&gt;
&lt;br /&gt;
openssl req -subj /CN=elk-master -x509 -days 3650 -batch -nodes -newkey rsa:4096 -keyout logstash.key -out logstash.crt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change the &#039;/CN&#039; value to the elastic server hostname.&lt;br /&gt;
&lt;br /&gt;
Certificate files will be created in the &#039;/etc/logstash/&#039; directory.&lt;br /&gt;
&lt;br /&gt;
Next, we will create the configuration files for logstash. We will create a configuration file &#039;filebeat-input.conf&#039; as input file from filebeat, &#039;syslog-filter.conf&#039; for syslog processing, and then a &#039;output-elasticsearch.conf&#039; file to define the Elasticsearch output.&lt;br /&gt;
&lt;br /&gt;
Go to the logstash configuration directory and create the new configuration files in the &#039;conf.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/logstash/&lt;br /&gt;
&lt;br /&gt;
nano conf.d/filebeat-input.conf&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Input configuration, paste configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input {&lt;br /&gt;
  beats {&lt;br /&gt;
    port =&amp;gt; 5443&lt;br /&gt;
    type =&amp;gt; syslog&lt;br /&gt;
    ssl =&amp;gt; true&lt;br /&gt;
    ssl_certificate =&amp;gt; &amp;quot;/etc/logstash/logstash.crt&amp;quot;&lt;br /&gt;
    ssl_key =&amp;gt; &amp;quot;/etc/logstash/logstash.key&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Create the syslog-filter.conf file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano conf.d/syslog-filter.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
filter {&lt;br /&gt;
  if [type] == &amp;quot;syslog&amp;quot; {&lt;br /&gt;
    grok {&lt;br /&gt;
      match =&amp;gt; { &amp;quot;message&amp;quot; =&amp;gt; &amp;quot;%{SYSLOGTIMESTAMP:syslog_timestamp} %{SYSLOGHOST:syslog_hostname} %{DATA:syslog_program}(?:\[%{POSINT:syslog_pid}\])?: %{GREEDYDATA:syslog_message}&amp;quot; }&lt;br /&gt;
      add_field =&amp;gt; [ &amp;quot;received_at&amp;quot;, &amp;quot;%{@timestamp}&amp;quot; ]&lt;br /&gt;
      add_field =&amp;gt; [ &amp;quot;received_from&amp;quot;, &amp;quot;%{host}&amp;quot; ]&lt;br /&gt;
    }&lt;br /&gt;
    date {&lt;br /&gt;
      match =&amp;gt; [ &amp;quot;syslog_timestamp&amp;quot;, &amp;quot;MMM  d HH:mm:ss&amp;quot;, &amp;quot;MMM dd HH:mm:ss&amp;quot; ]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We use a filter plugin named &#039;grok&#039; to parse the syslog files.&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Create the output configuration file &#039;output-elasticsearch.conf&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano conf.d/output-elasticsearch.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
output {&lt;br /&gt;
  elasticsearch { hosts =&amp;gt; [&amp;quot;localhost:9200&amp;quot;]&lt;br /&gt;
    hosts =&amp;gt; &amp;quot;localhost:9200&amp;quot;&lt;br /&gt;
    manage_template =&amp;gt; false&lt;br /&gt;
    index =&amp;gt; &amp;quot;%{[@metadata][beat]}-%{+YYYY.MM.dd}&amp;quot;&lt;br /&gt;
    document_type =&amp;gt; &amp;quot;%{[@metadata][type]}&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
When this is done, add logstash to start at boot time and start the service.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable logstash&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start logstash&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Alternatives of ELK stack (Graylog2) ==&lt;br /&gt;
&lt;br /&gt;
Graylog is a powerful tool for logs management that gives you lots of options on analyzing incoming logs from different servers. The way Graylog works is pretty much similar to ELK. In addition to the very Graylog server, which consists of the application and the web interface server, you will also need to have MongoDB and Elasticsearch in order to make the whole stack fully operable. &amp;lt;ref&amp;gt;[https://www.graylog.org/features garylog]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;ELK stack vs Graylog2&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
ELK stack and Graylog both almost same in terms of features. Graylog can’t read from syslog files, so you need to send your messages to Graylog directly.&amp;lt;ref&amp;gt;[https://medium.com/jetruby/log-management-graylog-vs-elk-fc93428e0f66 medium.co]&amp;lt;/ref&amp;gt;. Logstash’s weak spot has always been performance and resource consumption. Graylog also has built is user permissions management, this feature is not available in Kibana. In Graylog you can also configure it to receive alerts via emails. Graylog uses good-ol [https://en.wikipedia.org/wiki/Representational_state_transfer REST API].&lt;br /&gt;
== References ==&lt;/div&gt;</summary>
		<author><name>Mdhasan</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123821</id>
		<title>Logging and monitoring with Elastic stack on Ubuntu 16.04</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123821"/>
		<updated>2017-06-21T22:02:05Z</updated>

		<summary type="html">&lt;p&gt;Mdhasan: /* Alternatives of ELK stack (Graylog2) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
Logging and monitoring of IT systems is very important part of information security. Proper system logs and monitoring can prevent cyber attacks or service failure. In this wiki we will learn how configure logging and monitoring with ELK stack in Ubuntu server 16.04 andwhat is alternatives (Graylog) of ELK stack and disadvantages of ELK stack.      &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Elasticsearch&#039;&#039;&#039; is an open source search engine based on Lucene, developed in java. It provides a distributed and multitenant [https://en.wikipedia.org/wiki/Full-text_search full-text search engine] with an HTTP Dashboard web-interface (Kibana) and JSON documents scheme. Elasticsearch is a scalable search engine that can be used to search for all types of documents, including log file. Elasticsearch is the heart of the &#039;Elastic Stack&#039; or ELK Stack.&amp;lt;ref&amp;gt;[https://www.elastic.co/products/elasticsearch] Elastic Search Homepage&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Logstash&#039;&#039;&#039; is an open source, server-side data processing pipeline that ingests data from a multitude of sources simultaneously, transforms it, and then sends it to Elasticsearch.&amp;lt;ref&amp;gt;[https://www.elastic.co/products/logstash] Logstash homepage&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Kibana&#039;&#039;&#039; is a data visualization interface for Elasticsearch. Kibana provides a pretty dashboard (web interfaces), it allows you to manage and visualize all data from Elasticsearch on your own. &amp;lt;ref&amp;gt;[https://www.elastic.co/products/kibana] kibana homepage&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Prerequisite ==&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit server with 4GB of RAM, hostname - elk-master&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit client with 1 GB of RAM, hostname - elk-client&lt;br /&gt;
&lt;br /&gt;
Following installation steps from 1 to 4 is collected from &lt;br /&gt;
&lt;br /&gt;
[http://www.howtoforge.com HowToFroge.com]&amp;lt;ref&amp;gt;[http://thehackernews.com/2013/10/importance-of-logs-and-log-management.html]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Virtual Box setup ==&lt;br /&gt;
&lt;br /&gt;
As we are going to use Ubuntu server 16.04, which has no Graphical user interface (GUI). It is better to add a GUI client to Ubuntu server and ssh to virtual box setup. Here I will show to how to connect to Ubuntu server from a Ubuntu desktop client via SSH in Virtual box. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Step 1 - Virtual box Networking&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
- For both Server and Client &lt;br /&gt;
&lt;br /&gt;
- Select the virtual Machine&lt;br /&gt;
&lt;br /&gt;
- go to settings &amp;gt; network&lt;br /&gt;
&lt;br /&gt;
- set Adapter 1 as Internal network (It is better to setup static IP for adapter 1)&lt;br /&gt;
&lt;br /&gt;
- Also Add another network NAT (So the server could have internet access )&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Step 2 - Setup static IP in Ubuntu server (elk-master)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
- Become a root user &amp;lt;code&amp;gt; sudo -i &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Enable SSH by running following commands&amp;lt;ref&amp;gt;[https://askubuntu.com/questions/218344/why-am-i-getting-a-port-22-connection-refused-error open port 22 ]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; &lt;br /&gt;
sudo apt-get update&lt;br /&gt;
&lt;br /&gt;
sudo apt-get install openssh-server&lt;br /&gt;
&lt;br /&gt;
sudo ufw allow 22&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Set up static IP&lt;br /&gt;
&lt;br /&gt;
run this command &amp;lt;code&amp;gt; nano /etc/network/interfaces &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you set a static IP for primary network as screenshot:&lt;br /&gt;
&lt;br /&gt;
[[File:Static-ip-elk-master.PNG]]&lt;br /&gt;
&lt;br /&gt;
- Now go to &amp;lt;code&amp;gt;nano /etc/hosts &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add IP addresses of elk-master and elk-client as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
192.168.2.105 elk-master&lt;br /&gt;
192.168.2.106 elk-client&lt;br /&gt;
&amp;lt;/pre&amp;gt;[[File:Elk-master-hostd.PNG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Step 2 - Setup static IP for Ubuntu Desktop(elk-client)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
- Open terminal &lt;br /&gt;
&lt;br /&gt;
- log in as root user &lt;br /&gt;
&lt;br /&gt;
- Run following command for Openssh&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; &lt;br /&gt;
sudo apt-get update&lt;br /&gt;
&lt;br /&gt;
sudo apt-get install openssh-server&lt;br /&gt;
&lt;br /&gt;
sudo ufw allow 22&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Go to &amp;lt;code&amp;gt; nano /etc/network/interfaces &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Set static IP (example: 192.168.2.106) like ubuntu server &lt;br /&gt;
&lt;br /&gt;
- restart the Ubuntu desktop &lt;br /&gt;
&lt;br /&gt;
- Now ping ELK-MASTER by running this command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; ping elk-master &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Ping-elk-master.PNG]]&lt;br /&gt;
&lt;br /&gt;
- Connect to elk-master via ssh by this command here naz is the username for elk-master&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; ssh naz@elk-master &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Ssh-to-elk-master.PNG]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If you have follow the above steps for virtual box, now you are ready to install the ELK stack.&lt;br /&gt;
&lt;br /&gt;
== Step 1 - Install Java ==&lt;br /&gt;
&lt;br /&gt;
Java is required for the Elastic stack deployment. Elasticsearch requires Java 8. It is recommended to use the Oracle JDK 1.8. We will install Java 8 from a PPA repository.&lt;br /&gt;
&lt;br /&gt;
Install the new package &#039;&#039;&#039;&#039;python-software-properties&#039;&#039;&#039;&#039; so we can add a new repository easily with an apt command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y python-software-properties software-properties-common apt-transport-https&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the new Java 8 PPA repository with the &#039;add-apt-repository&#039; command, then update the repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo add-apt-repository ppa:webupd8team/java -y &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install Java 8 from the PPA webpub8 repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y oracle-java8-installer&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 2 - Install and Configure Elasticsearch ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Elasticsearch. Install Elasticsearch from the elastic repository and configure it to run on the localhost IP.&lt;br /&gt;
&lt;br /&gt;
Before installing Elasticsearch, add the elastic repository key to the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add - &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add elastic 5.x repository to the &#039;sources.list.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; echo &amp;quot;deb https://artifacts.elastic.co/packages/5.x/apt stable main&amp;quot; | sudo tee -a /etc/apt/sources.list.d/elastic-5.x.list &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Update the repository and install Elasticsearch 5.1 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Elasticsearch is installed. Now go to the configuration directory and edit the elasticsaerch.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; cd /etc/elasticsearch/ &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano elasticsearch.yml &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enable memory lock for Elasticsearch by removing the comment on line 43. We do this to disable swapping memory for Elasticsearchto avoid overloading the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; bootstrap.memory_lock: true &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the &#039;Network&#039; block, uncomment the network.host and http.port lines.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;network.host: localhost&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;http.port: 9200&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Now edit the elasticsearch service file for the memory lock mlockall configuration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /usr/lib/systemd/system/elasticsearch.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment LimitMEMLOCK line.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;LimitMEMLOCK=infinity&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit.&lt;br /&gt;
&lt;br /&gt;
Edit the default configuration for Elasticsearch in the /etc/default directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano /etc/default/elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment line 60 and make sure the value is &#039;unlimited&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;MAX_LOCKED_MEMORY=unlimited&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
The Elasticsearch configuration is finished. Elasticsearch will run under localhost IP address with port 9200 and we disabled swap memory by enabling mlockall on the Ubuntu server.&lt;br /&gt;
&lt;br /&gt;
Reload the Elasticsearch service file and enable it to run on the boot time, then start the service.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl daemon-reload&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable elasticsearch&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start elasticsearch&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Wait a sec for Elasticsearch to run, then check the open port on the server, make sure the &#039;state&#039; for port 9200 is &#039;LISTEN&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;netstat -plntu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then check the memory lock to ensure that mlockall is enabled. Also check that Elasticsearch is running with the commands below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
curl -XGET &#039;localhost:9200/_nodes?filter_path=**.mlockall&amp;amp;pretty&#039;&lt;br /&gt;
&lt;br /&gt;
curl -XGET &#039;localhost:9200/?pretty&#039;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see the results below.&lt;br /&gt;
&lt;br /&gt;
== Step 3 - Install and Configure Kibana with Nginx ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Kibana behind a Nginx web server. Kibana will listen on the localhost IP address only and Nginx acts as the reverse proxy for the Kibana application.&lt;br /&gt;
&lt;br /&gt;
Install Kibana with this apt command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y kibana&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the kibana.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /etc/kibana/kibana.yml&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment the server.port, server.hos and elasticsearch.url lines.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
server.port: 5601&lt;br /&gt;
&lt;br /&gt;
server.host: &amp;quot;localhost&amp;quot;&lt;br /&gt;
&lt;br /&gt;
elasticsearch.url: &amp;quot;http://localhost:9200&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Add Kibana to run at boot and start it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl enable kibana&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start kibana&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana will run on port 5601 as node application.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
netstat -plntu&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana installation is done, now we need to install Nginx and configure it as a reverse proxy to be able to access Kibana from the public IP address.&lt;br /&gt;
&lt;br /&gt;
Next, install the Nginx and apache2-utils packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo apt-get install -y nginx apache2-utils&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Apache2-utils is a package that contains tools for the webserver that work with Nginx as well, we will use htpasswd basic authentication for Kibana.&lt;br /&gt;
&lt;br /&gt;
Nginx has been installed. Now we need to create a new virtual host configuration file in the Nginx sites-available directory. Create a new file &#039;kibana&#039; with nano.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/nginx/&lt;br /&gt;
vim sites-available/kibana&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
    listen 80;&lt;br /&gt;
 &lt;br /&gt;
    server_name elk-stack.co;&lt;br /&gt;
 &lt;br /&gt;
    auth_basic &amp;quot;Restricted Access&amp;quot;;&lt;br /&gt;
    auth_basic_user_file /etc/nginx/.kibana-user;&lt;br /&gt;
 &lt;br /&gt;
    location / {&lt;br /&gt;
        proxy_pass http://localhost:5601;&lt;br /&gt;
        proxy_http_version 1.1;&lt;br /&gt;
        proxy_set_header Upgrade $http_upgrade;&lt;br /&gt;
        proxy_set_header Connection &#039;upgrade&#039;;&lt;br /&gt;
        proxy_set_header Host $host;&lt;br /&gt;
        proxy_cache_bypass $http_upgrade;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano&lt;br /&gt;
&lt;br /&gt;
Create a new basic authentication file with the htpasswd command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo htpasswd -c /etc/nginx/.kibana-user admin&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
TYPE YOUR PASSWORD&lt;br /&gt;
&lt;br /&gt;
Activate the kibana virtual host by creating a symbolic link from the kibana file in &#039;sites-available&#039; to the &#039;sites-enabled&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ln -s /etc/nginx/sites-available/kibana /etc/nginx/sites-enabled/ &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Test the nginx configuration and make sure there is no error, then add nginx to run at boot time and restart nginx.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
nginx -t&lt;br /&gt;
&lt;br /&gt;
systemctl enable nginx&lt;br /&gt;
&lt;br /&gt;
systemctl restart nginx&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Step 4 - Install and Configure Logstash == &lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Logsatash to centralize server logs from client sources with filebeat, then filter and transform all data (Syslog) and transport it to the stash (Elasticsearch).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install Logstash 5 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y logstash&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Edit the hosts file with nano.&lt;br /&gt;
&lt;br /&gt;
nano /etc/hosts&lt;br /&gt;
&lt;br /&gt;
Add the server IP address and hostname.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;10.0.2.15    elk-master&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the hosts file and exit the editor.&lt;br /&gt;
&lt;br /&gt;
Now generate a new SSL certificate file with OpenSSL so the client sources can identify the elastic server.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/logstash/&lt;br /&gt;
&lt;br /&gt;
openssl req -subj /CN=elk-master -x509 -days 3650 -batch -nodes -newkey rsa:4096 -keyout logstash.key -out logstash.crt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change the &#039;/CN&#039; value to the elastic server hostname.&lt;br /&gt;
&lt;br /&gt;
Certificate files will be created in the &#039;/etc/logstash/&#039; directory.&lt;br /&gt;
&lt;br /&gt;
Next, we will create the configuration files for logstash. We will create a configuration file &#039;filebeat-input.conf&#039; as input file from filebeat, &#039;syslog-filter.conf&#039; for syslog processing, and then a &#039;output-elasticsearch.conf&#039; file to define the Elasticsearch output.&lt;br /&gt;
&lt;br /&gt;
Go to the logstash configuration directory and create the new configuration files in the &#039;conf.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/logstash/&lt;br /&gt;
&lt;br /&gt;
nano conf.d/filebeat-input.conf&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Input configuration, paste configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input {&lt;br /&gt;
  beats {&lt;br /&gt;
    port =&amp;gt; 5443&lt;br /&gt;
    type =&amp;gt; syslog&lt;br /&gt;
    ssl =&amp;gt; true&lt;br /&gt;
    ssl_certificate =&amp;gt; &amp;quot;/etc/logstash/logstash.crt&amp;quot;&lt;br /&gt;
    ssl_key =&amp;gt; &amp;quot;/etc/logstash/logstash.key&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Create the syslog-filter.conf file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano conf.d/syslog-filter.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
filter {&lt;br /&gt;
  if [type] == &amp;quot;syslog&amp;quot; {&lt;br /&gt;
    grok {&lt;br /&gt;
      match =&amp;gt; { &amp;quot;message&amp;quot; =&amp;gt; &amp;quot;%{SYSLOGTIMESTAMP:syslog_timestamp} %{SYSLOGHOST:syslog_hostname} %{DATA:syslog_program}(?:\[%{POSINT:syslog_pid}\])?: %{GREEDYDATA:syslog_message}&amp;quot; }&lt;br /&gt;
      add_field =&amp;gt; [ &amp;quot;received_at&amp;quot;, &amp;quot;%{@timestamp}&amp;quot; ]&lt;br /&gt;
      add_field =&amp;gt; [ &amp;quot;received_from&amp;quot;, &amp;quot;%{host}&amp;quot; ]&lt;br /&gt;
    }&lt;br /&gt;
    date {&lt;br /&gt;
      match =&amp;gt; [ &amp;quot;syslog_timestamp&amp;quot;, &amp;quot;MMM  d HH:mm:ss&amp;quot;, &amp;quot;MMM dd HH:mm:ss&amp;quot; ]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We use a filter plugin named &#039;grok&#039; to parse the syslog files.&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Create the output configuration file &#039;output-elasticsearch.conf&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano conf.d/output-elasticsearch.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
output {&lt;br /&gt;
  elasticsearch { hosts =&amp;gt; [&amp;quot;localhost:9200&amp;quot;]&lt;br /&gt;
    hosts =&amp;gt; &amp;quot;localhost:9200&amp;quot;&lt;br /&gt;
    manage_template =&amp;gt; false&lt;br /&gt;
    index =&amp;gt; &amp;quot;%{[@metadata][beat]}-%{+YYYY.MM.dd}&amp;quot;&lt;br /&gt;
    document_type =&amp;gt; &amp;quot;%{[@metadata][type]}&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
When this is done, add logstash to start at boot time and start the service.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable logstash&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start logstash&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Alternatives of ELK stack (Graylog2) ==&lt;br /&gt;
&lt;br /&gt;
Graylog is a powerful tool for logs management that gives you lots of options on analyzing incoming logs from different servers. The way Graylog works is pretty much similar to ELK. In addition to the very Graylog server, which consists of the application and the web interface server, you will also need to have MongoDB and Elasticsearch in order to make the whole stack fully operable. &amp;lt;ref&amp;gt;[https://www.graylog.org/features garylog]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;ELK stack vs Graylog2&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
ELK stack and Graylog both almost same in terms of features. Graylog can’t read from syslog files, so you need to send your messages to Graylog directly.&amp;lt;ref&amp;gt;[https://medium.com/jetruby/log-management-graylog-vs-elk-fc93428e0f66 medium.co]&amp;lt;/ref&amp;gt;. Logstash’s weak spot has always been performance and resource consumption. Graylog also has built is user permissions management, this feature is not available in Kibana. In Graylog you can also configure it to receive alerts via emails. Graylog uses good-ol [https://en.wikipedia.org/wiki/Representational_state_transfer REST API].&lt;br /&gt;
== References ==&lt;/div&gt;</summary>
		<author><name>Mdhasan</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123820</id>
		<title>Logging and monitoring with Elastic stack on Ubuntu 16.04</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123820"/>
		<updated>2017-06-21T21:43:28Z</updated>

		<summary type="html">&lt;p&gt;Mdhasan: /* Alternatives of ELK stack (Graylog2) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
Logging and monitoring of IT systems is very important part of information security. Proper system logs and monitoring can prevent cyber attacks or service failure. In this wiki we will learn how configure logging and monitoring with ELK stack in Ubuntu server 16.04 andwhat is alternatives (Graylog) of ELK stack and disadvantages of ELK stack.      &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Elasticsearch&#039;&#039;&#039; is an open source search engine based on Lucene, developed in java. It provides a distributed and multitenant [https://en.wikipedia.org/wiki/Full-text_search full-text search engine] with an HTTP Dashboard web-interface (Kibana) and JSON documents scheme. Elasticsearch is a scalable search engine that can be used to search for all types of documents, including log file. Elasticsearch is the heart of the &#039;Elastic Stack&#039; or ELK Stack.&amp;lt;ref&amp;gt;[https://www.elastic.co/products/elasticsearch] Elastic Search Homepage&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Logstash&#039;&#039;&#039; is an open source, server-side data processing pipeline that ingests data from a multitude of sources simultaneously, transforms it, and then sends it to Elasticsearch.&amp;lt;ref&amp;gt;[https://www.elastic.co/products/logstash] Logstash homepage&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Kibana&#039;&#039;&#039; is a data visualization interface for Elasticsearch. Kibana provides a pretty dashboard (web interfaces), it allows you to manage and visualize all data from Elasticsearch on your own. &amp;lt;ref&amp;gt;[https://www.elastic.co/products/kibana] kibana homepage&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Prerequisite ==&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit server with 4GB of RAM, hostname - elk-master&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit client with 1 GB of RAM, hostname - elk-client&lt;br /&gt;
&lt;br /&gt;
Following installation steps from 1 to 4 is collected from &lt;br /&gt;
&lt;br /&gt;
[http://www.howtoforge.com HowToFroge.com]&amp;lt;ref&amp;gt;[http://thehackernews.com/2013/10/importance-of-logs-and-log-management.html]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Virtual Box setup ==&lt;br /&gt;
&lt;br /&gt;
As we are going to use Ubuntu server 16.04, which has no Graphical user interface (GUI). It is better to add a GUI client to Ubuntu server and ssh to virtual box setup. Here I will show to how to connect to Ubuntu server from a Ubuntu desktop client via SSH in Virtual box. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Step 1 - Virtual box Networking&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
- For both Server and Client &lt;br /&gt;
&lt;br /&gt;
- Select the virtual Machine&lt;br /&gt;
&lt;br /&gt;
- go to settings &amp;gt; network&lt;br /&gt;
&lt;br /&gt;
- set Adapter 1 as Internal network (It is better to setup static IP for adapter 1)&lt;br /&gt;
&lt;br /&gt;
- Also Add another network NAT (So the server could have internet access )&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Step 2 - Setup static IP in Ubuntu server (elk-master)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
- Become a root user &amp;lt;code&amp;gt; sudo -i &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Enable SSH by running following commands&amp;lt;ref&amp;gt;[https://askubuntu.com/questions/218344/why-am-i-getting-a-port-22-connection-refused-error open port 22 ]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; &lt;br /&gt;
sudo apt-get update&lt;br /&gt;
&lt;br /&gt;
sudo apt-get install openssh-server&lt;br /&gt;
&lt;br /&gt;
sudo ufw allow 22&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Set up static IP&lt;br /&gt;
&lt;br /&gt;
run this command &amp;lt;code&amp;gt; nano /etc/network/interfaces &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you set a static IP for primary network as screenshot:&lt;br /&gt;
&lt;br /&gt;
[[File:Static-ip-elk-master.PNG]]&lt;br /&gt;
&lt;br /&gt;
- Now go to &amp;lt;code&amp;gt;nano /etc/hosts &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add IP addresses of elk-master and elk-client as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
192.168.2.105 elk-master&lt;br /&gt;
192.168.2.106 elk-client&lt;br /&gt;
&amp;lt;/pre&amp;gt;[[File:Elk-master-hostd.PNG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Step 2 - Setup static IP for Ubuntu Desktop(elk-client)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
- Open terminal &lt;br /&gt;
&lt;br /&gt;
- log in as root user &lt;br /&gt;
&lt;br /&gt;
- Run following command for Openssh&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; &lt;br /&gt;
sudo apt-get update&lt;br /&gt;
&lt;br /&gt;
sudo apt-get install openssh-server&lt;br /&gt;
&lt;br /&gt;
sudo ufw allow 22&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Go to &amp;lt;code&amp;gt; nano /etc/network/interfaces &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Set static IP (example: 192.168.2.106) like ubuntu server &lt;br /&gt;
&lt;br /&gt;
- restart the Ubuntu desktop &lt;br /&gt;
&lt;br /&gt;
- Now ping ELK-MASTER by running this command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; ping elk-master &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Ping-elk-master.PNG]]&lt;br /&gt;
&lt;br /&gt;
- Connect to elk-master via ssh by this command here naz is the username for elk-master&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; ssh naz@elk-master &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Ssh-to-elk-master.PNG]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If you have follow the above steps for virtual box, now you are ready to install the ELK stack.&lt;br /&gt;
&lt;br /&gt;
== Step 1 - Install Java ==&lt;br /&gt;
&lt;br /&gt;
Java is required for the Elastic stack deployment. Elasticsearch requires Java 8. It is recommended to use the Oracle JDK 1.8. We will install Java 8 from a PPA repository.&lt;br /&gt;
&lt;br /&gt;
Install the new package &#039;&#039;&#039;&#039;python-software-properties&#039;&#039;&#039;&#039; so we can add a new repository easily with an apt command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y python-software-properties software-properties-common apt-transport-https&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the new Java 8 PPA repository with the &#039;add-apt-repository&#039; command, then update the repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo add-apt-repository ppa:webupd8team/java -y &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install Java 8 from the PPA webpub8 repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y oracle-java8-installer&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 2 - Install and Configure Elasticsearch ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Elasticsearch. Install Elasticsearch from the elastic repository and configure it to run on the localhost IP.&lt;br /&gt;
&lt;br /&gt;
Before installing Elasticsearch, add the elastic repository key to the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add - &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add elastic 5.x repository to the &#039;sources.list.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; echo &amp;quot;deb https://artifacts.elastic.co/packages/5.x/apt stable main&amp;quot; | sudo tee -a /etc/apt/sources.list.d/elastic-5.x.list &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Update the repository and install Elasticsearch 5.1 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Elasticsearch is installed. Now go to the configuration directory and edit the elasticsaerch.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; cd /etc/elasticsearch/ &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano elasticsearch.yml &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enable memory lock for Elasticsearch by removing the comment on line 43. We do this to disable swapping memory for Elasticsearchto avoid overloading the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; bootstrap.memory_lock: true &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the &#039;Network&#039; block, uncomment the network.host and http.port lines.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;network.host: localhost&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;http.port: 9200&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Now edit the elasticsearch service file for the memory lock mlockall configuration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /usr/lib/systemd/system/elasticsearch.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment LimitMEMLOCK line.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;LimitMEMLOCK=infinity&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit.&lt;br /&gt;
&lt;br /&gt;
Edit the default configuration for Elasticsearch in the /etc/default directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano /etc/default/elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment line 60 and make sure the value is &#039;unlimited&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;MAX_LOCKED_MEMORY=unlimited&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
The Elasticsearch configuration is finished. Elasticsearch will run under localhost IP address with port 9200 and we disabled swap memory by enabling mlockall on the Ubuntu server.&lt;br /&gt;
&lt;br /&gt;
Reload the Elasticsearch service file and enable it to run on the boot time, then start the service.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl daemon-reload&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable elasticsearch&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start elasticsearch&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Wait a sec for Elasticsearch to run, then check the open port on the server, make sure the &#039;state&#039; for port 9200 is &#039;LISTEN&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;netstat -plntu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then check the memory lock to ensure that mlockall is enabled. Also check that Elasticsearch is running with the commands below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
curl -XGET &#039;localhost:9200/_nodes?filter_path=**.mlockall&amp;amp;pretty&#039;&lt;br /&gt;
&lt;br /&gt;
curl -XGET &#039;localhost:9200/?pretty&#039;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see the results below.&lt;br /&gt;
&lt;br /&gt;
== Step 3 - Install and Configure Kibana with Nginx ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Kibana behind a Nginx web server. Kibana will listen on the localhost IP address only and Nginx acts as the reverse proxy for the Kibana application.&lt;br /&gt;
&lt;br /&gt;
Install Kibana with this apt command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y kibana&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the kibana.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /etc/kibana/kibana.yml&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment the server.port, server.hos and elasticsearch.url lines.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
server.port: 5601&lt;br /&gt;
&lt;br /&gt;
server.host: &amp;quot;localhost&amp;quot;&lt;br /&gt;
&lt;br /&gt;
elasticsearch.url: &amp;quot;http://localhost:9200&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Add Kibana to run at boot and start it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl enable kibana&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start kibana&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana will run on port 5601 as node application.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
netstat -plntu&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana installation is done, now we need to install Nginx and configure it as a reverse proxy to be able to access Kibana from the public IP address.&lt;br /&gt;
&lt;br /&gt;
Next, install the Nginx and apache2-utils packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo apt-get install -y nginx apache2-utils&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Apache2-utils is a package that contains tools for the webserver that work with Nginx as well, we will use htpasswd basic authentication for Kibana.&lt;br /&gt;
&lt;br /&gt;
Nginx has been installed. Now we need to create a new virtual host configuration file in the Nginx sites-available directory. Create a new file &#039;kibana&#039; with nano.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/nginx/&lt;br /&gt;
vim sites-available/kibana&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
    listen 80;&lt;br /&gt;
 &lt;br /&gt;
    server_name elk-stack.co;&lt;br /&gt;
 &lt;br /&gt;
    auth_basic &amp;quot;Restricted Access&amp;quot;;&lt;br /&gt;
    auth_basic_user_file /etc/nginx/.kibana-user;&lt;br /&gt;
 &lt;br /&gt;
    location / {&lt;br /&gt;
        proxy_pass http://localhost:5601;&lt;br /&gt;
        proxy_http_version 1.1;&lt;br /&gt;
        proxy_set_header Upgrade $http_upgrade;&lt;br /&gt;
        proxy_set_header Connection &#039;upgrade&#039;;&lt;br /&gt;
        proxy_set_header Host $host;&lt;br /&gt;
        proxy_cache_bypass $http_upgrade;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano&lt;br /&gt;
&lt;br /&gt;
Create a new basic authentication file with the htpasswd command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo htpasswd -c /etc/nginx/.kibana-user admin&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
TYPE YOUR PASSWORD&lt;br /&gt;
&lt;br /&gt;
Activate the kibana virtual host by creating a symbolic link from the kibana file in &#039;sites-available&#039; to the &#039;sites-enabled&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ln -s /etc/nginx/sites-available/kibana /etc/nginx/sites-enabled/ &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Test the nginx configuration and make sure there is no error, then add nginx to run at boot time and restart nginx.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
nginx -t&lt;br /&gt;
&lt;br /&gt;
systemctl enable nginx&lt;br /&gt;
&lt;br /&gt;
systemctl restart nginx&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Step 4 - Install and Configure Logstash == &lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Logsatash to centralize server logs from client sources with filebeat, then filter and transform all data (Syslog) and transport it to the stash (Elasticsearch).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install Logstash 5 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y logstash&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Edit the hosts file with nano.&lt;br /&gt;
&lt;br /&gt;
nano /etc/hosts&lt;br /&gt;
&lt;br /&gt;
Add the server IP address and hostname.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;10.0.2.15    elk-master&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the hosts file and exit the editor.&lt;br /&gt;
&lt;br /&gt;
Now generate a new SSL certificate file with OpenSSL so the client sources can identify the elastic server.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/logstash/&lt;br /&gt;
&lt;br /&gt;
openssl req -subj /CN=elk-master -x509 -days 3650 -batch -nodes -newkey rsa:4096 -keyout logstash.key -out logstash.crt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change the &#039;/CN&#039; value to the elastic server hostname.&lt;br /&gt;
&lt;br /&gt;
Certificate files will be created in the &#039;/etc/logstash/&#039; directory.&lt;br /&gt;
&lt;br /&gt;
Next, we will create the configuration files for logstash. We will create a configuration file &#039;filebeat-input.conf&#039; as input file from filebeat, &#039;syslog-filter.conf&#039; for syslog processing, and then a &#039;output-elasticsearch.conf&#039; file to define the Elasticsearch output.&lt;br /&gt;
&lt;br /&gt;
Go to the logstash configuration directory and create the new configuration files in the &#039;conf.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/logstash/&lt;br /&gt;
&lt;br /&gt;
nano conf.d/filebeat-input.conf&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Input configuration, paste configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input {&lt;br /&gt;
  beats {&lt;br /&gt;
    port =&amp;gt; 5443&lt;br /&gt;
    type =&amp;gt; syslog&lt;br /&gt;
    ssl =&amp;gt; true&lt;br /&gt;
    ssl_certificate =&amp;gt; &amp;quot;/etc/logstash/logstash.crt&amp;quot;&lt;br /&gt;
    ssl_key =&amp;gt; &amp;quot;/etc/logstash/logstash.key&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Create the syslog-filter.conf file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano conf.d/syslog-filter.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
filter {&lt;br /&gt;
  if [type] == &amp;quot;syslog&amp;quot; {&lt;br /&gt;
    grok {&lt;br /&gt;
      match =&amp;gt; { &amp;quot;message&amp;quot; =&amp;gt; &amp;quot;%{SYSLOGTIMESTAMP:syslog_timestamp} %{SYSLOGHOST:syslog_hostname} %{DATA:syslog_program}(?:\[%{POSINT:syslog_pid}\])?: %{GREEDYDATA:syslog_message}&amp;quot; }&lt;br /&gt;
      add_field =&amp;gt; [ &amp;quot;received_at&amp;quot;, &amp;quot;%{@timestamp}&amp;quot; ]&lt;br /&gt;
      add_field =&amp;gt; [ &amp;quot;received_from&amp;quot;, &amp;quot;%{host}&amp;quot; ]&lt;br /&gt;
    }&lt;br /&gt;
    date {&lt;br /&gt;
      match =&amp;gt; [ &amp;quot;syslog_timestamp&amp;quot;, &amp;quot;MMM  d HH:mm:ss&amp;quot;, &amp;quot;MMM dd HH:mm:ss&amp;quot; ]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We use a filter plugin named &#039;grok&#039; to parse the syslog files.&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Create the output configuration file &#039;output-elasticsearch.conf&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano conf.d/output-elasticsearch.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
output {&lt;br /&gt;
  elasticsearch { hosts =&amp;gt; [&amp;quot;localhost:9200&amp;quot;]&lt;br /&gt;
    hosts =&amp;gt; &amp;quot;localhost:9200&amp;quot;&lt;br /&gt;
    manage_template =&amp;gt; false&lt;br /&gt;
    index =&amp;gt; &amp;quot;%{[@metadata][beat]}-%{+YYYY.MM.dd}&amp;quot;&lt;br /&gt;
    document_type =&amp;gt; &amp;quot;%{[@metadata][type]}&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
When this is done, add logstash to start at boot time and start the service.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable logstash&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start logstash&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Alternatives of ELK stack (Graylog2) ==&lt;br /&gt;
&lt;br /&gt;
Parse and enrich logs, wire data, and event data from any data source. Graylog also provides centralized configuration management for 3rd party collectors such as beats, fluentd and nxlog. The processing pipelines allow for greater flexibility in routing, blacklisting, modifying and enriching messages in real-time as they enter Graylog. &amp;lt;ref&amp;gt;[https://www.graylog.org/features garylog]&amp;lt;/ref&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mdhasan</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123819</id>
		<title>Logging and monitoring with Elastic stack on Ubuntu 16.04</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123819"/>
		<updated>2017-06-21T21:38:53Z</updated>

		<summary type="html">&lt;p&gt;Mdhasan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
Logging and monitoring of IT systems is very important part of information security. Proper system logs and monitoring can prevent cyber attacks or service failure. In this wiki we will learn how configure logging and monitoring with ELK stack in Ubuntu server 16.04 andwhat is alternatives (Graylog) of ELK stack and disadvantages of ELK stack.      &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Elasticsearch&#039;&#039;&#039; is an open source search engine based on Lucene, developed in java. It provides a distributed and multitenant [https://en.wikipedia.org/wiki/Full-text_search full-text search engine] with an HTTP Dashboard web-interface (Kibana) and JSON documents scheme. Elasticsearch is a scalable search engine that can be used to search for all types of documents, including log file. Elasticsearch is the heart of the &#039;Elastic Stack&#039; or ELK Stack.&amp;lt;ref&amp;gt;[https://www.elastic.co/products/elasticsearch] Elastic Search Homepage&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Logstash&#039;&#039;&#039; is an open source, server-side data processing pipeline that ingests data from a multitude of sources simultaneously, transforms it, and then sends it to Elasticsearch.&amp;lt;ref&amp;gt;[https://www.elastic.co/products/logstash] Logstash homepage&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Kibana&#039;&#039;&#039; is a data visualization interface for Elasticsearch. Kibana provides a pretty dashboard (web interfaces), it allows you to manage and visualize all data from Elasticsearch on your own. &amp;lt;ref&amp;gt;[https://www.elastic.co/products/kibana] kibana homepage&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Prerequisite ==&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit server with 4GB of RAM, hostname - elk-master&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit client with 1 GB of RAM, hostname - elk-client&lt;br /&gt;
&lt;br /&gt;
Following installation steps from 1 to 4 is collected from &lt;br /&gt;
&lt;br /&gt;
[http://www.howtoforge.com HowToFroge.com]&amp;lt;ref&amp;gt;[http://thehackernews.com/2013/10/importance-of-logs-and-log-management.html]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Virtual Box setup ==&lt;br /&gt;
&lt;br /&gt;
As we are going to use Ubuntu server 16.04, which has no Graphical user interface (GUI). It is better to add a GUI client to Ubuntu server and ssh to virtual box setup. Here I will show to how to connect to Ubuntu server from a Ubuntu desktop client via SSH in Virtual box. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Step 1 - Virtual box Networking&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
- For both Server and Client &lt;br /&gt;
&lt;br /&gt;
- Select the virtual Machine&lt;br /&gt;
&lt;br /&gt;
- go to settings &amp;gt; network&lt;br /&gt;
&lt;br /&gt;
- set Adapter 1 as Internal network (It is better to setup static IP for adapter 1)&lt;br /&gt;
&lt;br /&gt;
- Also Add another network NAT (So the server could have internet access )&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Step 2 - Setup static IP in Ubuntu server (elk-master)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
- Become a root user &amp;lt;code&amp;gt; sudo -i &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Enable SSH by running following commands&amp;lt;ref&amp;gt;[https://askubuntu.com/questions/218344/why-am-i-getting-a-port-22-connection-refused-error open port 22 ]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; &lt;br /&gt;
sudo apt-get update&lt;br /&gt;
&lt;br /&gt;
sudo apt-get install openssh-server&lt;br /&gt;
&lt;br /&gt;
sudo ufw allow 22&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Set up static IP&lt;br /&gt;
&lt;br /&gt;
run this command &amp;lt;code&amp;gt; nano /etc/network/interfaces &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you set a static IP for primary network as screenshot:&lt;br /&gt;
&lt;br /&gt;
[[File:Static-ip-elk-master.PNG]]&lt;br /&gt;
&lt;br /&gt;
- Now go to &amp;lt;code&amp;gt;nano /etc/hosts &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add IP addresses of elk-master and elk-client as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
192.168.2.105 elk-master&lt;br /&gt;
192.168.2.106 elk-client&lt;br /&gt;
&amp;lt;/pre&amp;gt;[[File:Elk-master-hostd.PNG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Step 2 - Setup static IP for Ubuntu Desktop(elk-client)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
- Open terminal &lt;br /&gt;
&lt;br /&gt;
- log in as root user &lt;br /&gt;
&lt;br /&gt;
- Run following command for Openssh&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; &lt;br /&gt;
sudo apt-get update&lt;br /&gt;
&lt;br /&gt;
sudo apt-get install openssh-server&lt;br /&gt;
&lt;br /&gt;
sudo ufw allow 22&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Go to &amp;lt;code&amp;gt; nano /etc/network/interfaces &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Set static IP (example: 192.168.2.106) like ubuntu server &lt;br /&gt;
&lt;br /&gt;
- restart the Ubuntu desktop &lt;br /&gt;
&lt;br /&gt;
- Now ping ELK-MASTER by running this command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; ping elk-master &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Ping-elk-master.PNG]]&lt;br /&gt;
&lt;br /&gt;
- Connect to elk-master via ssh by this command here naz is the username for elk-master&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; ssh naz@elk-master &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Ssh-to-elk-master.PNG]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If you have follow the above steps for virtual box, now you are ready to install the ELK stack.&lt;br /&gt;
&lt;br /&gt;
== Step 1 - Install Java ==&lt;br /&gt;
&lt;br /&gt;
Java is required for the Elastic stack deployment. Elasticsearch requires Java 8. It is recommended to use the Oracle JDK 1.8. We will install Java 8 from a PPA repository.&lt;br /&gt;
&lt;br /&gt;
Install the new package &#039;&#039;&#039;&#039;python-software-properties&#039;&#039;&#039;&#039; so we can add a new repository easily with an apt command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y python-software-properties software-properties-common apt-transport-https&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the new Java 8 PPA repository with the &#039;add-apt-repository&#039; command, then update the repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo add-apt-repository ppa:webupd8team/java -y &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install Java 8 from the PPA webpub8 repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y oracle-java8-installer&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 2 - Install and Configure Elasticsearch ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Elasticsearch. Install Elasticsearch from the elastic repository and configure it to run on the localhost IP.&lt;br /&gt;
&lt;br /&gt;
Before installing Elasticsearch, add the elastic repository key to the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add - &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add elastic 5.x repository to the &#039;sources.list.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; echo &amp;quot;deb https://artifacts.elastic.co/packages/5.x/apt stable main&amp;quot; | sudo tee -a /etc/apt/sources.list.d/elastic-5.x.list &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Update the repository and install Elasticsearch 5.1 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Elasticsearch is installed. Now go to the configuration directory and edit the elasticsaerch.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; cd /etc/elasticsearch/ &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano elasticsearch.yml &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enable memory lock for Elasticsearch by removing the comment on line 43. We do this to disable swapping memory for Elasticsearchto avoid overloading the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; bootstrap.memory_lock: true &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the &#039;Network&#039; block, uncomment the network.host and http.port lines.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;network.host: localhost&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;http.port: 9200&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Now edit the elasticsearch service file for the memory lock mlockall configuration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /usr/lib/systemd/system/elasticsearch.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment LimitMEMLOCK line.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;LimitMEMLOCK=infinity&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit.&lt;br /&gt;
&lt;br /&gt;
Edit the default configuration for Elasticsearch in the /etc/default directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano /etc/default/elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment line 60 and make sure the value is &#039;unlimited&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;MAX_LOCKED_MEMORY=unlimited&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
The Elasticsearch configuration is finished. Elasticsearch will run under localhost IP address with port 9200 and we disabled swap memory by enabling mlockall on the Ubuntu server.&lt;br /&gt;
&lt;br /&gt;
Reload the Elasticsearch service file and enable it to run on the boot time, then start the service.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl daemon-reload&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable elasticsearch&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start elasticsearch&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Wait a sec for Elasticsearch to run, then check the open port on the server, make sure the &#039;state&#039; for port 9200 is &#039;LISTEN&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;netstat -plntu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then check the memory lock to ensure that mlockall is enabled. Also check that Elasticsearch is running with the commands below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
curl -XGET &#039;localhost:9200/_nodes?filter_path=**.mlockall&amp;amp;pretty&#039;&lt;br /&gt;
&lt;br /&gt;
curl -XGET &#039;localhost:9200/?pretty&#039;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see the results below.&lt;br /&gt;
&lt;br /&gt;
== Step 3 - Install and Configure Kibana with Nginx ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Kibana behind a Nginx web server. Kibana will listen on the localhost IP address only and Nginx acts as the reverse proxy for the Kibana application.&lt;br /&gt;
&lt;br /&gt;
Install Kibana with this apt command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y kibana&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the kibana.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /etc/kibana/kibana.yml&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment the server.port, server.hos and elasticsearch.url lines.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
server.port: 5601&lt;br /&gt;
&lt;br /&gt;
server.host: &amp;quot;localhost&amp;quot;&lt;br /&gt;
&lt;br /&gt;
elasticsearch.url: &amp;quot;http://localhost:9200&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Add Kibana to run at boot and start it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl enable kibana&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start kibana&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana will run on port 5601 as node application.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
netstat -plntu&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana installation is done, now we need to install Nginx and configure it as a reverse proxy to be able to access Kibana from the public IP address.&lt;br /&gt;
&lt;br /&gt;
Next, install the Nginx and apache2-utils packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo apt-get install -y nginx apache2-utils&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Apache2-utils is a package that contains tools for the webserver that work with Nginx as well, we will use htpasswd basic authentication for Kibana.&lt;br /&gt;
&lt;br /&gt;
Nginx has been installed. Now we need to create a new virtual host configuration file in the Nginx sites-available directory. Create a new file &#039;kibana&#039; with nano.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/nginx/&lt;br /&gt;
vim sites-available/kibana&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
    listen 80;&lt;br /&gt;
 &lt;br /&gt;
    server_name elk-stack.co;&lt;br /&gt;
 &lt;br /&gt;
    auth_basic &amp;quot;Restricted Access&amp;quot;;&lt;br /&gt;
    auth_basic_user_file /etc/nginx/.kibana-user;&lt;br /&gt;
 &lt;br /&gt;
    location / {&lt;br /&gt;
        proxy_pass http://localhost:5601;&lt;br /&gt;
        proxy_http_version 1.1;&lt;br /&gt;
        proxy_set_header Upgrade $http_upgrade;&lt;br /&gt;
        proxy_set_header Connection &#039;upgrade&#039;;&lt;br /&gt;
        proxy_set_header Host $host;&lt;br /&gt;
        proxy_cache_bypass $http_upgrade;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano&lt;br /&gt;
&lt;br /&gt;
Create a new basic authentication file with the htpasswd command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo htpasswd -c /etc/nginx/.kibana-user admin&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
TYPE YOUR PASSWORD&lt;br /&gt;
&lt;br /&gt;
Activate the kibana virtual host by creating a symbolic link from the kibana file in &#039;sites-available&#039; to the &#039;sites-enabled&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ln -s /etc/nginx/sites-available/kibana /etc/nginx/sites-enabled/ &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Test the nginx configuration and make sure there is no error, then add nginx to run at boot time and restart nginx.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
nginx -t&lt;br /&gt;
&lt;br /&gt;
systemctl enable nginx&lt;br /&gt;
&lt;br /&gt;
systemctl restart nginx&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Step 4 - Install and Configure Logstash == &lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Logsatash to centralize server logs from client sources with filebeat, then filter and transform all data (Syslog) and transport it to the stash (Elasticsearch).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install Logstash 5 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y logstash&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Edit the hosts file with nano.&lt;br /&gt;
&lt;br /&gt;
nano /etc/hosts&lt;br /&gt;
&lt;br /&gt;
Add the server IP address and hostname.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;10.0.2.15    elk-master&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the hosts file and exit the editor.&lt;br /&gt;
&lt;br /&gt;
Now generate a new SSL certificate file with OpenSSL so the client sources can identify the elastic server.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/logstash/&lt;br /&gt;
&lt;br /&gt;
openssl req -subj /CN=elk-master -x509 -days 3650 -batch -nodes -newkey rsa:4096 -keyout logstash.key -out logstash.crt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change the &#039;/CN&#039; value to the elastic server hostname.&lt;br /&gt;
&lt;br /&gt;
Certificate files will be created in the &#039;/etc/logstash/&#039; directory.&lt;br /&gt;
&lt;br /&gt;
Next, we will create the configuration files for logstash. We will create a configuration file &#039;filebeat-input.conf&#039; as input file from filebeat, &#039;syslog-filter.conf&#039; for syslog processing, and then a &#039;output-elasticsearch.conf&#039; file to define the Elasticsearch output.&lt;br /&gt;
&lt;br /&gt;
Go to the logstash configuration directory and create the new configuration files in the &#039;conf.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/logstash/&lt;br /&gt;
&lt;br /&gt;
nano conf.d/filebeat-input.conf&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Input configuration, paste configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input {&lt;br /&gt;
  beats {&lt;br /&gt;
    port =&amp;gt; 5443&lt;br /&gt;
    type =&amp;gt; syslog&lt;br /&gt;
    ssl =&amp;gt; true&lt;br /&gt;
    ssl_certificate =&amp;gt; &amp;quot;/etc/logstash/logstash.crt&amp;quot;&lt;br /&gt;
    ssl_key =&amp;gt; &amp;quot;/etc/logstash/logstash.key&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Create the syslog-filter.conf file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano conf.d/syslog-filter.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
filter {&lt;br /&gt;
  if [type] == &amp;quot;syslog&amp;quot; {&lt;br /&gt;
    grok {&lt;br /&gt;
      match =&amp;gt; { &amp;quot;message&amp;quot; =&amp;gt; &amp;quot;%{SYSLOGTIMESTAMP:syslog_timestamp} %{SYSLOGHOST:syslog_hostname} %{DATA:syslog_program}(?:\[%{POSINT:syslog_pid}\])?: %{GREEDYDATA:syslog_message}&amp;quot; }&lt;br /&gt;
      add_field =&amp;gt; [ &amp;quot;received_at&amp;quot;, &amp;quot;%{@timestamp}&amp;quot; ]&lt;br /&gt;
      add_field =&amp;gt; [ &amp;quot;received_from&amp;quot;, &amp;quot;%{host}&amp;quot; ]&lt;br /&gt;
    }&lt;br /&gt;
    date {&lt;br /&gt;
      match =&amp;gt; [ &amp;quot;syslog_timestamp&amp;quot;, &amp;quot;MMM  d HH:mm:ss&amp;quot;, &amp;quot;MMM dd HH:mm:ss&amp;quot; ]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We use a filter plugin named &#039;grok&#039; to parse the syslog files.&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Create the output configuration file &#039;output-elasticsearch.conf&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano conf.d/output-elasticsearch.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
output {&lt;br /&gt;
  elasticsearch { hosts =&amp;gt; [&amp;quot;localhost:9200&amp;quot;]&lt;br /&gt;
    hosts =&amp;gt; &amp;quot;localhost:9200&amp;quot;&lt;br /&gt;
    manage_template =&amp;gt; false&lt;br /&gt;
    index =&amp;gt; &amp;quot;%{[@metadata][beat]}-%{+YYYY.MM.dd}&amp;quot;&lt;br /&gt;
    document_type =&amp;gt; &amp;quot;%{[@metadata][type]}&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
When this is done, add logstash to start at boot time and start the service.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable logstash&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start logstash&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Alternatives of ELK stack (Graylog2) ==&lt;/div&gt;</summary>
		<author><name>Mdhasan</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123818</id>
		<title>Logging and monitoring with Elastic stack on Ubuntu 16.04</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123818"/>
		<updated>2017-06-21T21:36:59Z</updated>

		<summary type="html">&lt;p&gt;Mdhasan: /* Virtual Box setup */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
Logging and monitoring of IT systems is very important part of information security. Proper system logs and monitoring can prevent cyber attacks or service failure. In this wiki we will learn how configure logging and monitoring with ELK stack in Ubuntu server 16.04 andwhat is alternatives (Graylog) of ELK stack and disadvantages of ELK stack.      &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Elasticsearch&#039;&#039;&#039; is an open source search engine based on Lucene, developed in java. It provides a distributed and multitenant [https://en.wikipedia.org/wiki/Full-text_search full-text search engine] with an HTTP Dashboard web-interface (Kibana) and JSON documents scheme. Elasticsearch is a scalable search engine that can be used to search for all types of documents, including log file. Elasticsearch is the heart of the &#039;Elastic Stack&#039; or ELK Stack.&amp;lt;ref&amp;gt;[https://www.elastic.co/products/elasticsearch] Elastic Search Homepage&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Logstash&#039;&#039;&#039; is an open source, server-side data processing pipeline that ingests data from a multitude of sources simultaneously, transforms it, and then sends it to Elasticsearch.&amp;lt;ref&amp;gt;[https://www.elastic.co/products/logstash] Logstash homepage&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Kibana&#039;&#039;&#039; is a data visualization interface for Elasticsearch. Kibana provides a pretty dashboard (web interfaces), it allows you to manage and visualize all data from Elasticsearch on your own. &amp;lt;ref&amp;gt;[https://www.elastic.co/products/kibana] kibana homepage&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Prerequisite ==&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit server with 4GB of RAM, hostname - elk-master&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit client with 1 GB of RAM, hostname - elk-client&lt;br /&gt;
&lt;br /&gt;
Following installation steps from 1 to 4 is collected from &lt;br /&gt;
&lt;br /&gt;
[http://www.howtoforge.com HowToFroge.com]&amp;lt;ref&amp;gt;[http://thehackernews.com/2013/10/importance-of-logs-and-log-management.html]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Virtual Box setup ==&lt;br /&gt;
&lt;br /&gt;
As we are going to use Ubuntu server 16.04, which has no Graphical user interface (GUI). It is better to add a GUI client to Ubuntu server and ssh to virtual box setup. Here I will show to how to connect to Ubuntu server from a Ubuntu desktop client via SSH in Virtual box. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Step 1 - Virtual box Networking&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
- For both Server and Client &lt;br /&gt;
&lt;br /&gt;
- Select the virtual Machine&lt;br /&gt;
&lt;br /&gt;
- go to settings &amp;gt; network&lt;br /&gt;
&lt;br /&gt;
- set Adapter 1 as Internal network (It is better to setup static IP for adapter 1)&lt;br /&gt;
&lt;br /&gt;
- Also Add another network NAT (So the server could have internet access )&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Step 2 - Setup static IP in Ubuntu server (elk-master)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
- Become a root user &amp;lt;code&amp;gt; sudo -i &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Enable SSH by running following commands&amp;lt;ref&amp;gt;[https://askubuntu.com/questions/218344/why-am-i-getting-a-port-22-connection-refused-error open port 22 ]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; &lt;br /&gt;
sudo apt-get update&lt;br /&gt;
&lt;br /&gt;
sudo apt-get install openssh-server&lt;br /&gt;
&lt;br /&gt;
sudo ufw allow 22&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Set up static IP&lt;br /&gt;
&lt;br /&gt;
run this command &amp;lt;code&amp;gt; nano /etc/network/interfaces &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you set a static IP for primary network as screenshot:&lt;br /&gt;
&lt;br /&gt;
[[File:Static-ip-elk-master.PNG]]&lt;br /&gt;
&lt;br /&gt;
- Now go to &amp;lt;code&amp;gt;nano /etc/hosts &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add IP addresses of elk-master and elk-client as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
192.168.2.105 elk-master&lt;br /&gt;
192.168.2.106 elk-client&lt;br /&gt;
&amp;lt;/pre&amp;gt;[[File:Elk-master-hostd.PNG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Step 2 - Setup static IP for Ubuntu Desktop(elk-client)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
- Open terminal &lt;br /&gt;
&lt;br /&gt;
- log in as root user &lt;br /&gt;
&lt;br /&gt;
- Run following command for Openssh&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; &lt;br /&gt;
sudo apt-get update&lt;br /&gt;
&lt;br /&gt;
sudo apt-get install openssh-server&lt;br /&gt;
&lt;br /&gt;
sudo ufw allow 22&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Go to &amp;lt;code&amp;gt; nano /etc/network/interfaces &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Set static IP (example: 192.168.2.106) like ubuntu server &lt;br /&gt;
&lt;br /&gt;
- restart the Ubuntu desktop &lt;br /&gt;
&lt;br /&gt;
- Now ping ELK-MASTER by running this command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; ping elk-master &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Ping-elk-master.PNG]]&lt;br /&gt;
&lt;br /&gt;
- Connect to elk-master via ssh by this command here naz is the username for elk-master&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; ssh naz@elk-master &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Ssh-to-elk-master.PNG]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If you have follow the above steps for virtual box, now you are ready to install the ELK stack.&lt;br /&gt;
&lt;br /&gt;
== Step 1 - Install Java ==&lt;br /&gt;
&lt;br /&gt;
Java is required for the Elastic stack deployment. Elasticsearch requires Java 8. It is recommended to use the Oracle JDK 1.8. We will install Java 8 from a PPA repository.&lt;br /&gt;
&lt;br /&gt;
Install the new package &#039;&#039;&#039;&#039;python-software-properties&#039;&#039;&#039;&#039; so we can add a new repository easily with an apt command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y python-software-properties software-properties-common apt-transport-https&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the new Java 8 PPA repository with the &#039;add-apt-repository&#039; command, then update the repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo add-apt-repository ppa:webupd8team/java -y &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install Java 8 from the PPA webpub8 repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y oracle-java8-installer&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 2 - Install and Configure Elasticsearch ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Elasticsearch. Install Elasticsearch from the elastic repository and configure it to run on the localhost IP.&lt;br /&gt;
&lt;br /&gt;
Before installing Elasticsearch, add the elastic repository key to the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add - &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add elastic 5.x repository to the &#039;sources.list.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; echo &amp;quot;deb https://artifacts.elastic.co/packages/5.x/apt stable main&amp;quot; | sudo tee -a /etc/apt/sources.list.d/elastic-5.x.list &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Update the repository and install Elasticsearch 5.1 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Elasticsearch is installed. Now go to the configuration directory and edit the elasticsaerch.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; cd /etc/elasticsearch/ &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano elasticsearch.yml &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enable memory lock for Elasticsearch by removing the comment on line 43. We do this to disable swapping memory for Elasticsearchto avoid overloading the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; bootstrap.memory_lock: true &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the &#039;Network&#039; block, uncomment the network.host and http.port lines.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;network.host: localhost&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;http.port: 9200&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Now edit the elasticsearch service file for the memory lock mlockall configuration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /usr/lib/systemd/system/elasticsearch.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment LimitMEMLOCK line.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;LimitMEMLOCK=infinity&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit.&lt;br /&gt;
&lt;br /&gt;
Edit the default configuration for Elasticsearch in the /etc/default directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano /etc/default/elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment line 60 and make sure the value is &#039;unlimited&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;MAX_LOCKED_MEMORY=unlimited&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
The Elasticsearch configuration is finished. Elasticsearch will run under localhost IP address with port 9200 and we disabled swap memory by enabling mlockall on the Ubuntu server.&lt;br /&gt;
&lt;br /&gt;
Reload the Elasticsearch service file and enable it to run on the boot time, then start the service.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl daemon-reload&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable elasticsearch&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start elasticsearch&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Wait a sec for Elasticsearch to run, then check the open port on the server, make sure the &#039;state&#039; for port 9200 is &#039;LISTEN&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;netstat -plntu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then check the memory lock to ensure that mlockall is enabled. Also check that Elasticsearch is running with the commands below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
curl -XGET &#039;localhost:9200/_nodes?filter_path=**.mlockall&amp;amp;pretty&#039;&lt;br /&gt;
&lt;br /&gt;
curl -XGET &#039;localhost:9200/?pretty&#039;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see the results below.&lt;br /&gt;
&lt;br /&gt;
== Step 3 - Install and Configure Kibana with Nginx ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Kibana behind a Nginx web server. Kibana will listen on the localhost IP address only and Nginx acts as the reverse proxy for the Kibana application.&lt;br /&gt;
&lt;br /&gt;
Install Kibana with this apt command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y kibana&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the kibana.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /etc/kibana/kibana.yml&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment the server.port, server.hos and elasticsearch.url lines.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
server.port: 5601&lt;br /&gt;
&lt;br /&gt;
server.host: &amp;quot;localhost&amp;quot;&lt;br /&gt;
&lt;br /&gt;
elasticsearch.url: &amp;quot;http://localhost:9200&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Add Kibana to run at boot and start it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl enable kibana&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start kibana&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana will run on port 5601 as node application.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
netstat -plntu&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana installation is done, now we need to install Nginx and configure it as a reverse proxy to be able to access Kibana from the public IP address.&lt;br /&gt;
&lt;br /&gt;
Next, install the Nginx and apache2-utils packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo apt-get install -y nginx apache2-utils&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Apache2-utils is a package that contains tools for the webserver that work with Nginx as well, we will use htpasswd basic authentication for Kibana.&lt;br /&gt;
&lt;br /&gt;
Nginx has been installed. Now we need to create a new virtual host configuration file in the Nginx sites-available directory. Create a new file &#039;kibana&#039; with nano.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/nginx/&lt;br /&gt;
vim sites-available/kibana&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
    listen 80;&lt;br /&gt;
 &lt;br /&gt;
    server_name elk-stack.co;&lt;br /&gt;
 &lt;br /&gt;
    auth_basic &amp;quot;Restricted Access&amp;quot;;&lt;br /&gt;
    auth_basic_user_file /etc/nginx/.kibana-user;&lt;br /&gt;
 &lt;br /&gt;
    location / {&lt;br /&gt;
        proxy_pass http://localhost:5601;&lt;br /&gt;
        proxy_http_version 1.1;&lt;br /&gt;
        proxy_set_header Upgrade $http_upgrade;&lt;br /&gt;
        proxy_set_header Connection &#039;upgrade&#039;;&lt;br /&gt;
        proxy_set_header Host $host;&lt;br /&gt;
        proxy_cache_bypass $http_upgrade;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano&lt;br /&gt;
&lt;br /&gt;
Create a new basic authentication file with the htpasswd command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo htpasswd -c /etc/nginx/.kibana-user admin&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
TYPE YOUR PASSWORD&lt;br /&gt;
&lt;br /&gt;
Activate the kibana virtual host by creating a symbolic link from the kibana file in &#039;sites-available&#039; to the &#039;sites-enabled&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ln -s /etc/nginx/sites-available/kibana /etc/nginx/sites-enabled/ &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Test the nginx configuration and make sure there is no error, then add nginx to run at boot time and restart nginx.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
nginx -t&lt;br /&gt;
&lt;br /&gt;
systemctl enable nginx&lt;br /&gt;
&lt;br /&gt;
systemctl restart nginx&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Step 4 - Install and Configure Logstash == &lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Logsatash to centralize server logs from client sources with filebeat, then filter and transform all data (Syslog) and transport it to the stash (Elasticsearch).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install Logstash 5 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y logstash&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Edit the hosts file with nano.&lt;br /&gt;
&lt;br /&gt;
nano /etc/hosts&lt;br /&gt;
&lt;br /&gt;
Add the server IP address and hostname.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;10.0.2.15    elk-master&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the hosts file and exit the editor.&lt;br /&gt;
&lt;br /&gt;
Now generate a new SSL certificate file with OpenSSL so the client sources can identify the elastic server.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/logstash/&lt;br /&gt;
&lt;br /&gt;
openssl req -subj /CN=elk-master -x509 -days 3650 -batch -nodes -newkey rsa:4096 -keyout logstash.key -out logstash.crt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change the &#039;/CN&#039; value to the elastic server hostname.&lt;br /&gt;
&lt;br /&gt;
Certificate files will be created in the &#039;/etc/logstash/&#039; directory.&lt;br /&gt;
&lt;br /&gt;
Next, we will create the configuration files for logstash. We will create a configuration file &#039;filebeat-input.conf&#039; as input file from filebeat, &#039;syslog-filter.conf&#039; for syslog processing, and then a &#039;output-elasticsearch.conf&#039; file to define the Elasticsearch output.&lt;br /&gt;
&lt;br /&gt;
Go to the logstash configuration directory and create the new configuration files in the &#039;conf.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/logstash/&lt;br /&gt;
&lt;br /&gt;
nano conf.d/filebeat-input.conf&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Input configuration, paste configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input {&lt;br /&gt;
  beats {&lt;br /&gt;
    port =&amp;gt; 5443&lt;br /&gt;
    type =&amp;gt; syslog&lt;br /&gt;
    ssl =&amp;gt; true&lt;br /&gt;
    ssl_certificate =&amp;gt; &amp;quot;/etc/logstash/logstash.crt&amp;quot;&lt;br /&gt;
    ssl_key =&amp;gt; &amp;quot;/etc/logstash/logstash.key&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Create the syslog-filter.conf file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano conf.d/syslog-filter.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
filter {&lt;br /&gt;
  if [type] == &amp;quot;syslog&amp;quot; {&lt;br /&gt;
    grok {&lt;br /&gt;
      match =&amp;gt; { &amp;quot;message&amp;quot; =&amp;gt; &amp;quot;%{SYSLOGTIMESTAMP:syslog_timestamp} %{SYSLOGHOST:syslog_hostname} %{DATA:syslog_program}(?:\[%{POSINT:syslog_pid}\])?: %{GREEDYDATA:syslog_message}&amp;quot; }&lt;br /&gt;
      add_field =&amp;gt; [ &amp;quot;received_at&amp;quot;, &amp;quot;%{@timestamp}&amp;quot; ]&lt;br /&gt;
      add_field =&amp;gt; [ &amp;quot;received_from&amp;quot;, &amp;quot;%{host}&amp;quot; ]&lt;br /&gt;
    }&lt;br /&gt;
    date {&lt;br /&gt;
      match =&amp;gt; [ &amp;quot;syslog_timestamp&amp;quot;, &amp;quot;MMM  d HH:mm:ss&amp;quot;, &amp;quot;MMM dd HH:mm:ss&amp;quot; ]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We use a filter plugin named &#039;grok&#039; to parse the syslog files.&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Create the output configuration file &#039;output-elasticsearch.conf&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano conf.d/output-elasticsearch.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
output {&lt;br /&gt;
  elasticsearch { hosts =&amp;gt; [&amp;quot;localhost:9200&amp;quot;]&lt;br /&gt;
    hosts =&amp;gt; &amp;quot;localhost:9200&amp;quot;&lt;br /&gt;
    manage_template =&amp;gt; false&lt;br /&gt;
    index =&amp;gt; &amp;quot;%{[@metadata][beat]}-%{+YYYY.MM.dd}&amp;quot;&lt;br /&gt;
    document_type =&amp;gt; &amp;quot;%{[@metadata][type]}&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
When this is done, add logstash to start at boot time and start the service.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable logstash&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start logstash&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mdhasan</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123817</id>
		<title>Logging and monitoring with Elastic stack on Ubuntu 16.04</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123817"/>
		<updated>2017-06-21T21:35:35Z</updated>

		<summary type="html">&lt;p&gt;Mdhasan: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
Logging and monitoring of IT systems is very important part of information security. Proper system logs and monitoring can prevent cyber attacks or service failure. In this wiki we will learn how configure logging and monitoring with ELK stack in Ubuntu server 16.04 andwhat is alternatives (Graylog) of ELK stack and disadvantages of ELK stack.      &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Elasticsearch&#039;&#039;&#039; is an open source search engine based on Lucene, developed in java. It provides a distributed and multitenant [https://en.wikipedia.org/wiki/Full-text_search full-text search engine] with an HTTP Dashboard web-interface (Kibana) and JSON documents scheme. Elasticsearch is a scalable search engine that can be used to search for all types of documents, including log file. Elasticsearch is the heart of the &#039;Elastic Stack&#039; or ELK Stack.&amp;lt;ref&amp;gt;[https://www.elastic.co/products/elasticsearch] Elastic Search Homepage&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Logstash&#039;&#039;&#039; is an open source, server-side data processing pipeline that ingests data from a multitude of sources simultaneously, transforms it, and then sends it to Elasticsearch.&amp;lt;ref&amp;gt;[https://www.elastic.co/products/logstash] Logstash homepage&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Kibana&#039;&#039;&#039; is a data visualization interface for Elasticsearch. Kibana provides a pretty dashboard (web interfaces), it allows you to manage and visualize all data from Elasticsearch on your own. &amp;lt;ref&amp;gt;[https://www.elastic.co/products/kibana] kibana homepage&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Prerequisite ==&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit server with 4GB of RAM, hostname - elk-master&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit client with 1 GB of RAM, hostname - elk-client&lt;br /&gt;
&lt;br /&gt;
Following installation steps from 1 to 4 is collected from &lt;br /&gt;
&lt;br /&gt;
[http://www.howtoforge.com HowToFroge.com]&amp;lt;ref&amp;gt;[http://thehackernews.com/2013/10/importance-of-logs-and-log-management.html]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Virtual Box setup ==&lt;br /&gt;
&lt;br /&gt;
As we are going to use Ubuntu server 16.04, which has no Graphical user interface (GUI). It is better to add a GUI client to Ubuntu server and ssh to virtual box setup. Here I will show to how to connect to Ubuntu server from a Ubuntu desktop client via SSH in Virtual box. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Step 1 - Virtual box Networking&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
- For both Server and Client &lt;br /&gt;
&lt;br /&gt;
- Select the virtual Machine&lt;br /&gt;
&lt;br /&gt;
- go to settings &amp;gt; network&lt;br /&gt;
&lt;br /&gt;
- set Adapter 1 as Internal network (It is better to setup static IP for adapter 1)&lt;br /&gt;
&lt;br /&gt;
- Also Add another network NAT (So the server could have internet access )&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Step 2 - Setup static IP in Ubuntu server (elk-master)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
- Become a root user &amp;lt;code&amp;gt; sudo -i &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Enable SSH by running following commands&amp;lt;ref&amp;gt;[https://askubuntu.com/questions/218344/why-am-i-getting-a-port-22-connection-refused-error open port 22 ]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; &lt;br /&gt;
sudo apt-get update&lt;br /&gt;
&lt;br /&gt;
sudo apt-get install openssh-server&lt;br /&gt;
&lt;br /&gt;
sudo ufw allow 22&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Set up static IP&lt;br /&gt;
&lt;br /&gt;
run this command &amp;lt;code&amp;gt; nano /etc/network/interfaces &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you set a static IP for primary network as screenshot:&lt;br /&gt;
&lt;br /&gt;
[[File:Static-ip-elk-master.PNG]]&lt;br /&gt;
&lt;br /&gt;
- Now go to &amp;lt;code&amp;gt;nano /etc/hosts &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add IP addresses of elk-master and elk-client as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
192.168.2.105 elk-master&lt;br /&gt;
192.168.2.106 elk-client&lt;br /&gt;
&amp;lt;/pre&amp;gt;[[File:Elk-master-hostd.PNG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Step 2 - Setup static IP for Ubuntu Desktop(elk-client)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
- Open terminal &lt;br /&gt;
&lt;br /&gt;
- log in as root user &lt;br /&gt;
&lt;br /&gt;
- Run following command for Openssh&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; &lt;br /&gt;
sudo apt-get update&lt;br /&gt;
&lt;br /&gt;
sudo apt-get install openssh-server&lt;br /&gt;
&lt;br /&gt;
sudo ufw allow 22&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Go to &amp;lt;code&amp;gt; nano /etc/network/interfaces &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Set static IP (example: 192.168.2.106) like ubuntu server &lt;br /&gt;
&lt;br /&gt;
- restart the Ubuntu desktop &lt;br /&gt;
&lt;br /&gt;
- Now ping ELK-MASTER by running this command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; ping elk-master &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Ping-elk-master.PNG]]&lt;br /&gt;
&lt;br /&gt;
- Connect to elk-master via ssh by this command here naz is the username for elk-master&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; ssh naz@elk-master &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Ssh-to-elk-master.PNG]]&lt;br /&gt;
&lt;br /&gt;
== Step 1 - Install Java ==&lt;br /&gt;
&lt;br /&gt;
Java is required for the Elastic stack deployment. Elasticsearch requires Java 8. It is recommended to use the Oracle JDK 1.8. We will install Java 8 from a PPA repository.&lt;br /&gt;
&lt;br /&gt;
Install the new package &#039;&#039;&#039;&#039;python-software-properties&#039;&#039;&#039;&#039; so we can add a new repository easily with an apt command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y python-software-properties software-properties-common apt-transport-https&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the new Java 8 PPA repository with the &#039;add-apt-repository&#039; command, then update the repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo add-apt-repository ppa:webupd8team/java -y &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install Java 8 from the PPA webpub8 repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y oracle-java8-installer&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 2 - Install and Configure Elasticsearch ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Elasticsearch. Install Elasticsearch from the elastic repository and configure it to run on the localhost IP.&lt;br /&gt;
&lt;br /&gt;
Before installing Elasticsearch, add the elastic repository key to the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add - &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add elastic 5.x repository to the &#039;sources.list.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; echo &amp;quot;deb https://artifacts.elastic.co/packages/5.x/apt stable main&amp;quot; | sudo tee -a /etc/apt/sources.list.d/elastic-5.x.list &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Update the repository and install Elasticsearch 5.1 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Elasticsearch is installed. Now go to the configuration directory and edit the elasticsaerch.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; cd /etc/elasticsearch/ &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano elasticsearch.yml &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enable memory lock for Elasticsearch by removing the comment on line 43. We do this to disable swapping memory for Elasticsearchto avoid overloading the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; bootstrap.memory_lock: true &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the &#039;Network&#039; block, uncomment the network.host and http.port lines.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;network.host: localhost&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;http.port: 9200&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Now edit the elasticsearch service file for the memory lock mlockall configuration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /usr/lib/systemd/system/elasticsearch.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment LimitMEMLOCK line.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;LimitMEMLOCK=infinity&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit.&lt;br /&gt;
&lt;br /&gt;
Edit the default configuration for Elasticsearch in the /etc/default directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano /etc/default/elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment line 60 and make sure the value is &#039;unlimited&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;MAX_LOCKED_MEMORY=unlimited&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
The Elasticsearch configuration is finished. Elasticsearch will run under localhost IP address with port 9200 and we disabled swap memory by enabling mlockall on the Ubuntu server.&lt;br /&gt;
&lt;br /&gt;
Reload the Elasticsearch service file and enable it to run on the boot time, then start the service.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl daemon-reload&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable elasticsearch&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start elasticsearch&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Wait a sec for Elasticsearch to run, then check the open port on the server, make sure the &#039;state&#039; for port 9200 is &#039;LISTEN&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;netstat -plntu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then check the memory lock to ensure that mlockall is enabled. Also check that Elasticsearch is running with the commands below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
curl -XGET &#039;localhost:9200/_nodes?filter_path=**.mlockall&amp;amp;pretty&#039;&lt;br /&gt;
&lt;br /&gt;
curl -XGET &#039;localhost:9200/?pretty&#039;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see the results below.&lt;br /&gt;
&lt;br /&gt;
== Step 3 - Install and Configure Kibana with Nginx ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Kibana behind a Nginx web server. Kibana will listen on the localhost IP address only and Nginx acts as the reverse proxy for the Kibana application.&lt;br /&gt;
&lt;br /&gt;
Install Kibana with this apt command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y kibana&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the kibana.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /etc/kibana/kibana.yml&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment the server.port, server.hos and elasticsearch.url lines.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
server.port: 5601&lt;br /&gt;
&lt;br /&gt;
server.host: &amp;quot;localhost&amp;quot;&lt;br /&gt;
&lt;br /&gt;
elasticsearch.url: &amp;quot;http://localhost:9200&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Add Kibana to run at boot and start it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl enable kibana&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start kibana&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana will run on port 5601 as node application.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
netstat -plntu&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana installation is done, now we need to install Nginx and configure it as a reverse proxy to be able to access Kibana from the public IP address.&lt;br /&gt;
&lt;br /&gt;
Next, install the Nginx and apache2-utils packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo apt-get install -y nginx apache2-utils&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Apache2-utils is a package that contains tools for the webserver that work with Nginx as well, we will use htpasswd basic authentication for Kibana.&lt;br /&gt;
&lt;br /&gt;
Nginx has been installed. Now we need to create a new virtual host configuration file in the Nginx sites-available directory. Create a new file &#039;kibana&#039; with nano.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/nginx/&lt;br /&gt;
vim sites-available/kibana&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
    listen 80;&lt;br /&gt;
 &lt;br /&gt;
    server_name elk-stack.co;&lt;br /&gt;
 &lt;br /&gt;
    auth_basic &amp;quot;Restricted Access&amp;quot;;&lt;br /&gt;
    auth_basic_user_file /etc/nginx/.kibana-user;&lt;br /&gt;
 &lt;br /&gt;
    location / {&lt;br /&gt;
        proxy_pass http://localhost:5601;&lt;br /&gt;
        proxy_http_version 1.1;&lt;br /&gt;
        proxy_set_header Upgrade $http_upgrade;&lt;br /&gt;
        proxy_set_header Connection &#039;upgrade&#039;;&lt;br /&gt;
        proxy_set_header Host $host;&lt;br /&gt;
        proxy_cache_bypass $http_upgrade;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano&lt;br /&gt;
&lt;br /&gt;
Create a new basic authentication file with the htpasswd command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo htpasswd -c /etc/nginx/.kibana-user admin&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
TYPE YOUR PASSWORD&lt;br /&gt;
&lt;br /&gt;
Activate the kibana virtual host by creating a symbolic link from the kibana file in &#039;sites-available&#039; to the &#039;sites-enabled&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ln -s /etc/nginx/sites-available/kibana /etc/nginx/sites-enabled/ &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Test the nginx configuration and make sure there is no error, then add nginx to run at boot time and restart nginx.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
nginx -t&lt;br /&gt;
&lt;br /&gt;
systemctl enable nginx&lt;br /&gt;
&lt;br /&gt;
systemctl restart nginx&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Step 4 - Install and Configure Logstash == &lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Logsatash to centralize server logs from client sources with filebeat, then filter and transform all data (Syslog) and transport it to the stash (Elasticsearch).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install Logstash 5 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y logstash&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Edit the hosts file with nano.&lt;br /&gt;
&lt;br /&gt;
nano /etc/hosts&lt;br /&gt;
&lt;br /&gt;
Add the server IP address and hostname.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;10.0.2.15    elk-master&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the hosts file and exit the editor.&lt;br /&gt;
&lt;br /&gt;
Now generate a new SSL certificate file with OpenSSL so the client sources can identify the elastic server.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/logstash/&lt;br /&gt;
&lt;br /&gt;
openssl req -subj /CN=elk-master -x509 -days 3650 -batch -nodes -newkey rsa:4096 -keyout logstash.key -out logstash.crt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change the &#039;/CN&#039; value to the elastic server hostname.&lt;br /&gt;
&lt;br /&gt;
Certificate files will be created in the &#039;/etc/logstash/&#039; directory.&lt;br /&gt;
&lt;br /&gt;
Next, we will create the configuration files for logstash. We will create a configuration file &#039;filebeat-input.conf&#039; as input file from filebeat, &#039;syslog-filter.conf&#039; for syslog processing, and then a &#039;output-elasticsearch.conf&#039; file to define the Elasticsearch output.&lt;br /&gt;
&lt;br /&gt;
Go to the logstash configuration directory and create the new configuration files in the &#039;conf.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/logstash/&lt;br /&gt;
&lt;br /&gt;
nano conf.d/filebeat-input.conf&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Input configuration, paste configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input {&lt;br /&gt;
  beats {&lt;br /&gt;
    port =&amp;gt; 5443&lt;br /&gt;
    type =&amp;gt; syslog&lt;br /&gt;
    ssl =&amp;gt; true&lt;br /&gt;
    ssl_certificate =&amp;gt; &amp;quot;/etc/logstash/logstash.crt&amp;quot;&lt;br /&gt;
    ssl_key =&amp;gt; &amp;quot;/etc/logstash/logstash.key&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Create the syslog-filter.conf file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano conf.d/syslog-filter.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
filter {&lt;br /&gt;
  if [type] == &amp;quot;syslog&amp;quot; {&lt;br /&gt;
    grok {&lt;br /&gt;
      match =&amp;gt; { &amp;quot;message&amp;quot; =&amp;gt; &amp;quot;%{SYSLOGTIMESTAMP:syslog_timestamp} %{SYSLOGHOST:syslog_hostname} %{DATA:syslog_program}(?:\[%{POSINT:syslog_pid}\])?: %{GREEDYDATA:syslog_message}&amp;quot; }&lt;br /&gt;
      add_field =&amp;gt; [ &amp;quot;received_at&amp;quot;, &amp;quot;%{@timestamp}&amp;quot; ]&lt;br /&gt;
      add_field =&amp;gt; [ &amp;quot;received_from&amp;quot;, &amp;quot;%{host}&amp;quot; ]&lt;br /&gt;
    }&lt;br /&gt;
    date {&lt;br /&gt;
      match =&amp;gt; [ &amp;quot;syslog_timestamp&amp;quot;, &amp;quot;MMM  d HH:mm:ss&amp;quot;, &amp;quot;MMM dd HH:mm:ss&amp;quot; ]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We use a filter plugin named &#039;grok&#039; to parse the syslog files.&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Create the output configuration file &#039;output-elasticsearch.conf&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano conf.d/output-elasticsearch.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
output {&lt;br /&gt;
  elasticsearch { hosts =&amp;gt; [&amp;quot;localhost:9200&amp;quot;]&lt;br /&gt;
    hosts =&amp;gt; &amp;quot;localhost:9200&amp;quot;&lt;br /&gt;
    manage_template =&amp;gt; false&lt;br /&gt;
    index =&amp;gt; &amp;quot;%{[@metadata][beat]}-%{+YYYY.MM.dd}&amp;quot;&lt;br /&gt;
    document_type =&amp;gt; &amp;quot;%{[@metadata][type]}&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
When this is done, add logstash to start at boot time and start the service.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable logstash&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start logstash&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mdhasan</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123816</id>
		<title>Logging and monitoring with Elastic stack on Ubuntu 16.04</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123816"/>
		<updated>2017-06-21T21:34:34Z</updated>

		<summary type="html">&lt;p&gt;Mdhasan: /* Virtual Box setup */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
Logging and monitoring of IT systems is very important part of information security. Proper system logs and monitoring can prevent cyber attacks or service failure. In this wiki we will learn how configure logging and monitoring with ELK stack in Ubuntu server 16.04, what is alternatives (Graylog) of ELK stack and disadvantages of ELK stack.      &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Elasticsearch&#039;&#039;&#039; is an open source search engine based on Lucene, developed in java. It provides a distributed and multitenant [https://en.wikipedia.org/wiki/Full-text_search full-text search engine] with an HTTP Dashboard web-interface (Kibana) and JSON documents scheme. Elasticsearch is a scalable search engine that can be used to search for all types of documents, including log file. Elasticsearch is the heart of the &#039;Elastic Stack&#039; or ELK Stack.&amp;lt;ref&amp;gt;[https://www.elastic.co/products/elasticsearch] Elastic Search Homepage&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Logstash&#039;&#039;&#039; is an open source, server-side data processing pipeline that ingests data from a multitude of sources simultaneously, transforms it, and then sends it to Elasticsearch.&amp;lt;ref&amp;gt;[https://www.elastic.co/products/logstash] Logstash homepahe&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Kibana&#039;&#039;&#039; is a data visualization interface for Elasticsearch. Kibana provides a pretty dashboard (web interfaces), it allows you to manage and visualize all data from Elasticsearch on your own. &amp;lt;ref&amp;gt;[https://www.elastic.co/products/kibana] kibana homepage&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Prerequisite ==&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit server with 4GB of RAM, hostname - elk-master&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit client with 1 GB of RAM, hostname - elk-client&lt;br /&gt;
&lt;br /&gt;
Following installation steps from 1 to 4 is collected from &lt;br /&gt;
&lt;br /&gt;
[http://www.howtoforge.com HowToFroge.com]&amp;lt;ref&amp;gt;[http://thehackernews.com/2013/10/importance-of-logs-and-log-management.html]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Virtual Box setup ==&lt;br /&gt;
&lt;br /&gt;
As we are going to use Ubuntu server 16.04, which has no Graphical user interface (GUI). It is better to add a GUI client to Ubuntu server and ssh to virtual box setup. Here I will show to how to connect to Ubuntu server from a Ubuntu desktop client via SSH in Virtual box. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Step 1 - Virtual box Networking&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
- For both Server and Client &lt;br /&gt;
&lt;br /&gt;
- Select the virtual Machine&lt;br /&gt;
&lt;br /&gt;
- go to settings &amp;gt; network&lt;br /&gt;
&lt;br /&gt;
- set Adapter 1 as Internal network (It is better to setup static IP for adapter 1)&lt;br /&gt;
&lt;br /&gt;
- Also Add another network NAT (So the server could have internet access )&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Step 2 - Setup static IP in Ubuntu server (elk-master)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
- Become a root user &amp;lt;code&amp;gt; sudo -i &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Enable SSH by running following commands&amp;lt;ref&amp;gt;[https://askubuntu.com/questions/218344/why-am-i-getting-a-port-22-connection-refused-error open port 22 ]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; &lt;br /&gt;
sudo apt-get update&lt;br /&gt;
&lt;br /&gt;
sudo apt-get install openssh-server&lt;br /&gt;
&lt;br /&gt;
sudo ufw allow 22&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Set up static IP&lt;br /&gt;
&lt;br /&gt;
run this command &amp;lt;code&amp;gt; nano /etc/network/interfaces &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you set a static IP for primary network as screenshot:&lt;br /&gt;
&lt;br /&gt;
[[File:Static-ip-elk-master.PNG]]&lt;br /&gt;
&lt;br /&gt;
- Now go to &amp;lt;code&amp;gt;nano /etc/hosts &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add IP addresses of elk-master and elk-client as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
192.168.2.105 elk-master&lt;br /&gt;
192.168.2.106 elk-client&lt;br /&gt;
&amp;lt;/pre&amp;gt;[[File:Elk-master-hostd.PNG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Step 2 - Setup static IP for Ubuntu Desktop(elk-client)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
- Open terminal &lt;br /&gt;
&lt;br /&gt;
- log in as root user &lt;br /&gt;
&lt;br /&gt;
- Run following command for Openssh&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; &lt;br /&gt;
sudo apt-get update&lt;br /&gt;
&lt;br /&gt;
sudo apt-get install openssh-server&lt;br /&gt;
&lt;br /&gt;
sudo ufw allow 22&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Go to &amp;lt;code&amp;gt; nano /etc/network/interfaces &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Set static IP (example: 192.168.2.106) like ubuntu server &lt;br /&gt;
&lt;br /&gt;
- restart the Ubuntu desktop &lt;br /&gt;
&lt;br /&gt;
- Now ping ELK-MASTER by running this command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; ping elk-master &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Ping-elk-master.PNG]]&lt;br /&gt;
&lt;br /&gt;
- Connect to elk-master via ssh by this command here naz is the username for elk-master&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; ssh naz@elk-master &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Ssh-to-elk-master.PNG]]&lt;br /&gt;
&lt;br /&gt;
== Step 1 - Install Java ==&lt;br /&gt;
&lt;br /&gt;
Java is required for the Elastic stack deployment. Elasticsearch requires Java 8. It is recommended to use the Oracle JDK 1.8. We will install Java 8 from a PPA repository.&lt;br /&gt;
&lt;br /&gt;
Install the new package &#039;&#039;&#039;&#039;python-software-properties&#039;&#039;&#039;&#039; so we can add a new repository easily with an apt command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y python-software-properties software-properties-common apt-transport-https&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the new Java 8 PPA repository with the &#039;add-apt-repository&#039; command, then update the repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo add-apt-repository ppa:webupd8team/java -y &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install Java 8 from the PPA webpub8 repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y oracle-java8-installer&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 2 - Install and Configure Elasticsearch ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Elasticsearch. Install Elasticsearch from the elastic repository and configure it to run on the localhost IP.&lt;br /&gt;
&lt;br /&gt;
Before installing Elasticsearch, add the elastic repository key to the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add - &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add elastic 5.x repository to the &#039;sources.list.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; echo &amp;quot;deb https://artifacts.elastic.co/packages/5.x/apt stable main&amp;quot; | sudo tee -a /etc/apt/sources.list.d/elastic-5.x.list &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Update the repository and install Elasticsearch 5.1 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Elasticsearch is installed. Now go to the configuration directory and edit the elasticsaerch.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; cd /etc/elasticsearch/ &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano elasticsearch.yml &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enable memory lock for Elasticsearch by removing the comment on line 43. We do this to disable swapping memory for Elasticsearchto avoid overloading the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; bootstrap.memory_lock: true &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the &#039;Network&#039; block, uncomment the network.host and http.port lines.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;network.host: localhost&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;http.port: 9200&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Now edit the elasticsearch service file for the memory lock mlockall configuration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /usr/lib/systemd/system/elasticsearch.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment LimitMEMLOCK line.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;LimitMEMLOCK=infinity&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit.&lt;br /&gt;
&lt;br /&gt;
Edit the default configuration for Elasticsearch in the /etc/default directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano /etc/default/elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment line 60 and make sure the value is &#039;unlimited&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;MAX_LOCKED_MEMORY=unlimited&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
The Elasticsearch configuration is finished. Elasticsearch will run under localhost IP address with port 9200 and we disabled swap memory by enabling mlockall on the Ubuntu server.&lt;br /&gt;
&lt;br /&gt;
Reload the Elasticsearch service file and enable it to run on the boot time, then start the service.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl daemon-reload&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable elasticsearch&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start elasticsearch&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Wait a sec for Elasticsearch to run, then check the open port on the server, make sure the &#039;state&#039; for port 9200 is &#039;LISTEN&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;netstat -plntu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then check the memory lock to ensure that mlockall is enabled. Also check that Elasticsearch is running with the commands below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
curl -XGET &#039;localhost:9200/_nodes?filter_path=**.mlockall&amp;amp;pretty&#039;&lt;br /&gt;
&lt;br /&gt;
curl -XGET &#039;localhost:9200/?pretty&#039;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see the results below.&lt;br /&gt;
&lt;br /&gt;
== Step 3 - Install and Configure Kibana with Nginx ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Kibana behind a Nginx web server. Kibana will listen on the localhost IP address only and Nginx acts as the reverse proxy for the Kibana application.&lt;br /&gt;
&lt;br /&gt;
Install Kibana with this apt command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y kibana&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the kibana.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /etc/kibana/kibana.yml&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment the server.port, server.hos and elasticsearch.url lines.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
server.port: 5601&lt;br /&gt;
&lt;br /&gt;
server.host: &amp;quot;localhost&amp;quot;&lt;br /&gt;
&lt;br /&gt;
elasticsearch.url: &amp;quot;http://localhost:9200&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Add Kibana to run at boot and start it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl enable kibana&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start kibana&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana will run on port 5601 as node application.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
netstat -plntu&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana installation is done, now we need to install Nginx and configure it as a reverse proxy to be able to access Kibana from the public IP address.&lt;br /&gt;
&lt;br /&gt;
Next, install the Nginx and apache2-utils packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo apt-get install -y nginx apache2-utils&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Apache2-utils is a package that contains tools for the webserver that work with Nginx as well, we will use htpasswd basic authentication for Kibana.&lt;br /&gt;
&lt;br /&gt;
Nginx has been installed. Now we need to create a new virtual host configuration file in the Nginx sites-available directory. Create a new file &#039;kibana&#039; with nano.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/nginx/&lt;br /&gt;
vim sites-available/kibana&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
    listen 80;&lt;br /&gt;
 &lt;br /&gt;
    server_name elk-stack.co;&lt;br /&gt;
 &lt;br /&gt;
    auth_basic &amp;quot;Restricted Access&amp;quot;;&lt;br /&gt;
    auth_basic_user_file /etc/nginx/.kibana-user;&lt;br /&gt;
 &lt;br /&gt;
    location / {&lt;br /&gt;
        proxy_pass http://localhost:5601;&lt;br /&gt;
        proxy_http_version 1.1;&lt;br /&gt;
        proxy_set_header Upgrade $http_upgrade;&lt;br /&gt;
        proxy_set_header Connection &#039;upgrade&#039;;&lt;br /&gt;
        proxy_set_header Host $host;&lt;br /&gt;
        proxy_cache_bypass $http_upgrade;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano&lt;br /&gt;
&lt;br /&gt;
Create a new basic authentication file with the htpasswd command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo htpasswd -c /etc/nginx/.kibana-user admin&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
TYPE YOUR PASSWORD&lt;br /&gt;
&lt;br /&gt;
Activate the kibana virtual host by creating a symbolic link from the kibana file in &#039;sites-available&#039; to the &#039;sites-enabled&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ln -s /etc/nginx/sites-available/kibana /etc/nginx/sites-enabled/ &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Test the nginx configuration and make sure there is no error, then add nginx to run at boot time and restart nginx.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
nginx -t&lt;br /&gt;
&lt;br /&gt;
systemctl enable nginx&lt;br /&gt;
&lt;br /&gt;
systemctl restart nginx&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Step 4 - Install and Configure Logstash == &lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Logsatash to centralize server logs from client sources with filebeat, then filter and transform all data (Syslog) and transport it to the stash (Elasticsearch).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install Logstash 5 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y logstash&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Edit the hosts file with nano.&lt;br /&gt;
&lt;br /&gt;
nano /etc/hosts&lt;br /&gt;
&lt;br /&gt;
Add the server IP address and hostname.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;10.0.2.15    elk-master&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the hosts file and exit the editor.&lt;br /&gt;
&lt;br /&gt;
Now generate a new SSL certificate file with OpenSSL so the client sources can identify the elastic server.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/logstash/&lt;br /&gt;
&lt;br /&gt;
openssl req -subj /CN=elk-master -x509 -days 3650 -batch -nodes -newkey rsa:4096 -keyout logstash.key -out logstash.crt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change the &#039;/CN&#039; value to the elastic server hostname.&lt;br /&gt;
&lt;br /&gt;
Certificate files will be created in the &#039;/etc/logstash/&#039; directory.&lt;br /&gt;
&lt;br /&gt;
Next, we will create the configuration files for logstash. We will create a configuration file &#039;filebeat-input.conf&#039; as input file from filebeat, &#039;syslog-filter.conf&#039; for syslog processing, and then a &#039;output-elasticsearch.conf&#039; file to define the Elasticsearch output.&lt;br /&gt;
&lt;br /&gt;
Go to the logstash configuration directory and create the new configuration files in the &#039;conf.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/logstash/&lt;br /&gt;
&lt;br /&gt;
nano conf.d/filebeat-input.conf&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Input configuration, paste configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input {&lt;br /&gt;
  beats {&lt;br /&gt;
    port =&amp;gt; 5443&lt;br /&gt;
    type =&amp;gt; syslog&lt;br /&gt;
    ssl =&amp;gt; true&lt;br /&gt;
    ssl_certificate =&amp;gt; &amp;quot;/etc/logstash/logstash.crt&amp;quot;&lt;br /&gt;
    ssl_key =&amp;gt; &amp;quot;/etc/logstash/logstash.key&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Create the syslog-filter.conf file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano conf.d/syslog-filter.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
filter {&lt;br /&gt;
  if [type] == &amp;quot;syslog&amp;quot; {&lt;br /&gt;
    grok {&lt;br /&gt;
      match =&amp;gt; { &amp;quot;message&amp;quot; =&amp;gt; &amp;quot;%{SYSLOGTIMESTAMP:syslog_timestamp} %{SYSLOGHOST:syslog_hostname} %{DATA:syslog_program}(?:\[%{POSINT:syslog_pid}\])?: %{GREEDYDATA:syslog_message}&amp;quot; }&lt;br /&gt;
      add_field =&amp;gt; [ &amp;quot;received_at&amp;quot;, &amp;quot;%{@timestamp}&amp;quot; ]&lt;br /&gt;
      add_field =&amp;gt; [ &amp;quot;received_from&amp;quot;, &amp;quot;%{host}&amp;quot; ]&lt;br /&gt;
    }&lt;br /&gt;
    date {&lt;br /&gt;
      match =&amp;gt; [ &amp;quot;syslog_timestamp&amp;quot;, &amp;quot;MMM  d HH:mm:ss&amp;quot;, &amp;quot;MMM dd HH:mm:ss&amp;quot; ]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We use a filter plugin named &#039;grok&#039; to parse the syslog files.&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Create the output configuration file &#039;output-elasticsearch.conf&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano conf.d/output-elasticsearch.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
output {&lt;br /&gt;
  elasticsearch { hosts =&amp;gt; [&amp;quot;localhost:9200&amp;quot;]&lt;br /&gt;
    hosts =&amp;gt; &amp;quot;localhost:9200&amp;quot;&lt;br /&gt;
    manage_template =&amp;gt; false&lt;br /&gt;
    index =&amp;gt; &amp;quot;%{[@metadata][beat]}-%{+YYYY.MM.dd}&amp;quot;&lt;br /&gt;
    document_type =&amp;gt; &amp;quot;%{[@metadata][type]}&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
When this is done, add logstash to start at boot time and start the service.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable logstash&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start logstash&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mdhasan</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123815</id>
		<title>Logging and monitoring with Elastic stack on Ubuntu 16.04</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123815"/>
		<updated>2017-06-21T21:33:48Z</updated>

		<summary type="html">&lt;p&gt;Mdhasan: /* Virtual Box setup */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
Logging and monitoring of IT systems is very important part of information security. Proper system logs and monitoring can prevent cyber attacks or service failure. In this wiki we will learn how configure logging and monitoring with ELK stack in Ubuntu server 16.04, what is alternatives (Graylog) of ELK stack and disadvantages of ELK stack.      &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Elasticsearch&#039;&#039;&#039; is an open source search engine based on Lucene, developed in java. It provides a distributed and multitenant [https://en.wikipedia.org/wiki/Full-text_search full-text search engine] with an HTTP Dashboard web-interface (Kibana) and JSON documents scheme. Elasticsearch is a scalable search engine that can be used to search for all types of documents, including log file. Elasticsearch is the heart of the &#039;Elastic Stack&#039; or ELK Stack.&amp;lt;ref&amp;gt;[https://www.elastic.co/products/elasticsearch] Elastic Search Homepage&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Logstash&#039;&#039;&#039; is an open source, server-side data processing pipeline that ingests data from a multitude of sources simultaneously, transforms it, and then sends it to Elasticsearch.&amp;lt;ref&amp;gt;[https://www.elastic.co/products/logstash] Logstash homepahe&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Kibana&#039;&#039;&#039; is a data visualization interface for Elasticsearch. Kibana provides a pretty dashboard (web interfaces), it allows you to manage and visualize all data from Elasticsearch on your own. &amp;lt;ref&amp;gt;[https://www.elastic.co/products/kibana] kibana homepage&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Prerequisite ==&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit server with 4GB of RAM, hostname - elk-master&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit client with 1 GB of RAM, hostname - elk-client&lt;br /&gt;
&lt;br /&gt;
Following installation steps from 1 to 4 is collected from &lt;br /&gt;
&lt;br /&gt;
[http://www.howtoforge.com HowToFroge.com]&amp;lt;ref&amp;gt;[http://thehackernews.com/2013/10/importance-of-logs-and-log-management.html]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Virtual Box setup ==&lt;br /&gt;
&lt;br /&gt;
As we are going to use Ubuntu server 16.04, which has no Graphical user interface (GUI). It is better to add a GUI client to Ubuntu server and ssh to virtual box setup. Here I will show to how to connect to Ubuntu server from a Ubuntu desktop client via SSH in Virtual box. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Step 1 - Virtual box Networking&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
- For both Server and Client &lt;br /&gt;
&lt;br /&gt;
- Select the virtual Machine&lt;br /&gt;
&lt;br /&gt;
- go to settings &amp;gt; network&lt;br /&gt;
&lt;br /&gt;
- set Adapter 1 as Internal network (It is better to setup static IP for adapter 1)&lt;br /&gt;
&lt;br /&gt;
- Also Add another network NAT (So the server could have internet access )&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Step 2 - Setup static IP in Ubuntu server (elk-master)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
- Become a root user &amp;lt;code&amp;gt; sudo -i &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Enable SSH by running following commands&amp;lt;ref&amp;gt;[https://askubuntu.com/questions/218344/why-am-i-getting-a-port-22-connection-refused-error open port 22 ]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; &lt;br /&gt;
sudo apt-get update&lt;br /&gt;
&lt;br /&gt;
sudo apt-get install openssh-server&lt;br /&gt;
&lt;br /&gt;
sudo ufw allow 22&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Set up static IP&lt;br /&gt;
&lt;br /&gt;
run this command &amp;lt;code&amp;gt; nano /etc/network/interfaces &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you set a static IP for primary network as screenshot:&lt;br /&gt;
&lt;br /&gt;
[[File:Static-ip-elk-master.PNG]]&lt;br /&gt;
&lt;br /&gt;
- Now go to &amp;lt;code&amp;gt;nano /etc/hosts &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add IP addresses of elk-master and elk-client as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
192.168.2.105 elk-master&lt;br /&gt;
192.168.2.106 elk-client&lt;br /&gt;
&amp;lt;/pre&amp;gt;[[File:Elk-master-hostd.PNG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Step 2 - Setup static IP for Ubuntu Desktop(elk-client)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
- Open terminal &lt;br /&gt;
- log in as root user &lt;br /&gt;
- Run following command for Openssh&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
sudo apt-get update&lt;br /&gt;
&lt;br /&gt;
sudo apt-get install openssh-server&lt;br /&gt;
&lt;br /&gt;
sudo ufw allow 22&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Go to &amp;lt;code&amp;gt; nano /etc/network/interfaces &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Set static IP (example: 192.168.2.106) like ubuntu server &lt;br /&gt;
&lt;br /&gt;
- restart the Ubuntu desktop &lt;br /&gt;
&lt;br /&gt;
- Now ping ELK-MASTER by running this command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; ping elk-master &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Ping-elk-master.PNG]]&lt;br /&gt;
&lt;br /&gt;
- Connect to elk-master via ssh by this command here naz is the username for elk-master&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; ssh naz@elk-master &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:Ssh-to-elk-master.PNG]]&lt;br /&gt;
&lt;br /&gt;
== Step 1 - Install Java ==&lt;br /&gt;
&lt;br /&gt;
Java is required for the Elastic stack deployment. Elasticsearch requires Java 8. It is recommended to use the Oracle JDK 1.8. We will install Java 8 from a PPA repository.&lt;br /&gt;
&lt;br /&gt;
Install the new package &#039;&#039;&#039;&#039;python-software-properties&#039;&#039;&#039;&#039; so we can add a new repository easily with an apt command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y python-software-properties software-properties-common apt-transport-https&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the new Java 8 PPA repository with the &#039;add-apt-repository&#039; command, then update the repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo add-apt-repository ppa:webupd8team/java -y &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install Java 8 from the PPA webpub8 repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y oracle-java8-installer&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 2 - Install and Configure Elasticsearch ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Elasticsearch. Install Elasticsearch from the elastic repository and configure it to run on the localhost IP.&lt;br /&gt;
&lt;br /&gt;
Before installing Elasticsearch, add the elastic repository key to the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add - &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add elastic 5.x repository to the &#039;sources.list.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; echo &amp;quot;deb https://artifacts.elastic.co/packages/5.x/apt stable main&amp;quot; | sudo tee -a /etc/apt/sources.list.d/elastic-5.x.list &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Update the repository and install Elasticsearch 5.1 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Elasticsearch is installed. Now go to the configuration directory and edit the elasticsaerch.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; cd /etc/elasticsearch/ &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano elasticsearch.yml &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enable memory lock for Elasticsearch by removing the comment on line 43. We do this to disable swapping memory for Elasticsearchto avoid overloading the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; bootstrap.memory_lock: true &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the &#039;Network&#039; block, uncomment the network.host and http.port lines.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;network.host: localhost&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;http.port: 9200&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Now edit the elasticsearch service file for the memory lock mlockall configuration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /usr/lib/systemd/system/elasticsearch.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment LimitMEMLOCK line.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;LimitMEMLOCK=infinity&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit.&lt;br /&gt;
&lt;br /&gt;
Edit the default configuration for Elasticsearch in the /etc/default directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano /etc/default/elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment line 60 and make sure the value is &#039;unlimited&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;MAX_LOCKED_MEMORY=unlimited&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
The Elasticsearch configuration is finished. Elasticsearch will run under localhost IP address with port 9200 and we disabled swap memory by enabling mlockall on the Ubuntu server.&lt;br /&gt;
&lt;br /&gt;
Reload the Elasticsearch service file and enable it to run on the boot time, then start the service.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl daemon-reload&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable elasticsearch&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start elasticsearch&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Wait a sec for Elasticsearch to run, then check the open port on the server, make sure the &#039;state&#039; for port 9200 is &#039;LISTEN&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;netstat -plntu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then check the memory lock to ensure that mlockall is enabled. Also check that Elasticsearch is running with the commands below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
curl -XGET &#039;localhost:9200/_nodes?filter_path=**.mlockall&amp;amp;pretty&#039;&lt;br /&gt;
&lt;br /&gt;
curl -XGET &#039;localhost:9200/?pretty&#039;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see the results below.&lt;br /&gt;
&lt;br /&gt;
== Step 3 - Install and Configure Kibana with Nginx ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Kibana behind a Nginx web server. Kibana will listen on the localhost IP address only and Nginx acts as the reverse proxy for the Kibana application.&lt;br /&gt;
&lt;br /&gt;
Install Kibana with this apt command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y kibana&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the kibana.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /etc/kibana/kibana.yml&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment the server.port, server.hos and elasticsearch.url lines.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
server.port: 5601&lt;br /&gt;
&lt;br /&gt;
server.host: &amp;quot;localhost&amp;quot;&lt;br /&gt;
&lt;br /&gt;
elasticsearch.url: &amp;quot;http://localhost:9200&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Add Kibana to run at boot and start it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl enable kibana&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start kibana&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana will run on port 5601 as node application.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
netstat -plntu&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana installation is done, now we need to install Nginx and configure it as a reverse proxy to be able to access Kibana from the public IP address.&lt;br /&gt;
&lt;br /&gt;
Next, install the Nginx and apache2-utils packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo apt-get install -y nginx apache2-utils&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Apache2-utils is a package that contains tools for the webserver that work with Nginx as well, we will use htpasswd basic authentication for Kibana.&lt;br /&gt;
&lt;br /&gt;
Nginx has been installed. Now we need to create a new virtual host configuration file in the Nginx sites-available directory. Create a new file &#039;kibana&#039; with nano.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/nginx/&lt;br /&gt;
vim sites-available/kibana&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
    listen 80;&lt;br /&gt;
 &lt;br /&gt;
    server_name elk-stack.co;&lt;br /&gt;
 &lt;br /&gt;
    auth_basic &amp;quot;Restricted Access&amp;quot;;&lt;br /&gt;
    auth_basic_user_file /etc/nginx/.kibana-user;&lt;br /&gt;
 &lt;br /&gt;
    location / {&lt;br /&gt;
        proxy_pass http://localhost:5601;&lt;br /&gt;
        proxy_http_version 1.1;&lt;br /&gt;
        proxy_set_header Upgrade $http_upgrade;&lt;br /&gt;
        proxy_set_header Connection &#039;upgrade&#039;;&lt;br /&gt;
        proxy_set_header Host $host;&lt;br /&gt;
        proxy_cache_bypass $http_upgrade;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano&lt;br /&gt;
&lt;br /&gt;
Create a new basic authentication file with the htpasswd command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo htpasswd -c /etc/nginx/.kibana-user admin&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
TYPE YOUR PASSWORD&lt;br /&gt;
&lt;br /&gt;
Activate the kibana virtual host by creating a symbolic link from the kibana file in &#039;sites-available&#039; to the &#039;sites-enabled&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ln -s /etc/nginx/sites-available/kibana /etc/nginx/sites-enabled/ &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Test the nginx configuration and make sure there is no error, then add nginx to run at boot time and restart nginx.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
nginx -t&lt;br /&gt;
&lt;br /&gt;
systemctl enable nginx&lt;br /&gt;
&lt;br /&gt;
systemctl restart nginx&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Step 4 - Install and Configure Logstash == &lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Logsatash to centralize server logs from client sources with filebeat, then filter and transform all data (Syslog) and transport it to the stash (Elasticsearch).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install Logstash 5 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y logstash&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Edit the hosts file with nano.&lt;br /&gt;
&lt;br /&gt;
nano /etc/hosts&lt;br /&gt;
&lt;br /&gt;
Add the server IP address and hostname.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;10.0.2.15    elk-master&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the hosts file and exit the editor.&lt;br /&gt;
&lt;br /&gt;
Now generate a new SSL certificate file with OpenSSL so the client sources can identify the elastic server.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/logstash/&lt;br /&gt;
&lt;br /&gt;
openssl req -subj /CN=elk-master -x509 -days 3650 -batch -nodes -newkey rsa:4096 -keyout logstash.key -out logstash.crt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change the &#039;/CN&#039; value to the elastic server hostname.&lt;br /&gt;
&lt;br /&gt;
Certificate files will be created in the &#039;/etc/logstash/&#039; directory.&lt;br /&gt;
&lt;br /&gt;
Next, we will create the configuration files for logstash. We will create a configuration file &#039;filebeat-input.conf&#039; as input file from filebeat, &#039;syslog-filter.conf&#039; for syslog processing, and then a &#039;output-elasticsearch.conf&#039; file to define the Elasticsearch output.&lt;br /&gt;
&lt;br /&gt;
Go to the logstash configuration directory and create the new configuration files in the &#039;conf.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/logstash/&lt;br /&gt;
&lt;br /&gt;
nano conf.d/filebeat-input.conf&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Input configuration, paste configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input {&lt;br /&gt;
  beats {&lt;br /&gt;
    port =&amp;gt; 5443&lt;br /&gt;
    type =&amp;gt; syslog&lt;br /&gt;
    ssl =&amp;gt; true&lt;br /&gt;
    ssl_certificate =&amp;gt; &amp;quot;/etc/logstash/logstash.crt&amp;quot;&lt;br /&gt;
    ssl_key =&amp;gt; &amp;quot;/etc/logstash/logstash.key&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Create the syslog-filter.conf file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano conf.d/syslog-filter.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
filter {&lt;br /&gt;
  if [type] == &amp;quot;syslog&amp;quot; {&lt;br /&gt;
    grok {&lt;br /&gt;
      match =&amp;gt; { &amp;quot;message&amp;quot; =&amp;gt; &amp;quot;%{SYSLOGTIMESTAMP:syslog_timestamp} %{SYSLOGHOST:syslog_hostname} %{DATA:syslog_program}(?:\[%{POSINT:syslog_pid}\])?: %{GREEDYDATA:syslog_message}&amp;quot; }&lt;br /&gt;
      add_field =&amp;gt; [ &amp;quot;received_at&amp;quot;, &amp;quot;%{@timestamp}&amp;quot; ]&lt;br /&gt;
      add_field =&amp;gt; [ &amp;quot;received_from&amp;quot;, &amp;quot;%{host}&amp;quot; ]&lt;br /&gt;
    }&lt;br /&gt;
    date {&lt;br /&gt;
      match =&amp;gt; [ &amp;quot;syslog_timestamp&amp;quot;, &amp;quot;MMM  d HH:mm:ss&amp;quot;, &amp;quot;MMM dd HH:mm:ss&amp;quot; ]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We use a filter plugin named &#039;grok&#039; to parse the syslog files.&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Create the output configuration file &#039;output-elasticsearch.conf&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano conf.d/output-elasticsearch.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
output {&lt;br /&gt;
  elasticsearch { hosts =&amp;gt; [&amp;quot;localhost:9200&amp;quot;]&lt;br /&gt;
    hosts =&amp;gt; &amp;quot;localhost:9200&amp;quot;&lt;br /&gt;
    manage_template =&amp;gt; false&lt;br /&gt;
    index =&amp;gt; &amp;quot;%{[@metadata][beat]}-%{+YYYY.MM.dd}&amp;quot;&lt;br /&gt;
    document_type =&amp;gt; &amp;quot;%{[@metadata][type]}&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
When this is done, add logstash to start at boot time and start the service.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable logstash&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start logstash&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mdhasan</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=File:Ssh-to-elk-master.PNG&amp;diff=123814</id>
		<title>File:Ssh-to-elk-master.PNG</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=File:Ssh-to-elk-master.PNG&amp;diff=123814"/>
		<updated>2017-06-21T21:33:11Z</updated>

		<summary type="html">&lt;p&gt;Mdhasan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Mdhasan</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123813</id>
		<title>Logging and monitoring with Elastic stack on Ubuntu 16.04</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123813"/>
		<updated>2017-06-21T20:39:34Z</updated>

		<summary type="html">&lt;p&gt;Mdhasan: /* Virtual Box setup */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
Logging and monitoring of IT systems is very important part of information security. Proper system logs and monitoring can prevent cyber attacks or service failure. In this wiki we will learn how configure logging and monitoring with ELK stack in Ubuntu server 16.04, what is alternatives (Graylog) of ELK stack and disadvantages of ELK stack.      &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Elasticsearch&#039;&#039;&#039; is an open source search engine based on Lucene, developed in java. It provides a distributed and multitenant [https://en.wikipedia.org/wiki/Full-text_search full-text search engine] with an HTTP Dashboard web-interface (Kibana) and JSON documents scheme. Elasticsearch is a scalable search engine that can be used to search for all types of documents, including log file. Elasticsearch is the heart of the &#039;Elastic Stack&#039; or ELK Stack.&amp;lt;ref&amp;gt;[https://www.elastic.co/products/elasticsearch] Elastic Search Homepage&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Logstash&#039;&#039;&#039; is an open source, server-side data processing pipeline that ingests data from a multitude of sources simultaneously, transforms it, and then sends it to Elasticsearch.&amp;lt;ref&amp;gt;[https://www.elastic.co/products/logstash] Logstash homepahe&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Kibana&#039;&#039;&#039; is a data visualization interface for Elasticsearch. Kibana provides a pretty dashboard (web interfaces), it allows you to manage and visualize all data from Elasticsearch on your own. &amp;lt;ref&amp;gt;[https://www.elastic.co/products/kibana] kibana homepage&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Prerequisite ==&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit server with 4GB of RAM, hostname - elk-master&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit client with 1 GB of RAM, hostname - elk-client&lt;br /&gt;
&lt;br /&gt;
Following installation steps from 1 to 4 is collected from &lt;br /&gt;
&lt;br /&gt;
[http://www.howtoforge.com HowToFroge.com]&amp;lt;ref&amp;gt;[http://thehackernews.com/2013/10/importance-of-logs-and-log-management.html]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Virtual Box setup ==&lt;br /&gt;
&lt;br /&gt;
As we are going to use Ubuntu server 16.04, which has no Graphical user interface (GUI). It is better to add a GUI client to Ubuntu server and ssh to virtual box setup. Here I will show to how to connect to Ubuntu server from a Ubuntu desktop client via SSH in Virtual box. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Step 1 - Virtual box Networking&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
- For both Server and Client &lt;br /&gt;
&lt;br /&gt;
- Select the virtual Machine&lt;br /&gt;
&lt;br /&gt;
- go to settings &amp;gt; network&lt;br /&gt;
&lt;br /&gt;
- set Adapter 1 as Internal network (It is better to setup static IP for adapter 1)&lt;br /&gt;
&lt;br /&gt;
- Also Add another network NAT (So the server could have internet access )&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Step 2 - Setup static IP in Ubuntu server (elk-master)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
- Become a root user &amp;lt;code&amp;gt; sudo -i &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Enable SSH by running following commands&amp;lt;ref&amp;gt;[https://askubuntu.com/questions/218344/why-am-i-getting-a-port-22-connection-refused-error open port 22 ]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; &lt;br /&gt;
sudo apt-get update&lt;br /&gt;
&lt;br /&gt;
sudo apt-get install openssh-server&lt;br /&gt;
&lt;br /&gt;
sudo ufw allow 22&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Set up static IP&lt;br /&gt;
&lt;br /&gt;
run this command &amp;lt;code&amp;gt; nano /etc/network/interfaces &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you set a static IP for primary network as screenshot:&lt;br /&gt;
&lt;br /&gt;
[[File:Static-ip-elk-master.PNG]]&lt;br /&gt;
&lt;br /&gt;
- Now go to &amp;lt;code&amp;gt;nano /etc/hosts &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add IP addresses of elk-master and elk-client as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
192.168.2.105 elk-master&lt;br /&gt;
192.168.2.106 elk-client&lt;br /&gt;
&amp;lt;/pre&amp;gt;[[File:Elk-master-hostd.PNG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Step 2 - Setup static IP for Ubuntu Desktop(elk-client)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
- Open terminal &lt;br /&gt;
- log in as root user &lt;br /&gt;
- Run following command for Openssh&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
sudo apt-get update&lt;br /&gt;
&lt;br /&gt;
sudo apt-get install openssh-server&lt;br /&gt;
&lt;br /&gt;
sudo ufw allow 22&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Go to &amp;lt;code&amp;gt; nano /etc/network/interfaces &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Set static IP (example: 192.168.2.106) like ubuntu server &lt;br /&gt;
&lt;br /&gt;
- restart the Ubuntu desktop &lt;br /&gt;
&lt;br /&gt;
- Now ping ELK-MASTER by running this command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; ping elk-master &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Ping-elk-master.PNG]]&lt;br /&gt;
&lt;br /&gt;
== Step 1 - Install Java ==&lt;br /&gt;
&lt;br /&gt;
Java is required for the Elastic stack deployment. Elasticsearch requires Java 8. It is recommended to use the Oracle JDK 1.8. We will install Java 8 from a PPA repository.&lt;br /&gt;
&lt;br /&gt;
Install the new package &#039;&#039;&#039;&#039;python-software-properties&#039;&#039;&#039;&#039; so we can add a new repository easily with an apt command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y python-software-properties software-properties-common apt-transport-https&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the new Java 8 PPA repository with the &#039;add-apt-repository&#039; command, then update the repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo add-apt-repository ppa:webupd8team/java -y &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install Java 8 from the PPA webpub8 repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y oracle-java8-installer&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 2 - Install and Configure Elasticsearch ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Elasticsearch. Install Elasticsearch from the elastic repository and configure it to run on the localhost IP.&lt;br /&gt;
&lt;br /&gt;
Before installing Elasticsearch, add the elastic repository key to the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add - &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add elastic 5.x repository to the &#039;sources.list.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; echo &amp;quot;deb https://artifacts.elastic.co/packages/5.x/apt stable main&amp;quot; | sudo tee -a /etc/apt/sources.list.d/elastic-5.x.list &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Update the repository and install Elasticsearch 5.1 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Elasticsearch is installed. Now go to the configuration directory and edit the elasticsaerch.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; cd /etc/elasticsearch/ &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano elasticsearch.yml &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enable memory lock for Elasticsearch by removing the comment on line 43. We do this to disable swapping memory for Elasticsearchto avoid overloading the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; bootstrap.memory_lock: true &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the &#039;Network&#039; block, uncomment the network.host and http.port lines.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;network.host: localhost&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;http.port: 9200&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Now edit the elasticsearch service file for the memory lock mlockall configuration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /usr/lib/systemd/system/elasticsearch.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment LimitMEMLOCK line.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;LimitMEMLOCK=infinity&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit.&lt;br /&gt;
&lt;br /&gt;
Edit the default configuration for Elasticsearch in the /etc/default directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano /etc/default/elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment line 60 and make sure the value is &#039;unlimited&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;MAX_LOCKED_MEMORY=unlimited&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
The Elasticsearch configuration is finished. Elasticsearch will run under localhost IP address with port 9200 and we disabled swap memory by enabling mlockall on the Ubuntu server.&lt;br /&gt;
&lt;br /&gt;
Reload the Elasticsearch service file and enable it to run on the boot time, then start the service.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl daemon-reload&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable elasticsearch&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start elasticsearch&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Wait a sec for Elasticsearch to run, then check the open port on the server, make sure the &#039;state&#039; for port 9200 is &#039;LISTEN&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;netstat -plntu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then check the memory lock to ensure that mlockall is enabled. Also check that Elasticsearch is running with the commands below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
curl -XGET &#039;localhost:9200/_nodes?filter_path=**.mlockall&amp;amp;pretty&#039;&lt;br /&gt;
&lt;br /&gt;
curl -XGET &#039;localhost:9200/?pretty&#039;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see the results below.&lt;br /&gt;
&lt;br /&gt;
== Step 3 - Install and Configure Kibana with Nginx ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Kibana behind a Nginx web server. Kibana will listen on the localhost IP address only and Nginx acts as the reverse proxy for the Kibana application.&lt;br /&gt;
&lt;br /&gt;
Install Kibana with this apt command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y kibana&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the kibana.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /etc/kibana/kibana.yml&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment the server.port, server.hos and elasticsearch.url lines.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
server.port: 5601&lt;br /&gt;
&lt;br /&gt;
server.host: &amp;quot;localhost&amp;quot;&lt;br /&gt;
&lt;br /&gt;
elasticsearch.url: &amp;quot;http://localhost:9200&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Add Kibana to run at boot and start it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl enable kibana&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start kibana&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana will run on port 5601 as node application.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
netstat -plntu&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana installation is done, now we need to install Nginx and configure it as a reverse proxy to be able to access Kibana from the public IP address.&lt;br /&gt;
&lt;br /&gt;
Next, install the Nginx and apache2-utils packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo apt-get install -y nginx apache2-utils&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Apache2-utils is a package that contains tools for the webserver that work with Nginx as well, we will use htpasswd basic authentication for Kibana.&lt;br /&gt;
&lt;br /&gt;
Nginx has been installed. Now we need to create a new virtual host configuration file in the Nginx sites-available directory. Create a new file &#039;kibana&#039; with nano.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/nginx/&lt;br /&gt;
vim sites-available/kibana&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
    listen 80;&lt;br /&gt;
 &lt;br /&gt;
    server_name elk-stack.co;&lt;br /&gt;
 &lt;br /&gt;
    auth_basic &amp;quot;Restricted Access&amp;quot;;&lt;br /&gt;
    auth_basic_user_file /etc/nginx/.kibana-user;&lt;br /&gt;
 &lt;br /&gt;
    location / {&lt;br /&gt;
        proxy_pass http://localhost:5601;&lt;br /&gt;
        proxy_http_version 1.1;&lt;br /&gt;
        proxy_set_header Upgrade $http_upgrade;&lt;br /&gt;
        proxy_set_header Connection &#039;upgrade&#039;;&lt;br /&gt;
        proxy_set_header Host $host;&lt;br /&gt;
        proxy_cache_bypass $http_upgrade;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano&lt;br /&gt;
&lt;br /&gt;
Create a new basic authentication file with the htpasswd command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo htpasswd -c /etc/nginx/.kibana-user admin&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
TYPE YOUR PASSWORD&lt;br /&gt;
&lt;br /&gt;
Activate the kibana virtual host by creating a symbolic link from the kibana file in &#039;sites-available&#039; to the &#039;sites-enabled&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ln -s /etc/nginx/sites-available/kibana /etc/nginx/sites-enabled/ &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Test the nginx configuration and make sure there is no error, then add nginx to run at boot time and restart nginx.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
nginx -t&lt;br /&gt;
&lt;br /&gt;
systemctl enable nginx&lt;br /&gt;
&lt;br /&gt;
systemctl restart nginx&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Step 4 - Install and Configure Logstash == &lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Logsatash to centralize server logs from client sources with filebeat, then filter and transform all data (Syslog) and transport it to the stash (Elasticsearch).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install Logstash 5 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y logstash&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Edit the hosts file with nano.&lt;br /&gt;
&lt;br /&gt;
nano /etc/hosts&lt;br /&gt;
&lt;br /&gt;
Add the server IP address and hostname.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;10.0.2.15    elk-master&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the hosts file and exit the editor.&lt;br /&gt;
&lt;br /&gt;
Now generate a new SSL certificate file with OpenSSL so the client sources can identify the elastic server.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/logstash/&lt;br /&gt;
&lt;br /&gt;
openssl req -subj /CN=elk-master -x509 -days 3650 -batch -nodes -newkey rsa:4096 -keyout logstash.key -out logstash.crt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change the &#039;/CN&#039; value to the elastic server hostname.&lt;br /&gt;
&lt;br /&gt;
Certificate files will be created in the &#039;/etc/logstash/&#039; directory.&lt;br /&gt;
&lt;br /&gt;
Next, we will create the configuration files for logstash. We will create a configuration file &#039;filebeat-input.conf&#039; as input file from filebeat, &#039;syslog-filter.conf&#039; for syslog processing, and then a &#039;output-elasticsearch.conf&#039; file to define the Elasticsearch output.&lt;br /&gt;
&lt;br /&gt;
Go to the logstash configuration directory and create the new configuration files in the &#039;conf.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/logstash/&lt;br /&gt;
&lt;br /&gt;
nano conf.d/filebeat-input.conf&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Input configuration, paste configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input {&lt;br /&gt;
  beats {&lt;br /&gt;
    port =&amp;gt; 5443&lt;br /&gt;
    type =&amp;gt; syslog&lt;br /&gt;
    ssl =&amp;gt; true&lt;br /&gt;
    ssl_certificate =&amp;gt; &amp;quot;/etc/logstash/logstash.crt&amp;quot;&lt;br /&gt;
    ssl_key =&amp;gt; &amp;quot;/etc/logstash/logstash.key&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Create the syslog-filter.conf file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano conf.d/syslog-filter.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
filter {&lt;br /&gt;
  if [type] == &amp;quot;syslog&amp;quot; {&lt;br /&gt;
    grok {&lt;br /&gt;
      match =&amp;gt; { &amp;quot;message&amp;quot; =&amp;gt; &amp;quot;%{SYSLOGTIMESTAMP:syslog_timestamp} %{SYSLOGHOST:syslog_hostname} %{DATA:syslog_program}(?:\[%{POSINT:syslog_pid}\])?: %{GREEDYDATA:syslog_message}&amp;quot; }&lt;br /&gt;
      add_field =&amp;gt; [ &amp;quot;received_at&amp;quot;, &amp;quot;%{@timestamp}&amp;quot; ]&lt;br /&gt;
      add_field =&amp;gt; [ &amp;quot;received_from&amp;quot;, &amp;quot;%{host}&amp;quot; ]&lt;br /&gt;
    }&lt;br /&gt;
    date {&lt;br /&gt;
      match =&amp;gt; [ &amp;quot;syslog_timestamp&amp;quot;, &amp;quot;MMM  d HH:mm:ss&amp;quot;, &amp;quot;MMM dd HH:mm:ss&amp;quot; ]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We use a filter plugin named &#039;grok&#039; to parse the syslog files.&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Create the output configuration file &#039;output-elasticsearch.conf&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano conf.d/output-elasticsearch.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
output {&lt;br /&gt;
  elasticsearch { hosts =&amp;gt; [&amp;quot;localhost:9200&amp;quot;]&lt;br /&gt;
    hosts =&amp;gt; &amp;quot;localhost:9200&amp;quot;&lt;br /&gt;
    manage_template =&amp;gt; false&lt;br /&gt;
    index =&amp;gt; &amp;quot;%{[@metadata][beat]}-%{+YYYY.MM.dd}&amp;quot;&lt;br /&gt;
    document_type =&amp;gt; &amp;quot;%{[@metadata][type]}&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
When this is done, add logstash to start at boot time and start the service.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable logstash&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start logstash&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mdhasan</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=File:Ping-elk-master.PNG&amp;diff=123812</id>
		<title>File:Ping-elk-master.PNG</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=File:Ping-elk-master.PNG&amp;diff=123812"/>
		<updated>2017-06-21T20:38:13Z</updated>

		<summary type="html">&lt;p&gt;Mdhasan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Mdhasan</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123811</id>
		<title>Logging and monitoring with Elastic stack on Ubuntu 16.04</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123811"/>
		<updated>2017-06-21T20:20:25Z</updated>

		<summary type="html">&lt;p&gt;Mdhasan: /* Virtual Box setup */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
Logging and monitoring of IT systems is very important part of information security. Proper system logs and monitoring can prevent cyber attacks or service failure. In this wiki we will learn how configure logging and monitoring with ELK stack in Ubuntu server 16.04, what is alternatives (Graylog) of ELK stack and disadvantages of ELK stack.      &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Elasticsearch&#039;&#039;&#039; is an open source search engine based on Lucene, developed in java. It provides a distributed and multitenant [https://en.wikipedia.org/wiki/Full-text_search full-text search engine] with an HTTP Dashboard web-interface (Kibana) and JSON documents scheme. Elasticsearch is a scalable search engine that can be used to search for all types of documents, including log file. Elasticsearch is the heart of the &#039;Elastic Stack&#039; or ELK Stack.&amp;lt;ref&amp;gt;[https://www.elastic.co/products/elasticsearch] Elastic Search Homepage&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Logstash&#039;&#039;&#039; is an open source, server-side data processing pipeline that ingests data from a multitude of sources simultaneously, transforms it, and then sends it to Elasticsearch.&amp;lt;ref&amp;gt;[https://www.elastic.co/products/logstash] Logstash homepahe&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Kibana&#039;&#039;&#039; is a data visualization interface for Elasticsearch. Kibana provides a pretty dashboard (web interfaces), it allows you to manage and visualize all data from Elasticsearch on your own. &amp;lt;ref&amp;gt;[https://www.elastic.co/products/kibana] kibana homepage&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Prerequisite ==&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit server with 4GB of RAM, hostname - elk-master&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit client with 1 GB of RAM, hostname - elk-client&lt;br /&gt;
&lt;br /&gt;
Following installation steps from 1 to 4 is collected from &lt;br /&gt;
&lt;br /&gt;
[http://www.howtoforge.com HowToFroge.com]&amp;lt;ref&amp;gt;[http://thehackernews.com/2013/10/importance-of-logs-and-log-management.html]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Virtual Box setup ==&lt;br /&gt;
&lt;br /&gt;
As we are going to use Ubuntu server 16.04, which has no Graphical user interface (GUI). It is better to add a GUI client to Ubuntu server and ssh to virtual box setup. Here I will show to how to connect to Ubuntu server from a Ubuntu desktop client via SSH in Virtual box. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Step 1 - Virtual box Networking&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
- For both Server and Client &lt;br /&gt;
&lt;br /&gt;
- Select the virtual Machine&lt;br /&gt;
&lt;br /&gt;
- go to settings &amp;gt; network&lt;br /&gt;
&lt;br /&gt;
- set Adapter 1 as Internal network (It is better to setup static IP for adapter 1)&lt;br /&gt;
&lt;br /&gt;
- Also Add another network NAT (So the server could have internet access )&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Step 2 - Setup static IP in Ubuntu server (elk-master)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
- Become a root user &amp;lt;code&amp;gt; sudo -i &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Enable SSH by running following commands&amp;lt;ref&amp;gt;[https://askubuntu.com/questions/218344/why-am-i-getting-a-port-22-connection-refused-error open port 22 ]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; &lt;br /&gt;
sudo apt-get update&lt;br /&gt;
&lt;br /&gt;
sudo apt-get install openssh-server&lt;br /&gt;
&lt;br /&gt;
sudo ufw allow 22&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Set up static IP&lt;br /&gt;
&lt;br /&gt;
run this command &amp;lt;code&amp;gt; nano /etc/network/interfaces &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you set a static IP for primary network as screenshot:&lt;br /&gt;
&lt;br /&gt;
[[File:Static-ip-elk-master.PNG]]&lt;br /&gt;
&lt;br /&gt;
- Now go to &amp;lt;code&amp;gt;nano /etc/hosts &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add IP addresses of elk-master and elk-client as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
192.168.2.105 elk-master&lt;br /&gt;
192.168.2.106 elk-client&lt;br /&gt;
&amp;lt;/pre&amp;gt;[[File:Elk-master-hostd.PNG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Step 2 - Setup static IP for Ubuntu Desktop(elk-client)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
- Open terminal &lt;br /&gt;
- log in as root user &lt;br /&gt;
- Run following command for Openssh&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; &lt;br /&gt;
&lt;br /&gt;
sudo apt-get update&lt;br /&gt;
&lt;br /&gt;
sudo apt-get install openssh-server&lt;br /&gt;
&lt;br /&gt;
sudo ufw allow 22&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Go to &amp;lt;code&amp;gt; nano /etc/network/interfaces &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Set static IP (example: 192.168.2.106) like ubuntu server &lt;br /&gt;
&lt;br /&gt;
- restart the Ubuntu desktop &lt;br /&gt;
&lt;br /&gt;
- Now ping ELK-MASTER by running this command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; ping elk-master &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 1 - Install Java ==&lt;br /&gt;
&lt;br /&gt;
Java is required for the Elastic stack deployment. Elasticsearch requires Java 8. It is recommended to use the Oracle JDK 1.8. We will install Java 8 from a PPA repository.&lt;br /&gt;
&lt;br /&gt;
Install the new package &#039;&#039;&#039;&#039;python-software-properties&#039;&#039;&#039;&#039; so we can add a new repository easily with an apt command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y python-software-properties software-properties-common apt-transport-https&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the new Java 8 PPA repository with the &#039;add-apt-repository&#039; command, then update the repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo add-apt-repository ppa:webupd8team/java -y &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install Java 8 from the PPA webpub8 repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y oracle-java8-installer&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 2 - Install and Configure Elasticsearch ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Elasticsearch. Install Elasticsearch from the elastic repository and configure it to run on the localhost IP.&lt;br /&gt;
&lt;br /&gt;
Before installing Elasticsearch, add the elastic repository key to the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add - &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add elastic 5.x repository to the &#039;sources.list.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; echo &amp;quot;deb https://artifacts.elastic.co/packages/5.x/apt stable main&amp;quot; | sudo tee -a /etc/apt/sources.list.d/elastic-5.x.list &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Update the repository and install Elasticsearch 5.1 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Elasticsearch is installed. Now go to the configuration directory and edit the elasticsaerch.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; cd /etc/elasticsearch/ &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano elasticsearch.yml &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enable memory lock for Elasticsearch by removing the comment on line 43. We do this to disable swapping memory for Elasticsearchto avoid overloading the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; bootstrap.memory_lock: true &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the &#039;Network&#039; block, uncomment the network.host and http.port lines.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;network.host: localhost&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;http.port: 9200&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Now edit the elasticsearch service file for the memory lock mlockall configuration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /usr/lib/systemd/system/elasticsearch.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment LimitMEMLOCK line.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;LimitMEMLOCK=infinity&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit.&lt;br /&gt;
&lt;br /&gt;
Edit the default configuration for Elasticsearch in the /etc/default directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano /etc/default/elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment line 60 and make sure the value is &#039;unlimited&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;MAX_LOCKED_MEMORY=unlimited&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
The Elasticsearch configuration is finished. Elasticsearch will run under localhost IP address with port 9200 and we disabled swap memory by enabling mlockall on the Ubuntu server.&lt;br /&gt;
&lt;br /&gt;
Reload the Elasticsearch service file and enable it to run on the boot time, then start the service.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl daemon-reload&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable elasticsearch&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start elasticsearch&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Wait a sec for Elasticsearch to run, then check the open port on the server, make sure the &#039;state&#039; for port 9200 is &#039;LISTEN&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;netstat -plntu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then check the memory lock to ensure that mlockall is enabled. Also check that Elasticsearch is running with the commands below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
curl -XGET &#039;localhost:9200/_nodes?filter_path=**.mlockall&amp;amp;pretty&#039;&lt;br /&gt;
&lt;br /&gt;
curl -XGET &#039;localhost:9200/?pretty&#039;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see the results below.&lt;br /&gt;
&lt;br /&gt;
== Step 3 - Install and Configure Kibana with Nginx ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Kibana behind a Nginx web server. Kibana will listen on the localhost IP address only and Nginx acts as the reverse proxy for the Kibana application.&lt;br /&gt;
&lt;br /&gt;
Install Kibana with this apt command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y kibana&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the kibana.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /etc/kibana/kibana.yml&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment the server.port, server.hos and elasticsearch.url lines.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
server.port: 5601&lt;br /&gt;
&lt;br /&gt;
server.host: &amp;quot;localhost&amp;quot;&lt;br /&gt;
&lt;br /&gt;
elasticsearch.url: &amp;quot;http://localhost:9200&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Add Kibana to run at boot and start it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl enable kibana&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start kibana&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana will run on port 5601 as node application.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
netstat -plntu&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana installation is done, now we need to install Nginx and configure it as a reverse proxy to be able to access Kibana from the public IP address.&lt;br /&gt;
&lt;br /&gt;
Next, install the Nginx and apache2-utils packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo apt-get install -y nginx apache2-utils&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Apache2-utils is a package that contains tools for the webserver that work with Nginx as well, we will use htpasswd basic authentication for Kibana.&lt;br /&gt;
&lt;br /&gt;
Nginx has been installed. Now we need to create a new virtual host configuration file in the Nginx sites-available directory. Create a new file &#039;kibana&#039; with nano.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/nginx/&lt;br /&gt;
vim sites-available/kibana&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
    listen 80;&lt;br /&gt;
 &lt;br /&gt;
    server_name elk-stack.co;&lt;br /&gt;
 &lt;br /&gt;
    auth_basic &amp;quot;Restricted Access&amp;quot;;&lt;br /&gt;
    auth_basic_user_file /etc/nginx/.kibana-user;&lt;br /&gt;
 &lt;br /&gt;
    location / {&lt;br /&gt;
        proxy_pass http://localhost:5601;&lt;br /&gt;
        proxy_http_version 1.1;&lt;br /&gt;
        proxy_set_header Upgrade $http_upgrade;&lt;br /&gt;
        proxy_set_header Connection &#039;upgrade&#039;;&lt;br /&gt;
        proxy_set_header Host $host;&lt;br /&gt;
        proxy_cache_bypass $http_upgrade;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano&lt;br /&gt;
&lt;br /&gt;
Create a new basic authentication file with the htpasswd command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo htpasswd -c /etc/nginx/.kibana-user admin&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
TYPE YOUR PASSWORD&lt;br /&gt;
&lt;br /&gt;
Activate the kibana virtual host by creating a symbolic link from the kibana file in &#039;sites-available&#039; to the &#039;sites-enabled&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ln -s /etc/nginx/sites-available/kibana /etc/nginx/sites-enabled/ &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Test the nginx configuration and make sure there is no error, then add nginx to run at boot time and restart nginx.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
nginx -t&lt;br /&gt;
&lt;br /&gt;
systemctl enable nginx&lt;br /&gt;
&lt;br /&gt;
systemctl restart nginx&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Step 4 - Install and Configure Logstash == &lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Logsatash to centralize server logs from client sources with filebeat, then filter and transform all data (Syslog) and transport it to the stash (Elasticsearch).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install Logstash 5 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y logstash&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Edit the hosts file with nano.&lt;br /&gt;
&lt;br /&gt;
nano /etc/hosts&lt;br /&gt;
&lt;br /&gt;
Add the server IP address and hostname.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;10.0.2.15    elk-master&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the hosts file and exit the editor.&lt;br /&gt;
&lt;br /&gt;
Now generate a new SSL certificate file with OpenSSL so the client sources can identify the elastic server.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/logstash/&lt;br /&gt;
&lt;br /&gt;
openssl req -subj /CN=elk-master -x509 -days 3650 -batch -nodes -newkey rsa:4096 -keyout logstash.key -out logstash.crt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change the &#039;/CN&#039; value to the elastic server hostname.&lt;br /&gt;
&lt;br /&gt;
Certificate files will be created in the &#039;/etc/logstash/&#039; directory.&lt;br /&gt;
&lt;br /&gt;
Next, we will create the configuration files for logstash. We will create a configuration file &#039;filebeat-input.conf&#039; as input file from filebeat, &#039;syslog-filter.conf&#039; for syslog processing, and then a &#039;output-elasticsearch.conf&#039; file to define the Elasticsearch output.&lt;br /&gt;
&lt;br /&gt;
Go to the logstash configuration directory and create the new configuration files in the &#039;conf.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/logstash/&lt;br /&gt;
&lt;br /&gt;
nano conf.d/filebeat-input.conf&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Input configuration, paste configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input {&lt;br /&gt;
  beats {&lt;br /&gt;
    port =&amp;gt; 5443&lt;br /&gt;
    type =&amp;gt; syslog&lt;br /&gt;
    ssl =&amp;gt; true&lt;br /&gt;
    ssl_certificate =&amp;gt; &amp;quot;/etc/logstash/logstash.crt&amp;quot;&lt;br /&gt;
    ssl_key =&amp;gt; &amp;quot;/etc/logstash/logstash.key&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Create the syslog-filter.conf file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano conf.d/syslog-filter.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
filter {&lt;br /&gt;
  if [type] == &amp;quot;syslog&amp;quot; {&lt;br /&gt;
    grok {&lt;br /&gt;
      match =&amp;gt; { &amp;quot;message&amp;quot; =&amp;gt; &amp;quot;%{SYSLOGTIMESTAMP:syslog_timestamp} %{SYSLOGHOST:syslog_hostname} %{DATA:syslog_program}(?:\[%{POSINT:syslog_pid}\])?: %{GREEDYDATA:syslog_message}&amp;quot; }&lt;br /&gt;
      add_field =&amp;gt; [ &amp;quot;received_at&amp;quot;, &amp;quot;%{@timestamp}&amp;quot; ]&lt;br /&gt;
      add_field =&amp;gt; [ &amp;quot;received_from&amp;quot;, &amp;quot;%{host}&amp;quot; ]&lt;br /&gt;
    }&lt;br /&gt;
    date {&lt;br /&gt;
      match =&amp;gt; [ &amp;quot;syslog_timestamp&amp;quot;, &amp;quot;MMM  d HH:mm:ss&amp;quot;, &amp;quot;MMM dd HH:mm:ss&amp;quot; ]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We use a filter plugin named &#039;grok&#039; to parse the syslog files.&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Create the output configuration file &#039;output-elasticsearch.conf&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano conf.d/output-elasticsearch.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
output {&lt;br /&gt;
  elasticsearch { hosts =&amp;gt; [&amp;quot;localhost:9200&amp;quot;]&lt;br /&gt;
    hosts =&amp;gt; &amp;quot;localhost:9200&amp;quot;&lt;br /&gt;
    manage_template =&amp;gt; false&lt;br /&gt;
    index =&amp;gt; &amp;quot;%{[@metadata][beat]}-%{+YYYY.MM.dd}&amp;quot;&lt;br /&gt;
    document_type =&amp;gt; &amp;quot;%{[@metadata][type]}&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
When this is done, add logstash to start at boot time and start the service.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable logstash&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start logstash&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mdhasan</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123810</id>
		<title>Logging and monitoring with Elastic stack on Ubuntu 16.04</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123810"/>
		<updated>2017-06-21T20:19:39Z</updated>

		<summary type="html">&lt;p&gt;Mdhasan: /* Virtual Box setup */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
Logging and monitoring of IT systems is very important part of information security. Proper system logs and monitoring can prevent cyber attacks or service failure. In this wiki we will learn how configure logging and monitoring with ELK stack in Ubuntu server 16.04, what is alternatives (Graylog) of ELK stack and disadvantages of ELK stack.      &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Elasticsearch&#039;&#039;&#039; is an open source search engine based on Lucene, developed in java. It provides a distributed and multitenant [https://en.wikipedia.org/wiki/Full-text_search full-text search engine] with an HTTP Dashboard web-interface (Kibana) and JSON documents scheme. Elasticsearch is a scalable search engine that can be used to search for all types of documents, including log file. Elasticsearch is the heart of the &#039;Elastic Stack&#039; or ELK Stack.&amp;lt;ref&amp;gt;[https://www.elastic.co/products/elasticsearch] Elastic Search Homepage&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Logstash&#039;&#039;&#039; is an open source, server-side data processing pipeline that ingests data from a multitude of sources simultaneously, transforms it, and then sends it to Elasticsearch.&amp;lt;ref&amp;gt;[https://www.elastic.co/products/logstash] Logstash homepahe&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Kibana&#039;&#039;&#039; is a data visualization interface for Elasticsearch. Kibana provides a pretty dashboard (web interfaces), it allows you to manage and visualize all data from Elasticsearch on your own. &amp;lt;ref&amp;gt;[https://www.elastic.co/products/kibana] kibana homepage&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Prerequisite ==&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit server with 4GB of RAM, hostname - elk-master&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit client with 1 GB of RAM, hostname - elk-client&lt;br /&gt;
&lt;br /&gt;
Following installation steps from 1 to 4 is collected from &lt;br /&gt;
&lt;br /&gt;
[http://www.howtoforge.com HowToFroge.com]&amp;lt;ref&amp;gt;[http://thehackernews.com/2013/10/importance-of-logs-and-log-management.html]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Virtual Box setup ==&lt;br /&gt;
&lt;br /&gt;
As we are going to use Ubuntu server 16.04, which has no Graphical user interface (GUI). It is better to add a GUI client to Ubuntu server and ssh to virtual box setup. Here I will show to how to connect to Ubuntu server from a Ubuntu desktop client via SSH in Virtual box. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Step 1 - Virtual box Networking&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
- For both Server and Client &lt;br /&gt;
&lt;br /&gt;
- Select the virtual Machine&lt;br /&gt;
&lt;br /&gt;
- go to settings &amp;gt; network&lt;br /&gt;
&lt;br /&gt;
- set Adapter 1 as Internal network (It is better to setup static IP for adapter 1)&lt;br /&gt;
&lt;br /&gt;
- Also Add another network NAT (So the server could have internet access )&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Step 2 - Setup static IP in Ubuntu server (elk-master)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
- Become a root user &amp;lt;code&amp;gt; sudo -i &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Enable SSH by running following commands&amp;lt;ref&amp;gt;[https://askubuntu.com/questions/218344/why-am-i-getting-a-port-22-connection-refused-error open port 22 ]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; &lt;br /&gt;
sudo apt-get update&lt;br /&gt;
&lt;br /&gt;
sudo apt-get install openssh-server&lt;br /&gt;
&lt;br /&gt;
sudo ufw allow 22&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Set up static IP&lt;br /&gt;
&lt;br /&gt;
run this command &amp;lt;code&amp;gt; nano /etc/network/interfaces &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you set a static IP for primary network as screenshot:&lt;br /&gt;
&lt;br /&gt;
[[File:Static-ip-elk-master.PNG]]&lt;br /&gt;
&lt;br /&gt;
- Now go to &amp;lt;code&amp;gt;nano /etc/hosts &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add IP addresses of elk-master and elk-client as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
192.168.2.105 elk-master&lt;br /&gt;
192.168.2.106 elk-client&lt;br /&gt;
&amp;lt;/pre&amp;gt;[[File:Elk-master-hostd.PNG]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Step 2 - Setup static IP for Ubuntu Desktop(elk-client)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
- Open terminal &lt;br /&gt;
- log in as root user &lt;br /&gt;
- Run following command for Openssh&lt;br /&gt;
&amp;lt;code&amp;gt; &lt;br /&gt;
sudo apt-get update&lt;br /&gt;
&lt;br /&gt;
sudo apt-get install openssh-server&lt;br /&gt;
&lt;br /&gt;
sudo ufw allow 22&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Go to &amp;lt;code&amp;gt; nano /etc/network/interfaces &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Set static IP (example: 192.168.2.106) like ubuntu server &lt;br /&gt;
&lt;br /&gt;
- restart the Ubuntu desktop &lt;br /&gt;
&lt;br /&gt;
- Now ping ELK-MASTER by running this command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; ping elk-master &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 1 - Install Java ==&lt;br /&gt;
&lt;br /&gt;
Java is required for the Elastic stack deployment. Elasticsearch requires Java 8. It is recommended to use the Oracle JDK 1.8. We will install Java 8 from a PPA repository.&lt;br /&gt;
&lt;br /&gt;
Install the new package &#039;&#039;&#039;&#039;python-software-properties&#039;&#039;&#039;&#039; so we can add a new repository easily with an apt command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y python-software-properties software-properties-common apt-transport-https&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the new Java 8 PPA repository with the &#039;add-apt-repository&#039; command, then update the repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo add-apt-repository ppa:webupd8team/java -y &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install Java 8 from the PPA webpub8 repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y oracle-java8-installer&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 2 - Install and Configure Elasticsearch ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Elasticsearch. Install Elasticsearch from the elastic repository and configure it to run on the localhost IP.&lt;br /&gt;
&lt;br /&gt;
Before installing Elasticsearch, add the elastic repository key to the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add - &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add elastic 5.x repository to the &#039;sources.list.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; echo &amp;quot;deb https://artifacts.elastic.co/packages/5.x/apt stable main&amp;quot; | sudo tee -a /etc/apt/sources.list.d/elastic-5.x.list &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Update the repository and install Elasticsearch 5.1 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Elasticsearch is installed. Now go to the configuration directory and edit the elasticsaerch.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; cd /etc/elasticsearch/ &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano elasticsearch.yml &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enable memory lock for Elasticsearch by removing the comment on line 43. We do this to disable swapping memory for Elasticsearchto avoid overloading the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; bootstrap.memory_lock: true &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the &#039;Network&#039; block, uncomment the network.host and http.port lines.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;network.host: localhost&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;http.port: 9200&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Now edit the elasticsearch service file for the memory lock mlockall configuration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /usr/lib/systemd/system/elasticsearch.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment LimitMEMLOCK line.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;LimitMEMLOCK=infinity&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit.&lt;br /&gt;
&lt;br /&gt;
Edit the default configuration for Elasticsearch in the /etc/default directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano /etc/default/elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment line 60 and make sure the value is &#039;unlimited&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;MAX_LOCKED_MEMORY=unlimited&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
The Elasticsearch configuration is finished. Elasticsearch will run under localhost IP address with port 9200 and we disabled swap memory by enabling mlockall on the Ubuntu server.&lt;br /&gt;
&lt;br /&gt;
Reload the Elasticsearch service file and enable it to run on the boot time, then start the service.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl daemon-reload&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable elasticsearch&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start elasticsearch&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Wait a sec for Elasticsearch to run, then check the open port on the server, make sure the &#039;state&#039; for port 9200 is &#039;LISTEN&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;netstat -plntu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then check the memory lock to ensure that mlockall is enabled. Also check that Elasticsearch is running with the commands below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
curl -XGET &#039;localhost:9200/_nodes?filter_path=**.mlockall&amp;amp;pretty&#039;&lt;br /&gt;
&lt;br /&gt;
curl -XGET &#039;localhost:9200/?pretty&#039;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see the results below.&lt;br /&gt;
&lt;br /&gt;
== Step 3 - Install and Configure Kibana with Nginx ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Kibana behind a Nginx web server. Kibana will listen on the localhost IP address only and Nginx acts as the reverse proxy for the Kibana application.&lt;br /&gt;
&lt;br /&gt;
Install Kibana with this apt command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y kibana&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the kibana.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /etc/kibana/kibana.yml&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment the server.port, server.hos and elasticsearch.url lines.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
server.port: 5601&lt;br /&gt;
&lt;br /&gt;
server.host: &amp;quot;localhost&amp;quot;&lt;br /&gt;
&lt;br /&gt;
elasticsearch.url: &amp;quot;http://localhost:9200&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Add Kibana to run at boot and start it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl enable kibana&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start kibana&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana will run on port 5601 as node application.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
netstat -plntu&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana installation is done, now we need to install Nginx and configure it as a reverse proxy to be able to access Kibana from the public IP address.&lt;br /&gt;
&lt;br /&gt;
Next, install the Nginx and apache2-utils packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo apt-get install -y nginx apache2-utils&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Apache2-utils is a package that contains tools for the webserver that work with Nginx as well, we will use htpasswd basic authentication for Kibana.&lt;br /&gt;
&lt;br /&gt;
Nginx has been installed. Now we need to create a new virtual host configuration file in the Nginx sites-available directory. Create a new file &#039;kibana&#039; with nano.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/nginx/&lt;br /&gt;
vim sites-available/kibana&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
    listen 80;&lt;br /&gt;
 &lt;br /&gt;
    server_name elk-stack.co;&lt;br /&gt;
 &lt;br /&gt;
    auth_basic &amp;quot;Restricted Access&amp;quot;;&lt;br /&gt;
    auth_basic_user_file /etc/nginx/.kibana-user;&lt;br /&gt;
 &lt;br /&gt;
    location / {&lt;br /&gt;
        proxy_pass http://localhost:5601;&lt;br /&gt;
        proxy_http_version 1.1;&lt;br /&gt;
        proxy_set_header Upgrade $http_upgrade;&lt;br /&gt;
        proxy_set_header Connection &#039;upgrade&#039;;&lt;br /&gt;
        proxy_set_header Host $host;&lt;br /&gt;
        proxy_cache_bypass $http_upgrade;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano&lt;br /&gt;
&lt;br /&gt;
Create a new basic authentication file with the htpasswd command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo htpasswd -c /etc/nginx/.kibana-user admin&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
TYPE YOUR PASSWORD&lt;br /&gt;
&lt;br /&gt;
Activate the kibana virtual host by creating a symbolic link from the kibana file in &#039;sites-available&#039; to the &#039;sites-enabled&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ln -s /etc/nginx/sites-available/kibana /etc/nginx/sites-enabled/ &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Test the nginx configuration and make sure there is no error, then add nginx to run at boot time and restart nginx.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
nginx -t&lt;br /&gt;
&lt;br /&gt;
systemctl enable nginx&lt;br /&gt;
&lt;br /&gt;
systemctl restart nginx&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Step 4 - Install and Configure Logstash == &lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Logsatash to centralize server logs from client sources with filebeat, then filter and transform all data (Syslog) and transport it to the stash (Elasticsearch).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install Logstash 5 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y logstash&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Edit the hosts file with nano.&lt;br /&gt;
&lt;br /&gt;
nano /etc/hosts&lt;br /&gt;
&lt;br /&gt;
Add the server IP address and hostname.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;10.0.2.15    elk-master&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the hosts file and exit the editor.&lt;br /&gt;
&lt;br /&gt;
Now generate a new SSL certificate file with OpenSSL so the client sources can identify the elastic server.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/logstash/&lt;br /&gt;
&lt;br /&gt;
openssl req -subj /CN=elk-master -x509 -days 3650 -batch -nodes -newkey rsa:4096 -keyout logstash.key -out logstash.crt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change the &#039;/CN&#039; value to the elastic server hostname.&lt;br /&gt;
&lt;br /&gt;
Certificate files will be created in the &#039;/etc/logstash/&#039; directory.&lt;br /&gt;
&lt;br /&gt;
Next, we will create the configuration files for logstash. We will create a configuration file &#039;filebeat-input.conf&#039; as input file from filebeat, &#039;syslog-filter.conf&#039; for syslog processing, and then a &#039;output-elasticsearch.conf&#039; file to define the Elasticsearch output.&lt;br /&gt;
&lt;br /&gt;
Go to the logstash configuration directory and create the new configuration files in the &#039;conf.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/logstash/&lt;br /&gt;
&lt;br /&gt;
nano conf.d/filebeat-input.conf&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Input configuration, paste configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input {&lt;br /&gt;
  beats {&lt;br /&gt;
    port =&amp;gt; 5443&lt;br /&gt;
    type =&amp;gt; syslog&lt;br /&gt;
    ssl =&amp;gt; true&lt;br /&gt;
    ssl_certificate =&amp;gt; &amp;quot;/etc/logstash/logstash.crt&amp;quot;&lt;br /&gt;
    ssl_key =&amp;gt; &amp;quot;/etc/logstash/logstash.key&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Create the syslog-filter.conf file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano conf.d/syslog-filter.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
filter {&lt;br /&gt;
  if [type] == &amp;quot;syslog&amp;quot; {&lt;br /&gt;
    grok {&lt;br /&gt;
      match =&amp;gt; { &amp;quot;message&amp;quot; =&amp;gt; &amp;quot;%{SYSLOGTIMESTAMP:syslog_timestamp} %{SYSLOGHOST:syslog_hostname} %{DATA:syslog_program}(?:\[%{POSINT:syslog_pid}\])?: %{GREEDYDATA:syslog_message}&amp;quot; }&lt;br /&gt;
      add_field =&amp;gt; [ &amp;quot;received_at&amp;quot;, &amp;quot;%{@timestamp}&amp;quot; ]&lt;br /&gt;
      add_field =&amp;gt; [ &amp;quot;received_from&amp;quot;, &amp;quot;%{host}&amp;quot; ]&lt;br /&gt;
    }&lt;br /&gt;
    date {&lt;br /&gt;
      match =&amp;gt; [ &amp;quot;syslog_timestamp&amp;quot;, &amp;quot;MMM  d HH:mm:ss&amp;quot;, &amp;quot;MMM dd HH:mm:ss&amp;quot; ]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We use a filter plugin named &#039;grok&#039; to parse the syslog files.&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Create the output configuration file &#039;output-elasticsearch.conf&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano conf.d/output-elasticsearch.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
output {&lt;br /&gt;
  elasticsearch { hosts =&amp;gt; [&amp;quot;localhost:9200&amp;quot;]&lt;br /&gt;
    hosts =&amp;gt; &amp;quot;localhost:9200&amp;quot;&lt;br /&gt;
    manage_template =&amp;gt; false&lt;br /&gt;
    index =&amp;gt; &amp;quot;%{[@metadata][beat]}-%{+YYYY.MM.dd}&amp;quot;&lt;br /&gt;
    document_type =&amp;gt; &amp;quot;%{[@metadata][type]}&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
When this is done, add logstash to start at boot time and start the service.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable logstash&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start logstash&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mdhasan</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123809</id>
		<title>Logging and monitoring with Elastic stack on Ubuntu 16.04</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123809"/>
		<updated>2017-06-21T20:11:27Z</updated>

		<summary type="html">&lt;p&gt;Mdhasan: /* Virtual Box setup */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
Logging and monitoring of IT systems is very important part of information security. Proper system logs and monitoring can prevent cyber attacks or service failure. In this wiki we will learn how configure logging and monitoring with ELK stack in Ubuntu server 16.04, what is alternatives (Graylog) of ELK stack and disadvantages of ELK stack.      &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Elasticsearch&#039;&#039;&#039; is an open source search engine based on Lucene, developed in java. It provides a distributed and multitenant [https://en.wikipedia.org/wiki/Full-text_search full-text search engine] with an HTTP Dashboard web-interface (Kibana) and JSON documents scheme. Elasticsearch is a scalable search engine that can be used to search for all types of documents, including log file. Elasticsearch is the heart of the &#039;Elastic Stack&#039; or ELK Stack.&amp;lt;ref&amp;gt;[https://www.elastic.co/products/elasticsearch] Elastic Search Homepage&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Logstash&#039;&#039;&#039; is an open source, server-side data processing pipeline that ingests data from a multitude of sources simultaneously, transforms it, and then sends it to Elasticsearch.&amp;lt;ref&amp;gt;[https://www.elastic.co/products/logstash] Logstash homepahe&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Kibana&#039;&#039;&#039; is a data visualization interface for Elasticsearch. Kibana provides a pretty dashboard (web interfaces), it allows you to manage and visualize all data from Elasticsearch on your own. &amp;lt;ref&amp;gt;[https://www.elastic.co/products/kibana] kibana homepage&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Prerequisite ==&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit server with 4GB of RAM, hostname - elk-master&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit client with 1 GB of RAM, hostname - elk-client&lt;br /&gt;
&lt;br /&gt;
Following installation steps from 1 to 4 is collected from &lt;br /&gt;
&lt;br /&gt;
[http://www.howtoforge.com HowToFroge.com]&amp;lt;ref&amp;gt;[http://thehackernews.com/2013/10/importance-of-logs-and-log-management.html]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Virtual Box setup ==&lt;br /&gt;
&lt;br /&gt;
As we are going to use Ubuntu server 16.04, which has no Graphical user interface (GUI). It is better to add a GUI client to Ubuntu server and ssh to virtual box setup. Here I will show to how to connect to Ubuntu server from a Ubuntu desktop client via SSH in Virtual box. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Step 1 - Virtual box Networking&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
- For both Server and Client &lt;br /&gt;
&lt;br /&gt;
- Select the virtual Machine&lt;br /&gt;
&lt;br /&gt;
- go to settings &amp;gt; network&lt;br /&gt;
&lt;br /&gt;
- set Adapter 1 as Internal network (It is better to setup static IP for adapter 1)&lt;br /&gt;
&lt;br /&gt;
- Also Add another network NAT (So the server could have internet access )&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Step 2 - Setup static IP in Ubuntu server (elk-master)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
- Become a root user &amp;lt;code&amp;gt; sudo -i &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Enable SSH by running following commands&amp;lt;ref&amp;gt;[https://askubuntu.com/questions/218344/why-am-i-getting-a-port-22-connection-refused-error open port 22 ]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; &lt;br /&gt;
sudo apt-get update&lt;br /&gt;
&lt;br /&gt;
sudo apt-get install openssh-server&lt;br /&gt;
&lt;br /&gt;
sudo ufw allow 22&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Set up static IP&lt;br /&gt;
&lt;br /&gt;
run this command &amp;lt;code&amp;gt; nano /etc/network/interfaces &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you set a static IP for primary network as screenshot:&lt;br /&gt;
&lt;br /&gt;
[[File:Static-ip-elk-master.PNG]]&lt;br /&gt;
&lt;br /&gt;
- Now go to &amp;lt;code&amp;gt;nano /etc/hosts &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add IP addresses of elk-master and elk-client as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
192.168.2.105 elk-master&lt;br /&gt;
192.168.2.106 elk-client&lt;br /&gt;
&amp;lt;/pre&amp;gt;[[File:Elk-master-hostd.PNG]]&lt;br /&gt;
&lt;br /&gt;
== Step 1 - Install Java ==&lt;br /&gt;
&lt;br /&gt;
Java is required for the Elastic stack deployment. Elasticsearch requires Java 8. It is recommended to use the Oracle JDK 1.8. We will install Java 8 from a PPA repository.&lt;br /&gt;
&lt;br /&gt;
Install the new package &#039;&#039;&#039;&#039;python-software-properties&#039;&#039;&#039;&#039; so we can add a new repository easily with an apt command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y python-software-properties software-properties-common apt-transport-https&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the new Java 8 PPA repository with the &#039;add-apt-repository&#039; command, then update the repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo add-apt-repository ppa:webupd8team/java -y &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install Java 8 from the PPA webpub8 repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y oracle-java8-installer&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 2 - Install and Configure Elasticsearch ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Elasticsearch. Install Elasticsearch from the elastic repository and configure it to run on the localhost IP.&lt;br /&gt;
&lt;br /&gt;
Before installing Elasticsearch, add the elastic repository key to the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add - &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add elastic 5.x repository to the &#039;sources.list.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; echo &amp;quot;deb https://artifacts.elastic.co/packages/5.x/apt stable main&amp;quot; | sudo tee -a /etc/apt/sources.list.d/elastic-5.x.list &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Update the repository and install Elasticsearch 5.1 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Elasticsearch is installed. Now go to the configuration directory and edit the elasticsaerch.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; cd /etc/elasticsearch/ &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano elasticsearch.yml &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enable memory lock for Elasticsearch by removing the comment on line 43. We do this to disable swapping memory for Elasticsearchto avoid overloading the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; bootstrap.memory_lock: true &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the &#039;Network&#039; block, uncomment the network.host and http.port lines.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;network.host: localhost&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;http.port: 9200&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Now edit the elasticsearch service file for the memory lock mlockall configuration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /usr/lib/systemd/system/elasticsearch.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment LimitMEMLOCK line.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;LimitMEMLOCK=infinity&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit.&lt;br /&gt;
&lt;br /&gt;
Edit the default configuration for Elasticsearch in the /etc/default directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano /etc/default/elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment line 60 and make sure the value is &#039;unlimited&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;MAX_LOCKED_MEMORY=unlimited&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
The Elasticsearch configuration is finished. Elasticsearch will run under localhost IP address with port 9200 and we disabled swap memory by enabling mlockall on the Ubuntu server.&lt;br /&gt;
&lt;br /&gt;
Reload the Elasticsearch service file and enable it to run on the boot time, then start the service.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl daemon-reload&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable elasticsearch&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start elasticsearch&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Wait a sec for Elasticsearch to run, then check the open port on the server, make sure the &#039;state&#039; for port 9200 is &#039;LISTEN&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;netstat -plntu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then check the memory lock to ensure that mlockall is enabled. Also check that Elasticsearch is running with the commands below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
curl -XGET &#039;localhost:9200/_nodes?filter_path=**.mlockall&amp;amp;pretty&#039;&lt;br /&gt;
&lt;br /&gt;
curl -XGET &#039;localhost:9200/?pretty&#039;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see the results below.&lt;br /&gt;
&lt;br /&gt;
== Step 3 - Install and Configure Kibana with Nginx ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Kibana behind a Nginx web server. Kibana will listen on the localhost IP address only and Nginx acts as the reverse proxy for the Kibana application.&lt;br /&gt;
&lt;br /&gt;
Install Kibana with this apt command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y kibana&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the kibana.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /etc/kibana/kibana.yml&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment the server.port, server.hos and elasticsearch.url lines.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
server.port: 5601&lt;br /&gt;
&lt;br /&gt;
server.host: &amp;quot;localhost&amp;quot;&lt;br /&gt;
&lt;br /&gt;
elasticsearch.url: &amp;quot;http://localhost:9200&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Add Kibana to run at boot and start it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl enable kibana&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start kibana&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana will run on port 5601 as node application.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
netstat -plntu&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana installation is done, now we need to install Nginx and configure it as a reverse proxy to be able to access Kibana from the public IP address.&lt;br /&gt;
&lt;br /&gt;
Next, install the Nginx and apache2-utils packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo apt-get install -y nginx apache2-utils&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Apache2-utils is a package that contains tools for the webserver that work with Nginx as well, we will use htpasswd basic authentication for Kibana.&lt;br /&gt;
&lt;br /&gt;
Nginx has been installed. Now we need to create a new virtual host configuration file in the Nginx sites-available directory. Create a new file &#039;kibana&#039; with nano.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/nginx/&lt;br /&gt;
vim sites-available/kibana&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
    listen 80;&lt;br /&gt;
 &lt;br /&gt;
    server_name elk-stack.co;&lt;br /&gt;
 &lt;br /&gt;
    auth_basic &amp;quot;Restricted Access&amp;quot;;&lt;br /&gt;
    auth_basic_user_file /etc/nginx/.kibana-user;&lt;br /&gt;
 &lt;br /&gt;
    location / {&lt;br /&gt;
        proxy_pass http://localhost:5601;&lt;br /&gt;
        proxy_http_version 1.1;&lt;br /&gt;
        proxy_set_header Upgrade $http_upgrade;&lt;br /&gt;
        proxy_set_header Connection &#039;upgrade&#039;;&lt;br /&gt;
        proxy_set_header Host $host;&lt;br /&gt;
        proxy_cache_bypass $http_upgrade;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano&lt;br /&gt;
&lt;br /&gt;
Create a new basic authentication file with the htpasswd command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo htpasswd -c /etc/nginx/.kibana-user admin&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
TYPE YOUR PASSWORD&lt;br /&gt;
&lt;br /&gt;
Activate the kibana virtual host by creating a symbolic link from the kibana file in &#039;sites-available&#039; to the &#039;sites-enabled&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ln -s /etc/nginx/sites-available/kibana /etc/nginx/sites-enabled/ &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Test the nginx configuration and make sure there is no error, then add nginx to run at boot time and restart nginx.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
nginx -t&lt;br /&gt;
&lt;br /&gt;
systemctl enable nginx&lt;br /&gt;
&lt;br /&gt;
systemctl restart nginx&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Step 4 - Install and Configure Logstash == &lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Logsatash to centralize server logs from client sources with filebeat, then filter and transform all data (Syslog) and transport it to the stash (Elasticsearch).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install Logstash 5 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y logstash&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Edit the hosts file with nano.&lt;br /&gt;
&lt;br /&gt;
nano /etc/hosts&lt;br /&gt;
&lt;br /&gt;
Add the server IP address and hostname.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;10.0.2.15    elk-master&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the hosts file and exit the editor.&lt;br /&gt;
&lt;br /&gt;
Now generate a new SSL certificate file with OpenSSL so the client sources can identify the elastic server.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/logstash/&lt;br /&gt;
&lt;br /&gt;
openssl req -subj /CN=elk-master -x509 -days 3650 -batch -nodes -newkey rsa:4096 -keyout logstash.key -out logstash.crt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change the &#039;/CN&#039; value to the elastic server hostname.&lt;br /&gt;
&lt;br /&gt;
Certificate files will be created in the &#039;/etc/logstash/&#039; directory.&lt;br /&gt;
&lt;br /&gt;
Next, we will create the configuration files for logstash. We will create a configuration file &#039;filebeat-input.conf&#039; as input file from filebeat, &#039;syslog-filter.conf&#039; for syslog processing, and then a &#039;output-elasticsearch.conf&#039; file to define the Elasticsearch output.&lt;br /&gt;
&lt;br /&gt;
Go to the logstash configuration directory and create the new configuration files in the &#039;conf.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/logstash/&lt;br /&gt;
&lt;br /&gt;
nano conf.d/filebeat-input.conf&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Input configuration, paste configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input {&lt;br /&gt;
  beats {&lt;br /&gt;
    port =&amp;gt; 5443&lt;br /&gt;
    type =&amp;gt; syslog&lt;br /&gt;
    ssl =&amp;gt; true&lt;br /&gt;
    ssl_certificate =&amp;gt; &amp;quot;/etc/logstash/logstash.crt&amp;quot;&lt;br /&gt;
    ssl_key =&amp;gt; &amp;quot;/etc/logstash/logstash.key&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Create the syslog-filter.conf file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano conf.d/syslog-filter.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
filter {&lt;br /&gt;
  if [type] == &amp;quot;syslog&amp;quot; {&lt;br /&gt;
    grok {&lt;br /&gt;
      match =&amp;gt; { &amp;quot;message&amp;quot; =&amp;gt; &amp;quot;%{SYSLOGTIMESTAMP:syslog_timestamp} %{SYSLOGHOST:syslog_hostname} %{DATA:syslog_program}(?:\[%{POSINT:syslog_pid}\])?: %{GREEDYDATA:syslog_message}&amp;quot; }&lt;br /&gt;
      add_field =&amp;gt; [ &amp;quot;received_at&amp;quot;, &amp;quot;%{@timestamp}&amp;quot; ]&lt;br /&gt;
      add_field =&amp;gt; [ &amp;quot;received_from&amp;quot;, &amp;quot;%{host}&amp;quot; ]&lt;br /&gt;
    }&lt;br /&gt;
    date {&lt;br /&gt;
      match =&amp;gt; [ &amp;quot;syslog_timestamp&amp;quot;, &amp;quot;MMM  d HH:mm:ss&amp;quot;, &amp;quot;MMM dd HH:mm:ss&amp;quot; ]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We use a filter plugin named &#039;grok&#039; to parse the syslog files.&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Create the output configuration file &#039;output-elasticsearch.conf&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano conf.d/output-elasticsearch.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
output {&lt;br /&gt;
  elasticsearch { hosts =&amp;gt; [&amp;quot;localhost:9200&amp;quot;]&lt;br /&gt;
    hosts =&amp;gt; &amp;quot;localhost:9200&amp;quot;&lt;br /&gt;
    manage_template =&amp;gt; false&lt;br /&gt;
    index =&amp;gt; &amp;quot;%{[@metadata][beat]}-%{+YYYY.MM.dd}&amp;quot;&lt;br /&gt;
    document_type =&amp;gt; &amp;quot;%{[@metadata][type]}&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
When this is done, add logstash to start at boot time and start the service.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable logstash&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start logstash&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mdhasan</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123808</id>
		<title>Logging and monitoring with Elastic stack on Ubuntu 16.04</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123808"/>
		<updated>2017-06-21T20:10:28Z</updated>

		<summary type="html">&lt;p&gt;Mdhasan: /* Virtual Box setup */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
Logging and monitoring of IT systems is very important part of information security. Proper system logs and monitoring can prevent cyber attacks or service failure. In this wiki we will learn how configure logging and monitoring with ELK stack in Ubuntu server 16.04, what is alternatives (Graylog) of ELK stack and disadvantages of ELK stack.      &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Elasticsearch&#039;&#039;&#039; is an open source search engine based on Lucene, developed in java. It provides a distributed and multitenant [https://en.wikipedia.org/wiki/Full-text_search full-text search engine] with an HTTP Dashboard web-interface (Kibana) and JSON documents scheme. Elasticsearch is a scalable search engine that can be used to search for all types of documents, including log file. Elasticsearch is the heart of the &#039;Elastic Stack&#039; or ELK Stack.&amp;lt;ref&amp;gt;[https://www.elastic.co/products/elasticsearch] Elastic Search Homepage&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Logstash&#039;&#039;&#039; is an open source, server-side data processing pipeline that ingests data from a multitude of sources simultaneously, transforms it, and then sends it to Elasticsearch.&amp;lt;ref&amp;gt;[https://www.elastic.co/products/logstash] Logstash homepahe&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Kibana&#039;&#039;&#039; is a data visualization interface for Elasticsearch. Kibana provides a pretty dashboard (web interfaces), it allows you to manage and visualize all data from Elasticsearch on your own. &amp;lt;ref&amp;gt;[https://www.elastic.co/products/kibana] kibana homepage&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Prerequisite ==&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit server with 4GB of RAM, hostname - elk-master&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit client with 1 GB of RAM, hostname - elk-client&lt;br /&gt;
&lt;br /&gt;
Following installation steps from 1 to 4 is collected from &lt;br /&gt;
&lt;br /&gt;
[http://www.howtoforge.com HowToFroge.com]&amp;lt;ref&amp;gt;[http://thehackernews.com/2013/10/importance-of-logs-and-log-management.html]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Virtual Box setup ==&lt;br /&gt;
&lt;br /&gt;
As we are going to use Ubuntu server 16.04, which has no Graphical user interface (GUI). It is better to add a GUI client to Ubuntu server and ssh to virtual box setup. Here I will show to how to connect to Ubuntu server from a Ubuntu desktop client via SSH in Virtual box. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Step 1 - Virtual box Networking&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
- For both Server and Client follow this settings &lt;br /&gt;
&lt;br /&gt;
- go to settings &amp;gt; network&lt;br /&gt;
&lt;br /&gt;
- set Adapter 1 as Internal network (It is better to setup static IP for adapter 1)&lt;br /&gt;
&lt;br /&gt;
- Also Add another network NAT (So the server could have internet access )&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Step 2 - Setup static IP in Ubuntu server (elk-master)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
- Become a root user &amp;lt;code&amp;gt; sudo -i &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Enable SSH by running following commands&amp;lt;ref&amp;gt;[https://askubuntu.com/questions/218344/why-am-i-getting-a-port-22-connection-refused-error open port 22 ]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; &lt;br /&gt;
sudo apt-get update&lt;br /&gt;
&lt;br /&gt;
sudo apt-get install openssh-server&lt;br /&gt;
&lt;br /&gt;
sudo ufw allow 22&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Set up static IP&lt;br /&gt;
&lt;br /&gt;
run this command &amp;lt;code&amp;gt; nano /etc/network/interfaces &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you set a static IP for primary network as screenshot:&lt;br /&gt;
&lt;br /&gt;
[[File:Static-ip-elk-master.PNG]]&lt;br /&gt;
&lt;br /&gt;
- Now go to &amp;lt;code&amp;gt;nano /etc/hosts &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add IP addresses of elk-master and elk-client as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
192.168.2.105 elk-master&lt;br /&gt;
192.168.2.106 elk-client&lt;br /&gt;
&amp;lt;/pre&amp;gt;[[File:Elk-master-hostd.PNG]]&lt;br /&gt;
&lt;br /&gt;
== Step 1 - Install Java ==&lt;br /&gt;
&lt;br /&gt;
Java is required for the Elastic stack deployment. Elasticsearch requires Java 8. It is recommended to use the Oracle JDK 1.8. We will install Java 8 from a PPA repository.&lt;br /&gt;
&lt;br /&gt;
Install the new package &#039;&#039;&#039;&#039;python-software-properties&#039;&#039;&#039;&#039; so we can add a new repository easily with an apt command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y python-software-properties software-properties-common apt-transport-https&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the new Java 8 PPA repository with the &#039;add-apt-repository&#039; command, then update the repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo add-apt-repository ppa:webupd8team/java -y &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install Java 8 from the PPA webpub8 repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y oracle-java8-installer&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 2 - Install and Configure Elasticsearch ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Elasticsearch. Install Elasticsearch from the elastic repository and configure it to run on the localhost IP.&lt;br /&gt;
&lt;br /&gt;
Before installing Elasticsearch, add the elastic repository key to the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add - &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add elastic 5.x repository to the &#039;sources.list.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; echo &amp;quot;deb https://artifacts.elastic.co/packages/5.x/apt stable main&amp;quot; | sudo tee -a /etc/apt/sources.list.d/elastic-5.x.list &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Update the repository and install Elasticsearch 5.1 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Elasticsearch is installed. Now go to the configuration directory and edit the elasticsaerch.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; cd /etc/elasticsearch/ &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano elasticsearch.yml &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enable memory lock for Elasticsearch by removing the comment on line 43. We do this to disable swapping memory for Elasticsearchto avoid overloading the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; bootstrap.memory_lock: true &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the &#039;Network&#039; block, uncomment the network.host and http.port lines.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;network.host: localhost&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;http.port: 9200&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Now edit the elasticsearch service file for the memory lock mlockall configuration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /usr/lib/systemd/system/elasticsearch.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment LimitMEMLOCK line.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;LimitMEMLOCK=infinity&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit.&lt;br /&gt;
&lt;br /&gt;
Edit the default configuration for Elasticsearch in the /etc/default directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano /etc/default/elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment line 60 and make sure the value is &#039;unlimited&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;MAX_LOCKED_MEMORY=unlimited&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
The Elasticsearch configuration is finished. Elasticsearch will run under localhost IP address with port 9200 and we disabled swap memory by enabling mlockall on the Ubuntu server.&lt;br /&gt;
&lt;br /&gt;
Reload the Elasticsearch service file and enable it to run on the boot time, then start the service.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl daemon-reload&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable elasticsearch&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start elasticsearch&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Wait a sec for Elasticsearch to run, then check the open port on the server, make sure the &#039;state&#039; for port 9200 is &#039;LISTEN&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;netstat -plntu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then check the memory lock to ensure that mlockall is enabled. Also check that Elasticsearch is running with the commands below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
curl -XGET &#039;localhost:9200/_nodes?filter_path=**.mlockall&amp;amp;pretty&#039;&lt;br /&gt;
&lt;br /&gt;
curl -XGET &#039;localhost:9200/?pretty&#039;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see the results below.&lt;br /&gt;
&lt;br /&gt;
== Step 3 - Install and Configure Kibana with Nginx ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Kibana behind a Nginx web server. Kibana will listen on the localhost IP address only and Nginx acts as the reverse proxy for the Kibana application.&lt;br /&gt;
&lt;br /&gt;
Install Kibana with this apt command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y kibana&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the kibana.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /etc/kibana/kibana.yml&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment the server.port, server.hos and elasticsearch.url lines.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
server.port: 5601&lt;br /&gt;
&lt;br /&gt;
server.host: &amp;quot;localhost&amp;quot;&lt;br /&gt;
&lt;br /&gt;
elasticsearch.url: &amp;quot;http://localhost:9200&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Add Kibana to run at boot and start it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl enable kibana&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start kibana&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana will run on port 5601 as node application.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
netstat -plntu&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana installation is done, now we need to install Nginx and configure it as a reverse proxy to be able to access Kibana from the public IP address.&lt;br /&gt;
&lt;br /&gt;
Next, install the Nginx and apache2-utils packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo apt-get install -y nginx apache2-utils&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Apache2-utils is a package that contains tools for the webserver that work with Nginx as well, we will use htpasswd basic authentication for Kibana.&lt;br /&gt;
&lt;br /&gt;
Nginx has been installed. Now we need to create a new virtual host configuration file in the Nginx sites-available directory. Create a new file &#039;kibana&#039; with nano.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/nginx/&lt;br /&gt;
vim sites-available/kibana&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
    listen 80;&lt;br /&gt;
 &lt;br /&gt;
    server_name elk-stack.co;&lt;br /&gt;
 &lt;br /&gt;
    auth_basic &amp;quot;Restricted Access&amp;quot;;&lt;br /&gt;
    auth_basic_user_file /etc/nginx/.kibana-user;&lt;br /&gt;
 &lt;br /&gt;
    location / {&lt;br /&gt;
        proxy_pass http://localhost:5601;&lt;br /&gt;
        proxy_http_version 1.1;&lt;br /&gt;
        proxy_set_header Upgrade $http_upgrade;&lt;br /&gt;
        proxy_set_header Connection &#039;upgrade&#039;;&lt;br /&gt;
        proxy_set_header Host $host;&lt;br /&gt;
        proxy_cache_bypass $http_upgrade;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano&lt;br /&gt;
&lt;br /&gt;
Create a new basic authentication file with the htpasswd command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo htpasswd -c /etc/nginx/.kibana-user admin&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
TYPE YOUR PASSWORD&lt;br /&gt;
&lt;br /&gt;
Activate the kibana virtual host by creating a symbolic link from the kibana file in &#039;sites-available&#039; to the &#039;sites-enabled&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ln -s /etc/nginx/sites-available/kibana /etc/nginx/sites-enabled/ &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Test the nginx configuration and make sure there is no error, then add nginx to run at boot time and restart nginx.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
nginx -t&lt;br /&gt;
&lt;br /&gt;
systemctl enable nginx&lt;br /&gt;
&lt;br /&gt;
systemctl restart nginx&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Step 4 - Install and Configure Logstash == &lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Logsatash to centralize server logs from client sources with filebeat, then filter and transform all data (Syslog) and transport it to the stash (Elasticsearch).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install Logstash 5 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y logstash&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Edit the hosts file with nano.&lt;br /&gt;
&lt;br /&gt;
nano /etc/hosts&lt;br /&gt;
&lt;br /&gt;
Add the server IP address and hostname.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;10.0.2.15    elk-master&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the hosts file and exit the editor.&lt;br /&gt;
&lt;br /&gt;
Now generate a new SSL certificate file with OpenSSL so the client sources can identify the elastic server.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/logstash/&lt;br /&gt;
&lt;br /&gt;
openssl req -subj /CN=elk-master -x509 -days 3650 -batch -nodes -newkey rsa:4096 -keyout logstash.key -out logstash.crt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change the &#039;/CN&#039; value to the elastic server hostname.&lt;br /&gt;
&lt;br /&gt;
Certificate files will be created in the &#039;/etc/logstash/&#039; directory.&lt;br /&gt;
&lt;br /&gt;
Next, we will create the configuration files for logstash. We will create a configuration file &#039;filebeat-input.conf&#039; as input file from filebeat, &#039;syslog-filter.conf&#039; for syslog processing, and then a &#039;output-elasticsearch.conf&#039; file to define the Elasticsearch output.&lt;br /&gt;
&lt;br /&gt;
Go to the logstash configuration directory and create the new configuration files in the &#039;conf.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/logstash/&lt;br /&gt;
&lt;br /&gt;
nano conf.d/filebeat-input.conf&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Input configuration, paste configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input {&lt;br /&gt;
  beats {&lt;br /&gt;
    port =&amp;gt; 5443&lt;br /&gt;
    type =&amp;gt; syslog&lt;br /&gt;
    ssl =&amp;gt; true&lt;br /&gt;
    ssl_certificate =&amp;gt; &amp;quot;/etc/logstash/logstash.crt&amp;quot;&lt;br /&gt;
    ssl_key =&amp;gt; &amp;quot;/etc/logstash/logstash.key&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Create the syslog-filter.conf file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano conf.d/syslog-filter.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
filter {&lt;br /&gt;
  if [type] == &amp;quot;syslog&amp;quot; {&lt;br /&gt;
    grok {&lt;br /&gt;
      match =&amp;gt; { &amp;quot;message&amp;quot; =&amp;gt; &amp;quot;%{SYSLOGTIMESTAMP:syslog_timestamp} %{SYSLOGHOST:syslog_hostname} %{DATA:syslog_program}(?:\[%{POSINT:syslog_pid}\])?: %{GREEDYDATA:syslog_message}&amp;quot; }&lt;br /&gt;
      add_field =&amp;gt; [ &amp;quot;received_at&amp;quot;, &amp;quot;%{@timestamp}&amp;quot; ]&lt;br /&gt;
      add_field =&amp;gt; [ &amp;quot;received_from&amp;quot;, &amp;quot;%{host}&amp;quot; ]&lt;br /&gt;
    }&lt;br /&gt;
    date {&lt;br /&gt;
      match =&amp;gt; [ &amp;quot;syslog_timestamp&amp;quot;, &amp;quot;MMM  d HH:mm:ss&amp;quot;, &amp;quot;MMM dd HH:mm:ss&amp;quot; ]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We use a filter plugin named &#039;grok&#039; to parse the syslog files.&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Create the output configuration file &#039;output-elasticsearch.conf&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano conf.d/output-elasticsearch.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
output {&lt;br /&gt;
  elasticsearch { hosts =&amp;gt; [&amp;quot;localhost:9200&amp;quot;]&lt;br /&gt;
    hosts =&amp;gt; &amp;quot;localhost:9200&amp;quot;&lt;br /&gt;
    manage_template =&amp;gt; false&lt;br /&gt;
    index =&amp;gt; &amp;quot;%{[@metadata][beat]}-%{+YYYY.MM.dd}&amp;quot;&lt;br /&gt;
    document_type =&amp;gt; &amp;quot;%{[@metadata][type]}&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
When this is done, add logstash to start at boot time and start the service.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable logstash&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start logstash&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mdhasan</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123807</id>
		<title>Logging and monitoring with Elastic stack on Ubuntu 16.04</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123807"/>
		<updated>2017-06-21T20:08:44Z</updated>

		<summary type="html">&lt;p&gt;Mdhasan: /* Virtual Box setup */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
Logging and monitoring of IT systems is very important part of information security. Proper system logs and monitoring can prevent cyber attacks or service failure. In this wiki we will learn how configure logging and monitoring with ELK stack in Ubuntu server 16.04, what is alternatives (Graylog) of ELK stack and disadvantages of ELK stack.      &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Elasticsearch&#039;&#039;&#039; is an open source search engine based on Lucene, developed in java. It provides a distributed and multitenant [https://en.wikipedia.org/wiki/Full-text_search full-text search engine] with an HTTP Dashboard web-interface (Kibana) and JSON documents scheme. Elasticsearch is a scalable search engine that can be used to search for all types of documents, including log file. Elasticsearch is the heart of the &#039;Elastic Stack&#039; or ELK Stack.&amp;lt;ref&amp;gt;[https://www.elastic.co/products/elasticsearch] Elastic Search Homepage&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Logstash&#039;&#039;&#039; is an open source, server-side data processing pipeline that ingests data from a multitude of sources simultaneously, transforms it, and then sends it to Elasticsearch.&amp;lt;ref&amp;gt;[https://www.elastic.co/products/logstash] Logstash homepahe&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Kibana&#039;&#039;&#039; is a data visualization interface for Elasticsearch. Kibana provides a pretty dashboard (web interfaces), it allows you to manage and visualize all data from Elasticsearch on your own. &amp;lt;ref&amp;gt;[https://www.elastic.co/products/kibana] kibana homepage&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Prerequisite ==&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit server with 4GB of RAM, hostname - elk-master&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit client with 1 GB of RAM, hostname - elk-client&lt;br /&gt;
&lt;br /&gt;
Following installation steps from 1 to 4 is collected from &lt;br /&gt;
&lt;br /&gt;
[http://www.howtoforge.com HowToFroge.com]&amp;lt;ref&amp;gt;[http://thehackernews.com/2013/10/importance-of-logs-and-log-management.html]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Virtual Box setup ==&lt;br /&gt;
&lt;br /&gt;
As we are going to use Ubuntu server 16.04, which has no Graphical user interface (GUI). It is better to add a GUI client to Ubuntu server and ssh to virtual box setup. Here I will show to how to connect to Ubuntu server from a Ubuntu desktop client via SSH in Virtual box. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Step 1 - Virtual box Networking&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
- Select the Virtual machine Ubuntu server 16.04&lt;br /&gt;
&lt;br /&gt;
- go to settings &amp;gt; network&lt;br /&gt;
&lt;br /&gt;
- set Adapter 1 as Internal network (It is better to setup static IP for adapter 1)&lt;br /&gt;
&lt;br /&gt;
- Also Add another network NAT (So the server could have internet access )&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Step 2 - Setup static IP in Ubuntu server (elk-master)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
- Become a root user &amp;lt;code&amp;gt; sudo -i &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Enable SSH by running following commands&amp;lt;ref&amp;gt;[https://askubuntu.com/questions/218344/why-am-i-getting-a-port-22-connection-refused-error open port 22 ]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; &lt;br /&gt;
sudo apt-get update&lt;br /&gt;
&lt;br /&gt;
sudo apt-get install openssh-server&lt;br /&gt;
&lt;br /&gt;
sudo ufw allow 22&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Set up static IP&lt;br /&gt;
&lt;br /&gt;
run this command &amp;lt;code&amp;gt; nano /etc/network/interfaces &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you set a static IP for primary network as screenshot:&lt;br /&gt;
&lt;br /&gt;
[[File:Static-ip-elk-master.PNG]]&lt;br /&gt;
&lt;br /&gt;
- Now go to &amp;lt;code&amp;gt;nano /etc/hosts &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add IP addresses of elk-master and elk-client as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
192.168.2.105 elk-master&lt;br /&gt;
192.168.2.106 elk-client&lt;br /&gt;
&amp;lt;/pre&amp;gt;[[File:Elk-master-hostd.PNG]]&lt;br /&gt;
&lt;br /&gt;
== Step 1 - Install Java ==&lt;br /&gt;
&lt;br /&gt;
Java is required for the Elastic stack deployment. Elasticsearch requires Java 8. It is recommended to use the Oracle JDK 1.8. We will install Java 8 from a PPA repository.&lt;br /&gt;
&lt;br /&gt;
Install the new package &#039;&#039;&#039;&#039;python-software-properties&#039;&#039;&#039;&#039; so we can add a new repository easily with an apt command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y python-software-properties software-properties-common apt-transport-https&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the new Java 8 PPA repository with the &#039;add-apt-repository&#039; command, then update the repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo add-apt-repository ppa:webupd8team/java -y &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install Java 8 from the PPA webpub8 repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y oracle-java8-installer&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 2 - Install and Configure Elasticsearch ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Elasticsearch. Install Elasticsearch from the elastic repository and configure it to run on the localhost IP.&lt;br /&gt;
&lt;br /&gt;
Before installing Elasticsearch, add the elastic repository key to the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add - &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add elastic 5.x repository to the &#039;sources.list.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; echo &amp;quot;deb https://artifacts.elastic.co/packages/5.x/apt stable main&amp;quot; | sudo tee -a /etc/apt/sources.list.d/elastic-5.x.list &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Update the repository and install Elasticsearch 5.1 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Elasticsearch is installed. Now go to the configuration directory and edit the elasticsaerch.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; cd /etc/elasticsearch/ &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano elasticsearch.yml &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enable memory lock for Elasticsearch by removing the comment on line 43. We do this to disable swapping memory for Elasticsearchto avoid overloading the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; bootstrap.memory_lock: true &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the &#039;Network&#039; block, uncomment the network.host and http.port lines.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;network.host: localhost&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;http.port: 9200&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Now edit the elasticsearch service file for the memory lock mlockall configuration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /usr/lib/systemd/system/elasticsearch.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment LimitMEMLOCK line.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;LimitMEMLOCK=infinity&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit.&lt;br /&gt;
&lt;br /&gt;
Edit the default configuration for Elasticsearch in the /etc/default directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano /etc/default/elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment line 60 and make sure the value is &#039;unlimited&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;MAX_LOCKED_MEMORY=unlimited&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
The Elasticsearch configuration is finished. Elasticsearch will run under localhost IP address with port 9200 and we disabled swap memory by enabling mlockall on the Ubuntu server.&lt;br /&gt;
&lt;br /&gt;
Reload the Elasticsearch service file and enable it to run on the boot time, then start the service.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl daemon-reload&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable elasticsearch&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start elasticsearch&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Wait a sec for Elasticsearch to run, then check the open port on the server, make sure the &#039;state&#039; for port 9200 is &#039;LISTEN&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;netstat -plntu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then check the memory lock to ensure that mlockall is enabled. Also check that Elasticsearch is running with the commands below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
curl -XGET &#039;localhost:9200/_nodes?filter_path=**.mlockall&amp;amp;pretty&#039;&lt;br /&gt;
&lt;br /&gt;
curl -XGET &#039;localhost:9200/?pretty&#039;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see the results below.&lt;br /&gt;
&lt;br /&gt;
== Step 3 - Install and Configure Kibana with Nginx ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Kibana behind a Nginx web server. Kibana will listen on the localhost IP address only and Nginx acts as the reverse proxy for the Kibana application.&lt;br /&gt;
&lt;br /&gt;
Install Kibana with this apt command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y kibana&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the kibana.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /etc/kibana/kibana.yml&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment the server.port, server.hos and elasticsearch.url lines.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
server.port: 5601&lt;br /&gt;
&lt;br /&gt;
server.host: &amp;quot;localhost&amp;quot;&lt;br /&gt;
&lt;br /&gt;
elasticsearch.url: &amp;quot;http://localhost:9200&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Add Kibana to run at boot and start it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl enable kibana&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start kibana&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana will run on port 5601 as node application.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
netstat -plntu&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana installation is done, now we need to install Nginx and configure it as a reverse proxy to be able to access Kibana from the public IP address.&lt;br /&gt;
&lt;br /&gt;
Next, install the Nginx and apache2-utils packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo apt-get install -y nginx apache2-utils&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Apache2-utils is a package that contains tools for the webserver that work with Nginx as well, we will use htpasswd basic authentication for Kibana.&lt;br /&gt;
&lt;br /&gt;
Nginx has been installed. Now we need to create a new virtual host configuration file in the Nginx sites-available directory. Create a new file &#039;kibana&#039; with nano.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/nginx/&lt;br /&gt;
vim sites-available/kibana&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
    listen 80;&lt;br /&gt;
 &lt;br /&gt;
    server_name elk-stack.co;&lt;br /&gt;
 &lt;br /&gt;
    auth_basic &amp;quot;Restricted Access&amp;quot;;&lt;br /&gt;
    auth_basic_user_file /etc/nginx/.kibana-user;&lt;br /&gt;
 &lt;br /&gt;
    location / {&lt;br /&gt;
        proxy_pass http://localhost:5601;&lt;br /&gt;
        proxy_http_version 1.1;&lt;br /&gt;
        proxy_set_header Upgrade $http_upgrade;&lt;br /&gt;
        proxy_set_header Connection &#039;upgrade&#039;;&lt;br /&gt;
        proxy_set_header Host $host;&lt;br /&gt;
        proxy_cache_bypass $http_upgrade;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano&lt;br /&gt;
&lt;br /&gt;
Create a new basic authentication file with the htpasswd command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo htpasswd -c /etc/nginx/.kibana-user admin&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
TYPE YOUR PASSWORD&lt;br /&gt;
&lt;br /&gt;
Activate the kibana virtual host by creating a symbolic link from the kibana file in &#039;sites-available&#039; to the &#039;sites-enabled&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ln -s /etc/nginx/sites-available/kibana /etc/nginx/sites-enabled/ &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Test the nginx configuration and make sure there is no error, then add nginx to run at boot time and restart nginx.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
nginx -t&lt;br /&gt;
&lt;br /&gt;
systemctl enable nginx&lt;br /&gt;
&lt;br /&gt;
systemctl restart nginx&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Step 4 - Install and Configure Logstash == &lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Logsatash to centralize server logs from client sources with filebeat, then filter and transform all data (Syslog) and transport it to the stash (Elasticsearch).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install Logstash 5 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y logstash&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Edit the hosts file with nano.&lt;br /&gt;
&lt;br /&gt;
nano /etc/hosts&lt;br /&gt;
&lt;br /&gt;
Add the server IP address and hostname.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;10.0.2.15    elk-master&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the hosts file and exit the editor.&lt;br /&gt;
&lt;br /&gt;
Now generate a new SSL certificate file with OpenSSL so the client sources can identify the elastic server.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/logstash/&lt;br /&gt;
&lt;br /&gt;
openssl req -subj /CN=elk-master -x509 -days 3650 -batch -nodes -newkey rsa:4096 -keyout logstash.key -out logstash.crt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change the &#039;/CN&#039; value to the elastic server hostname.&lt;br /&gt;
&lt;br /&gt;
Certificate files will be created in the &#039;/etc/logstash/&#039; directory.&lt;br /&gt;
&lt;br /&gt;
Next, we will create the configuration files for logstash. We will create a configuration file &#039;filebeat-input.conf&#039; as input file from filebeat, &#039;syslog-filter.conf&#039; for syslog processing, and then a &#039;output-elasticsearch.conf&#039; file to define the Elasticsearch output.&lt;br /&gt;
&lt;br /&gt;
Go to the logstash configuration directory and create the new configuration files in the &#039;conf.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/logstash/&lt;br /&gt;
&lt;br /&gt;
nano conf.d/filebeat-input.conf&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Input configuration, paste configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input {&lt;br /&gt;
  beats {&lt;br /&gt;
    port =&amp;gt; 5443&lt;br /&gt;
    type =&amp;gt; syslog&lt;br /&gt;
    ssl =&amp;gt; true&lt;br /&gt;
    ssl_certificate =&amp;gt; &amp;quot;/etc/logstash/logstash.crt&amp;quot;&lt;br /&gt;
    ssl_key =&amp;gt; &amp;quot;/etc/logstash/logstash.key&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Create the syslog-filter.conf file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano conf.d/syslog-filter.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
filter {&lt;br /&gt;
  if [type] == &amp;quot;syslog&amp;quot; {&lt;br /&gt;
    grok {&lt;br /&gt;
      match =&amp;gt; { &amp;quot;message&amp;quot; =&amp;gt; &amp;quot;%{SYSLOGTIMESTAMP:syslog_timestamp} %{SYSLOGHOST:syslog_hostname} %{DATA:syslog_program}(?:\[%{POSINT:syslog_pid}\])?: %{GREEDYDATA:syslog_message}&amp;quot; }&lt;br /&gt;
      add_field =&amp;gt; [ &amp;quot;received_at&amp;quot;, &amp;quot;%{@timestamp}&amp;quot; ]&lt;br /&gt;
      add_field =&amp;gt; [ &amp;quot;received_from&amp;quot;, &amp;quot;%{host}&amp;quot; ]&lt;br /&gt;
    }&lt;br /&gt;
    date {&lt;br /&gt;
      match =&amp;gt; [ &amp;quot;syslog_timestamp&amp;quot;, &amp;quot;MMM  d HH:mm:ss&amp;quot;, &amp;quot;MMM dd HH:mm:ss&amp;quot; ]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We use a filter plugin named &#039;grok&#039; to parse the syslog files.&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Create the output configuration file &#039;output-elasticsearch.conf&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano conf.d/output-elasticsearch.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
output {&lt;br /&gt;
  elasticsearch { hosts =&amp;gt; [&amp;quot;localhost:9200&amp;quot;]&lt;br /&gt;
    hosts =&amp;gt; &amp;quot;localhost:9200&amp;quot;&lt;br /&gt;
    manage_template =&amp;gt; false&lt;br /&gt;
    index =&amp;gt; &amp;quot;%{[@metadata][beat]}-%{+YYYY.MM.dd}&amp;quot;&lt;br /&gt;
    document_type =&amp;gt; &amp;quot;%{[@metadata][type]}&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
When this is done, add logstash to start at boot time and start the service.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable logstash&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start logstash&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mdhasan</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123806</id>
		<title>Logging and monitoring with Elastic stack on Ubuntu 16.04</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123806"/>
		<updated>2017-06-21T20:08:28Z</updated>

		<summary type="html">&lt;p&gt;Mdhasan: /* Virtual Box setup */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
Logging and monitoring of IT systems is very important part of information security. Proper system logs and monitoring can prevent cyber attacks or service failure. In this wiki we will learn how configure logging and monitoring with ELK stack in Ubuntu server 16.04, what is alternatives (Graylog) of ELK stack and disadvantages of ELK stack.      &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Elasticsearch&#039;&#039;&#039; is an open source search engine based on Lucene, developed in java. It provides a distributed and multitenant [https://en.wikipedia.org/wiki/Full-text_search full-text search engine] with an HTTP Dashboard web-interface (Kibana) and JSON documents scheme. Elasticsearch is a scalable search engine that can be used to search for all types of documents, including log file. Elasticsearch is the heart of the &#039;Elastic Stack&#039; or ELK Stack.&amp;lt;ref&amp;gt;[https://www.elastic.co/products/elasticsearch] Elastic Search Homepage&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Logstash&#039;&#039;&#039; is an open source, server-side data processing pipeline that ingests data from a multitude of sources simultaneously, transforms it, and then sends it to Elasticsearch.&amp;lt;ref&amp;gt;[https://www.elastic.co/products/logstash] Logstash homepahe&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Kibana&#039;&#039;&#039; is a data visualization interface for Elasticsearch. Kibana provides a pretty dashboard (web interfaces), it allows you to manage and visualize all data from Elasticsearch on your own. &amp;lt;ref&amp;gt;[https://www.elastic.co/products/kibana] kibana homepage&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Prerequisite ==&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit server with 4GB of RAM, hostname - elk-master&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit client with 1 GB of RAM, hostname - elk-client&lt;br /&gt;
&lt;br /&gt;
Following installation steps from 1 to 4 is collected from &lt;br /&gt;
&lt;br /&gt;
[http://www.howtoforge.com HowToFroge.com]&amp;lt;ref&amp;gt;[http://thehackernews.com/2013/10/importance-of-logs-and-log-management.html]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Virtual Box setup ==&lt;br /&gt;
&lt;br /&gt;
As we are going to use Ubuntu server 16.04, which has no Graphical user interface (GUI). It is better to add a GUI client to Ubuntu server and ssh to virtual box setup. Here I will show to how to connect to Ubuntu server from a Ubuntu desktop client via SSH in Virtual box. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Step 1 - Virtual box Networking&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
- Select the Virtual machine Ubuntu server 16.04&lt;br /&gt;
&lt;br /&gt;
- go to settings &amp;gt; network&lt;br /&gt;
&lt;br /&gt;
- set Adapter 1 as Internal network (It is better to setup static IP for adapter 1)&lt;br /&gt;
&lt;br /&gt;
- Also Add another network NAT (So the server will have internet access )&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Step 2 - Setup static IP in Ubuntu server (elk-master)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
- Become a root user &amp;lt;code&amp;gt; sudo -i &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Enable SSH by running following commands&amp;lt;ref&amp;gt;[https://askubuntu.com/questions/218344/why-am-i-getting-a-port-22-connection-refused-error open port 22 ]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; &lt;br /&gt;
sudo apt-get update&lt;br /&gt;
&lt;br /&gt;
sudo apt-get install openssh-server&lt;br /&gt;
&lt;br /&gt;
sudo ufw allow 22&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Set up static IP&lt;br /&gt;
&lt;br /&gt;
run this command &amp;lt;code&amp;gt; nano /etc/network/interfaces &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you set a static IP for primary network as screenshot:&lt;br /&gt;
&lt;br /&gt;
[[File:Static-ip-elk-master.PNG]]&lt;br /&gt;
&lt;br /&gt;
- Now go to &amp;lt;code&amp;gt;nano /etc/hosts &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add IP addresses of elk-master and elk-client as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
192.168.2.105 elk-master&lt;br /&gt;
192.168.2.106 elk-client&lt;br /&gt;
&amp;lt;/pre&amp;gt;[[File:Elk-master-hostd.PNG]]&lt;br /&gt;
&lt;br /&gt;
== Step 1 - Install Java ==&lt;br /&gt;
&lt;br /&gt;
Java is required for the Elastic stack deployment. Elasticsearch requires Java 8. It is recommended to use the Oracle JDK 1.8. We will install Java 8 from a PPA repository.&lt;br /&gt;
&lt;br /&gt;
Install the new package &#039;&#039;&#039;&#039;python-software-properties&#039;&#039;&#039;&#039; so we can add a new repository easily with an apt command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y python-software-properties software-properties-common apt-transport-https&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the new Java 8 PPA repository with the &#039;add-apt-repository&#039; command, then update the repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo add-apt-repository ppa:webupd8team/java -y &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install Java 8 from the PPA webpub8 repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y oracle-java8-installer&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 2 - Install and Configure Elasticsearch ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Elasticsearch. Install Elasticsearch from the elastic repository and configure it to run on the localhost IP.&lt;br /&gt;
&lt;br /&gt;
Before installing Elasticsearch, add the elastic repository key to the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add - &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add elastic 5.x repository to the &#039;sources.list.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; echo &amp;quot;deb https://artifacts.elastic.co/packages/5.x/apt stable main&amp;quot; | sudo tee -a /etc/apt/sources.list.d/elastic-5.x.list &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Update the repository and install Elasticsearch 5.1 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Elasticsearch is installed. Now go to the configuration directory and edit the elasticsaerch.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; cd /etc/elasticsearch/ &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano elasticsearch.yml &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enable memory lock for Elasticsearch by removing the comment on line 43. We do this to disable swapping memory for Elasticsearchto avoid overloading the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; bootstrap.memory_lock: true &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the &#039;Network&#039; block, uncomment the network.host and http.port lines.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;network.host: localhost&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;http.port: 9200&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Now edit the elasticsearch service file for the memory lock mlockall configuration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /usr/lib/systemd/system/elasticsearch.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment LimitMEMLOCK line.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;LimitMEMLOCK=infinity&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit.&lt;br /&gt;
&lt;br /&gt;
Edit the default configuration for Elasticsearch in the /etc/default directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano /etc/default/elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment line 60 and make sure the value is &#039;unlimited&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;MAX_LOCKED_MEMORY=unlimited&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
The Elasticsearch configuration is finished. Elasticsearch will run under localhost IP address with port 9200 and we disabled swap memory by enabling mlockall on the Ubuntu server.&lt;br /&gt;
&lt;br /&gt;
Reload the Elasticsearch service file and enable it to run on the boot time, then start the service.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl daemon-reload&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable elasticsearch&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start elasticsearch&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Wait a sec for Elasticsearch to run, then check the open port on the server, make sure the &#039;state&#039; for port 9200 is &#039;LISTEN&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;netstat -plntu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then check the memory lock to ensure that mlockall is enabled. Also check that Elasticsearch is running with the commands below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
curl -XGET &#039;localhost:9200/_nodes?filter_path=**.mlockall&amp;amp;pretty&#039;&lt;br /&gt;
&lt;br /&gt;
curl -XGET &#039;localhost:9200/?pretty&#039;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see the results below.&lt;br /&gt;
&lt;br /&gt;
== Step 3 - Install and Configure Kibana with Nginx ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Kibana behind a Nginx web server. Kibana will listen on the localhost IP address only and Nginx acts as the reverse proxy for the Kibana application.&lt;br /&gt;
&lt;br /&gt;
Install Kibana with this apt command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y kibana&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the kibana.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /etc/kibana/kibana.yml&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment the server.port, server.hos and elasticsearch.url lines.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
server.port: 5601&lt;br /&gt;
&lt;br /&gt;
server.host: &amp;quot;localhost&amp;quot;&lt;br /&gt;
&lt;br /&gt;
elasticsearch.url: &amp;quot;http://localhost:9200&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Add Kibana to run at boot and start it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl enable kibana&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start kibana&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana will run on port 5601 as node application.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
netstat -plntu&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana installation is done, now we need to install Nginx and configure it as a reverse proxy to be able to access Kibana from the public IP address.&lt;br /&gt;
&lt;br /&gt;
Next, install the Nginx and apache2-utils packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo apt-get install -y nginx apache2-utils&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Apache2-utils is a package that contains tools for the webserver that work with Nginx as well, we will use htpasswd basic authentication for Kibana.&lt;br /&gt;
&lt;br /&gt;
Nginx has been installed. Now we need to create a new virtual host configuration file in the Nginx sites-available directory. Create a new file &#039;kibana&#039; with nano.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/nginx/&lt;br /&gt;
vim sites-available/kibana&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
    listen 80;&lt;br /&gt;
 &lt;br /&gt;
    server_name elk-stack.co;&lt;br /&gt;
 &lt;br /&gt;
    auth_basic &amp;quot;Restricted Access&amp;quot;;&lt;br /&gt;
    auth_basic_user_file /etc/nginx/.kibana-user;&lt;br /&gt;
 &lt;br /&gt;
    location / {&lt;br /&gt;
        proxy_pass http://localhost:5601;&lt;br /&gt;
        proxy_http_version 1.1;&lt;br /&gt;
        proxy_set_header Upgrade $http_upgrade;&lt;br /&gt;
        proxy_set_header Connection &#039;upgrade&#039;;&lt;br /&gt;
        proxy_set_header Host $host;&lt;br /&gt;
        proxy_cache_bypass $http_upgrade;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano&lt;br /&gt;
&lt;br /&gt;
Create a new basic authentication file with the htpasswd command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo htpasswd -c /etc/nginx/.kibana-user admin&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
TYPE YOUR PASSWORD&lt;br /&gt;
&lt;br /&gt;
Activate the kibana virtual host by creating a symbolic link from the kibana file in &#039;sites-available&#039; to the &#039;sites-enabled&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ln -s /etc/nginx/sites-available/kibana /etc/nginx/sites-enabled/ &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Test the nginx configuration and make sure there is no error, then add nginx to run at boot time and restart nginx.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
nginx -t&lt;br /&gt;
&lt;br /&gt;
systemctl enable nginx&lt;br /&gt;
&lt;br /&gt;
systemctl restart nginx&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Step 4 - Install and Configure Logstash == &lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Logsatash to centralize server logs from client sources with filebeat, then filter and transform all data (Syslog) and transport it to the stash (Elasticsearch).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install Logstash 5 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y logstash&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Edit the hosts file with nano.&lt;br /&gt;
&lt;br /&gt;
nano /etc/hosts&lt;br /&gt;
&lt;br /&gt;
Add the server IP address and hostname.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;10.0.2.15    elk-master&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the hosts file and exit the editor.&lt;br /&gt;
&lt;br /&gt;
Now generate a new SSL certificate file with OpenSSL so the client sources can identify the elastic server.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/logstash/&lt;br /&gt;
&lt;br /&gt;
openssl req -subj /CN=elk-master -x509 -days 3650 -batch -nodes -newkey rsa:4096 -keyout logstash.key -out logstash.crt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change the &#039;/CN&#039; value to the elastic server hostname.&lt;br /&gt;
&lt;br /&gt;
Certificate files will be created in the &#039;/etc/logstash/&#039; directory.&lt;br /&gt;
&lt;br /&gt;
Next, we will create the configuration files for logstash. We will create a configuration file &#039;filebeat-input.conf&#039; as input file from filebeat, &#039;syslog-filter.conf&#039; for syslog processing, and then a &#039;output-elasticsearch.conf&#039; file to define the Elasticsearch output.&lt;br /&gt;
&lt;br /&gt;
Go to the logstash configuration directory and create the new configuration files in the &#039;conf.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/logstash/&lt;br /&gt;
&lt;br /&gt;
nano conf.d/filebeat-input.conf&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Input configuration, paste configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input {&lt;br /&gt;
  beats {&lt;br /&gt;
    port =&amp;gt; 5443&lt;br /&gt;
    type =&amp;gt; syslog&lt;br /&gt;
    ssl =&amp;gt; true&lt;br /&gt;
    ssl_certificate =&amp;gt; &amp;quot;/etc/logstash/logstash.crt&amp;quot;&lt;br /&gt;
    ssl_key =&amp;gt; &amp;quot;/etc/logstash/logstash.key&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Create the syslog-filter.conf file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano conf.d/syslog-filter.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
filter {&lt;br /&gt;
  if [type] == &amp;quot;syslog&amp;quot; {&lt;br /&gt;
    grok {&lt;br /&gt;
      match =&amp;gt; { &amp;quot;message&amp;quot; =&amp;gt; &amp;quot;%{SYSLOGTIMESTAMP:syslog_timestamp} %{SYSLOGHOST:syslog_hostname} %{DATA:syslog_program}(?:\[%{POSINT:syslog_pid}\])?: %{GREEDYDATA:syslog_message}&amp;quot; }&lt;br /&gt;
      add_field =&amp;gt; [ &amp;quot;received_at&amp;quot;, &amp;quot;%{@timestamp}&amp;quot; ]&lt;br /&gt;
      add_field =&amp;gt; [ &amp;quot;received_from&amp;quot;, &amp;quot;%{host}&amp;quot; ]&lt;br /&gt;
    }&lt;br /&gt;
    date {&lt;br /&gt;
      match =&amp;gt; [ &amp;quot;syslog_timestamp&amp;quot;, &amp;quot;MMM  d HH:mm:ss&amp;quot;, &amp;quot;MMM dd HH:mm:ss&amp;quot; ]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We use a filter plugin named &#039;grok&#039; to parse the syslog files.&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Create the output configuration file &#039;output-elasticsearch.conf&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano conf.d/output-elasticsearch.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
output {&lt;br /&gt;
  elasticsearch { hosts =&amp;gt; [&amp;quot;localhost:9200&amp;quot;]&lt;br /&gt;
    hosts =&amp;gt; &amp;quot;localhost:9200&amp;quot;&lt;br /&gt;
    manage_template =&amp;gt; false&lt;br /&gt;
    index =&amp;gt; &amp;quot;%{[@metadata][beat]}-%{+YYYY.MM.dd}&amp;quot;&lt;br /&gt;
    document_type =&amp;gt; &amp;quot;%{[@metadata][type]}&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
When this is done, add logstash to start at boot time and start the service.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable logstash&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start logstash&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mdhasan</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123805</id>
		<title>Logging and monitoring with Elastic stack on Ubuntu 16.04</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123805"/>
		<updated>2017-06-21T20:08:12Z</updated>

		<summary type="html">&lt;p&gt;Mdhasan: /* Virtual Box setup */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
Logging and monitoring of IT systems is very important part of information security. Proper system logs and monitoring can prevent cyber attacks or service failure. In this wiki we will learn how configure logging and monitoring with ELK stack in Ubuntu server 16.04, what is alternatives (Graylog) of ELK stack and disadvantages of ELK stack.      &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Elasticsearch&#039;&#039;&#039; is an open source search engine based on Lucene, developed in java. It provides a distributed and multitenant [https://en.wikipedia.org/wiki/Full-text_search full-text search engine] with an HTTP Dashboard web-interface (Kibana) and JSON documents scheme. Elasticsearch is a scalable search engine that can be used to search for all types of documents, including log file. Elasticsearch is the heart of the &#039;Elastic Stack&#039; or ELK Stack.&amp;lt;ref&amp;gt;[https://www.elastic.co/products/elasticsearch] Elastic Search Homepage&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Logstash&#039;&#039;&#039; is an open source, server-side data processing pipeline that ingests data from a multitude of sources simultaneously, transforms it, and then sends it to Elasticsearch.&amp;lt;ref&amp;gt;[https://www.elastic.co/products/logstash] Logstash homepahe&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Kibana&#039;&#039;&#039; is a data visualization interface for Elasticsearch. Kibana provides a pretty dashboard (web interfaces), it allows you to manage and visualize all data from Elasticsearch on your own. &amp;lt;ref&amp;gt;[https://www.elastic.co/products/kibana] kibana homepage&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Prerequisite ==&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit server with 4GB of RAM, hostname - elk-master&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit client with 1 GB of RAM, hostname - elk-client&lt;br /&gt;
&lt;br /&gt;
Following installation steps from 1 to 4 is collected from &lt;br /&gt;
&lt;br /&gt;
[http://www.howtoforge.com HowToFroge.com]&amp;lt;ref&amp;gt;[http://thehackernews.com/2013/10/importance-of-logs-and-log-management.html]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Virtual Box setup ==&lt;br /&gt;
&lt;br /&gt;
As we are going to use Ubuntu server 16.04, which has no Graphical user interface (GUI). It is better to add a GUI client to Ubuntu server and ssh to virtual box setup. Here I will show to how to connect to Ubuntu server from a Ubuntu desktop client via SSH in Virtual box. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Step 1 - Virtual box Networking&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
- Select the Virtual machine Ubuntu server 16.04&lt;br /&gt;
- go to settings &amp;gt; network&lt;br /&gt;
- set Adapter 1 as Internal network (It is better to setup static IP for adapter 1)&lt;br /&gt;
- Also Add another network NAT (So the server will have internet access )&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Step 2 - Setup static IP in Ubuntu server (elk-master)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
- Become a root user &amp;lt;code&amp;gt; sudo -i &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Enable SSH by running following commands&amp;lt;ref&amp;gt;[https://askubuntu.com/questions/218344/why-am-i-getting-a-port-22-connection-refused-error open port 22 ]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; &lt;br /&gt;
sudo apt-get update&lt;br /&gt;
&lt;br /&gt;
sudo apt-get install openssh-server&lt;br /&gt;
&lt;br /&gt;
sudo ufw allow 22&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Set up static IP&lt;br /&gt;
&lt;br /&gt;
run this command &amp;lt;code&amp;gt; nano /etc/network/interfaces &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you set a static IP for primary network as screenshot:&lt;br /&gt;
&lt;br /&gt;
[[File:Static-ip-elk-master.PNG]]&lt;br /&gt;
&lt;br /&gt;
- Now go to &amp;lt;code&amp;gt;nano /etc/hosts &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add IP addresses of elk-master and elk-client as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
192.168.2.105 elk-master&lt;br /&gt;
192.168.2.106 elk-client&lt;br /&gt;
&amp;lt;/pre&amp;gt;[[File:Elk-master-hostd.PNG]]&lt;br /&gt;
&lt;br /&gt;
== Step 1 - Install Java ==&lt;br /&gt;
&lt;br /&gt;
Java is required for the Elastic stack deployment. Elasticsearch requires Java 8. It is recommended to use the Oracle JDK 1.8. We will install Java 8 from a PPA repository.&lt;br /&gt;
&lt;br /&gt;
Install the new package &#039;&#039;&#039;&#039;python-software-properties&#039;&#039;&#039;&#039; so we can add a new repository easily with an apt command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y python-software-properties software-properties-common apt-transport-https&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the new Java 8 PPA repository with the &#039;add-apt-repository&#039; command, then update the repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo add-apt-repository ppa:webupd8team/java -y &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install Java 8 from the PPA webpub8 repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y oracle-java8-installer&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 2 - Install and Configure Elasticsearch ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Elasticsearch. Install Elasticsearch from the elastic repository and configure it to run on the localhost IP.&lt;br /&gt;
&lt;br /&gt;
Before installing Elasticsearch, add the elastic repository key to the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add - &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add elastic 5.x repository to the &#039;sources.list.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; echo &amp;quot;deb https://artifacts.elastic.co/packages/5.x/apt stable main&amp;quot; | sudo tee -a /etc/apt/sources.list.d/elastic-5.x.list &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Update the repository and install Elasticsearch 5.1 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Elasticsearch is installed. Now go to the configuration directory and edit the elasticsaerch.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; cd /etc/elasticsearch/ &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano elasticsearch.yml &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enable memory lock for Elasticsearch by removing the comment on line 43. We do this to disable swapping memory for Elasticsearchto avoid overloading the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; bootstrap.memory_lock: true &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the &#039;Network&#039; block, uncomment the network.host and http.port lines.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;network.host: localhost&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;http.port: 9200&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Now edit the elasticsearch service file for the memory lock mlockall configuration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /usr/lib/systemd/system/elasticsearch.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment LimitMEMLOCK line.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;LimitMEMLOCK=infinity&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit.&lt;br /&gt;
&lt;br /&gt;
Edit the default configuration for Elasticsearch in the /etc/default directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano /etc/default/elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment line 60 and make sure the value is &#039;unlimited&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;MAX_LOCKED_MEMORY=unlimited&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
The Elasticsearch configuration is finished. Elasticsearch will run under localhost IP address with port 9200 and we disabled swap memory by enabling mlockall on the Ubuntu server.&lt;br /&gt;
&lt;br /&gt;
Reload the Elasticsearch service file and enable it to run on the boot time, then start the service.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl daemon-reload&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable elasticsearch&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start elasticsearch&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Wait a sec for Elasticsearch to run, then check the open port on the server, make sure the &#039;state&#039; for port 9200 is &#039;LISTEN&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;netstat -plntu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then check the memory lock to ensure that mlockall is enabled. Also check that Elasticsearch is running with the commands below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
curl -XGET &#039;localhost:9200/_nodes?filter_path=**.mlockall&amp;amp;pretty&#039;&lt;br /&gt;
&lt;br /&gt;
curl -XGET &#039;localhost:9200/?pretty&#039;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see the results below.&lt;br /&gt;
&lt;br /&gt;
== Step 3 - Install and Configure Kibana with Nginx ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Kibana behind a Nginx web server. Kibana will listen on the localhost IP address only and Nginx acts as the reverse proxy for the Kibana application.&lt;br /&gt;
&lt;br /&gt;
Install Kibana with this apt command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y kibana&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the kibana.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /etc/kibana/kibana.yml&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment the server.port, server.hos and elasticsearch.url lines.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
server.port: 5601&lt;br /&gt;
&lt;br /&gt;
server.host: &amp;quot;localhost&amp;quot;&lt;br /&gt;
&lt;br /&gt;
elasticsearch.url: &amp;quot;http://localhost:9200&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Add Kibana to run at boot and start it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl enable kibana&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start kibana&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana will run on port 5601 as node application.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
netstat -plntu&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana installation is done, now we need to install Nginx and configure it as a reverse proxy to be able to access Kibana from the public IP address.&lt;br /&gt;
&lt;br /&gt;
Next, install the Nginx and apache2-utils packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo apt-get install -y nginx apache2-utils&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Apache2-utils is a package that contains tools for the webserver that work with Nginx as well, we will use htpasswd basic authentication for Kibana.&lt;br /&gt;
&lt;br /&gt;
Nginx has been installed. Now we need to create a new virtual host configuration file in the Nginx sites-available directory. Create a new file &#039;kibana&#039; with nano.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/nginx/&lt;br /&gt;
vim sites-available/kibana&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
    listen 80;&lt;br /&gt;
 &lt;br /&gt;
    server_name elk-stack.co;&lt;br /&gt;
 &lt;br /&gt;
    auth_basic &amp;quot;Restricted Access&amp;quot;;&lt;br /&gt;
    auth_basic_user_file /etc/nginx/.kibana-user;&lt;br /&gt;
 &lt;br /&gt;
    location / {&lt;br /&gt;
        proxy_pass http://localhost:5601;&lt;br /&gt;
        proxy_http_version 1.1;&lt;br /&gt;
        proxy_set_header Upgrade $http_upgrade;&lt;br /&gt;
        proxy_set_header Connection &#039;upgrade&#039;;&lt;br /&gt;
        proxy_set_header Host $host;&lt;br /&gt;
        proxy_cache_bypass $http_upgrade;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano&lt;br /&gt;
&lt;br /&gt;
Create a new basic authentication file with the htpasswd command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo htpasswd -c /etc/nginx/.kibana-user admin&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
TYPE YOUR PASSWORD&lt;br /&gt;
&lt;br /&gt;
Activate the kibana virtual host by creating a symbolic link from the kibana file in &#039;sites-available&#039; to the &#039;sites-enabled&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ln -s /etc/nginx/sites-available/kibana /etc/nginx/sites-enabled/ &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Test the nginx configuration and make sure there is no error, then add nginx to run at boot time and restart nginx.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
nginx -t&lt;br /&gt;
&lt;br /&gt;
systemctl enable nginx&lt;br /&gt;
&lt;br /&gt;
systemctl restart nginx&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Step 4 - Install and Configure Logstash == &lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Logsatash to centralize server logs from client sources with filebeat, then filter and transform all data (Syslog) and transport it to the stash (Elasticsearch).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install Logstash 5 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y logstash&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Edit the hosts file with nano.&lt;br /&gt;
&lt;br /&gt;
nano /etc/hosts&lt;br /&gt;
&lt;br /&gt;
Add the server IP address and hostname.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;10.0.2.15    elk-master&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the hosts file and exit the editor.&lt;br /&gt;
&lt;br /&gt;
Now generate a new SSL certificate file with OpenSSL so the client sources can identify the elastic server.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/logstash/&lt;br /&gt;
&lt;br /&gt;
openssl req -subj /CN=elk-master -x509 -days 3650 -batch -nodes -newkey rsa:4096 -keyout logstash.key -out logstash.crt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change the &#039;/CN&#039; value to the elastic server hostname.&lt;br /&gt;
&lt;br /&gt;
Certificate files will be created in the &#039;/etc/logstash/&#039; directory.&lt;br /&gt;
&lt;br /&gt;
Next, we will create the configuration files for logstash. We will create a configuration file &#039;filebeat-input.conf&#039; as input file from filebeat, &#039;syslog-filter.conf&#039; for syslog processing, and then a &#039;output-elasticsearch.conf&#039; file to define the Elasticsearch output.&lt;br /&gt;
&lt;br /&gt;
Go to the logstash configuration directory and create the new configuration files in the &#039;conf.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/logstash/&lt;br /&gt;
&lt;br /&gt;
nano conf.d/filebeat-input.conf&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Input configuration, paste configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input {&lt;br /&gt;
  beats {&lt;br /&gt;
    port =&amp;gt; 5443&lt;br /&gt;
    type =&amp;gt; syslog&lt;br /&gt;
    ssl =&amp;gt; true&lt;br /&gt;
    ssl_certificate =&amp;gt; &amp;quot;/etc/logstash/logstash.crt&amp;quot;&lt;br /&gt;
    ssl_key =&amp;gt; &amp;quot;/etc/logstash/logstash.key&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Create the syslog-filter.conf file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano conf.d/syslog-filter.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
filter {&lt;br /&gt;
  if [type] == &amp;quot;syslog&amp;quot; {&lt;br /&gt;
    grok {&lt;br /&gt;
      match =&amp;gt; { &amp;quot;message&amp;quot; =&amp;gt; &amp;quot;%{SYSLOGTIMESTAMP:syslog_timestamp} %{SYSLOGHOST:syslog_hostname} %{DATA:syslog_program}(?:\[%{POSINT:syslog_pid}\])?: %{GREEDYDATA:syslog_message}&amp;quot; }&lt;br /&gt;
      add_field =&amp;gt; [ &amp;quot;received_at&amp;quot;, &amp;quot;%{@timestamp}&amp;quot; ]&lt;br /&gt;
      add_field =&amp;gt; [ &amp;quot;received_from&amp;quot;, &amp;quot;%{host}&amp;quot; ]&lt;br /&gt;
    }&lt;br /&gt;
    date {&lt;br /&gt;
      match =&amp;gt; [ &amp;quot;syslog_timestamp&amp;quot;, &amp;quot;MMM  d HH:mm:ss&amp;quot;, &amp;quot;MMM dd HH:mm:ss&amp;quot; ]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We use a filter plugin named &#039;grok&#039; to parse the syslog files.&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Create the output configuration file &#039;output-elasticsearch.conf&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano conf.d/output-elasticsearch.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
output {&lt;br /&gt;
  elasticsearch { hosts =&amp;gt; [&amp;quot;localhost:9200&amp;quot;]&lt;br /&gt;
    hosts =&amp;gt; &amp;quot;localhost:9200&amp;quot;&lt;br /&gt;
    manage_template =&amp;gt; false&lt;br /&gt;
    index =&amp;gt; &amp;quot;%{[@metadata][beat]}-%{+YYYY.MM.dd}&amp;quot;&lt;br /&gt;
    document_type =&amp;gt; &amp;quot;%{[@metadata][type]}&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
When this is done, add logstash to start at boot time and start the service.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable logstash&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start logstash&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mdhasan</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123804</id>
		<title>Logging and monitoring with Elastic stack on Ubuntu 16.04</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123804"/>
		<updated>2017-06-21T20:07:21Z</updated>

		<summary type="html">&lt;p&gt;Mdhasan: /* Virtual Box setup */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
Logging and monitoring of IT systems is very important part of information security. Proper system logs and monitoring can prevent cyber attacks or service failure. In this wiki we will learn how configure logging and monitoring with ELK stack in Ubuntu server 16.04, what is alternatives (Graylog) of ELK stack and disadvantages of ELK stack.      &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Elasticsearch&#039;&#039;&#039; is an open source search engine based on Lucene, developed in java. It provides a distributed and multitenant [https://en.wikipedia.org/wiki/Full-text_search full-text search engine] with an HTTP Dashboard web-interface (Kibana) and JSON documents scheme. Elasticsearch is a scalable search engine that can be used to search for all types of documents, including log file. Elasticsearch is the heart of the &#039;Elastic Stack&#039; or ELK Stack.&amp;lt;ref&amp;gt;[https://www.elastic.co/products/elasticsearch] Elastic Search Homepage&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Logstash&#039;&#039;&#039; is an open source, server-side data processing pipeline that ingests data from a multitude of sources simultaneously, transforms it, and then sends it to Elasticsearch.&amp;lt;ref&amp;gt;[https://www.elastic.co/products/logstash] Logstash homepahe&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Kibana&#039;&#039;&#039; is a data visualization interface for Elasticsearch. Kibana provides a pretty dashboard (web interfaces), it allows you to manage and visualize all data from Elasticsearch on your own. &amp;lt;ref&amp;gt;[https://www.elastic.co/products/kibana] kibana homepage&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Prerequisite ==&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit server with 4GB of RAM, hostname - elk-master&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit client with 1 GB of RAM, hostname - elk-client&lt;br /&gt;
&lt;br /&gt;
Following installation steps from 1 to 4 is collected from &lt;br /&gt;
&lt;br /&gt;
[http://www.howtoforge.com HowToFroge.com]&amp;lt;ref&amp;gt;[http://thehackernews.com/2013/10/importance-of-logs-and-log-management.html]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Virtual Box setup ==&lt;br /&gt;
&lt;br /&gt;
As we are going to use Ubuntu server 16.04, which has no Graphical user interface (GUI). It is better to add a GUI client to Ubuntu server and ssh to virtual box setup. Here I will show to how to connect to Ubuntu server from a Ubuntu desktop client via SSH in Virtual box. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Step 1 - Virtual box Networking&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
- Select the Virtual machine Ubuntu server 16.04&lt;br /&gt;
- go to settings &amp;gt; network&lt;br /&gt;
- set Adapter 1 as Internal network (It is better to setup static IP for adapter 1)&lt;br /&gt;
- Also Add another network NAT (So the server will have internet access )&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Step 2 - Setup static IP in Ubuntu server (elk-master)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
- Become a root user &amp;lt;code&amp;gt; sudo -i &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Enable SSH by running following commands&amp;lt;ref&amp;gt;[https://askubuntu.com/questions/218344/why-am-i-getting-a-port-22-connection-refused-error open port 22 ]&amp;lt;/ref&amp;gt;&lt;br /&gt;
192&lt;br /&gt;
&amp;lt;code&amp;gt; &lt;br /&gt;
sudo apt-get update&lt;br /&gt;
&lt;br /&gt;
sudo apt-get install openssh-server&lt;br /&gt;
&lt;br /&gt;
sudo ufw allow 22&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Set up static IP&lt;br /&gt;
&lt;br /&gt;
run this command &amp;lt;code&amp;gt; nano /etc/network/interfaces &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you set a static IP for primary network as screenshot:&lt;br /&gt;
&lt;br /&gt;
[[File:Static-ip-elk-master.PNG]]&lt;br /&gt;
&lt;br /&gt;
- Now go to &amp;lt;code&amp;gt;nano /etc/hosts &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add IP addresses of elk-master and elk-client as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
192.168.2.105 elk-master&lt;br /&gt;
192.168.2.106 elk-client&lt;br /&gt;
&amp;lt;/pre&amp;gt;[[File:Elk-master-hostd.PNG]]&lt;br /&gt;
&lt;br /&gt;
== Step 1 - Install Java ==&lt;br /&gt;
&lt;br /&gt;
Java is required for the Elastic stack deployment. Elasticsearch requires Java 8. It is recommended to use the Oracle JDK 1.8. We will install Java 8 from a PPA repository.&lt;br /&gt;
&lt;br /&gt;
Install the new package &#039;&#039;&#039;&#039;python-software-properties&#039;&#039;&#039;&#039; so we can add a new repository easily with an apt command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y python-software-properties software-properties-common apt-transport-https&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the new Java 8 PPA repository with the &#039;add-apt-repository&#039; command, then update the repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo add-apt-repository ppa:webupd8team/java -y &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install Java 8 from the PPA webpub8 repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y oracle-java8-installer&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 2 - Install and Configure Elasticsearch ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Elasticsearch. Install Elasticsearch from the elastic repository and configure it to run on the localhost IP.&lt;br /&gt;
&lt;br /&gt;
Before installing Elasticsearch, add the elastic repository key to the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add - &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add elastic 5.x repository to the &#039;sources.list.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; echo &amp;quot;deb https://artifacts.elastic.co/packages/5.x/apt stable main&amp;quot; | sudo tee -a /etc/apt/sources.list.d/elastic-5.x.list &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Update the repository and install Elasticsearch 5.1 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Elasticsearch is installed. Now go to the configuration directory and edit the elasticsaerch.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; cd /etc/elasticsearch/ &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano elasticsearch.yml &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enable memory lock for Elasticsearch by removing the comment on line 43. We do this to disable swapping memory for Elasticsearchto avoid overloading the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; bootstrap.memory_lock: true &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the &#039;Network&#039; block, uncomment the network.host and http.port lines.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;network.host: localhost&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;http.port: 9200&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Now edit the elasticsearch service file for the memory lock mlockall configuration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /usr/lib/systemd/system/elasticsearch.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment LimitMEMLOCK line.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;LimitMEMLOCK=infinity&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit.&lt;br /&gt;
&lt;br /&gt;
Edit the default configuration for Elasticsearch in the /etc/default directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano /etc/default/elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment line 60 and make sure the value is &#039;unlimited&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;MAX_LOCKED_MEMORY=unlimited&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
The Elasticsearch configuration is finished. Elasticsearch will run under localhost IP address with port 9200 and we disabled swap memory by enabling mlockall on the Ubuntu server.&lt;br /&gt;
&lt;br /&gt;
Reload the Elasticsearch service file and enable it to run on the boot time, then start the service.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl daemon-reload&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable elasticsearch&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start elasticsearch&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Wait a sec for Elasticsearch to run, then check the open port on the server, make sure the &#039;state&#039; for port 9200 is &#039;LISTEN&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;netstat -plntu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then check the memory lock to ensure that mlockall is enabled. Also check that Elasticsearch is running with the commands below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
curl -XGET &#039;localhost:9200/_nodes?filter_path=**.mlockall&amp;amp;pretty&#039;&lt;br /&gt;
&lt;br /&gt;
curl -XGET &#039;localhost:9200/?pretty&#039;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see the results below.&lt;br /&gt;
&lt;br /&gt;
== Step 3 - Install and Configure Kibana with Nginx ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Kibana behind a Nginx web server. Kibana will listen on the localhost IP address only and Nginx acts as the reverse proxy for the Kibana application.&lt;br /&gt;
&lt;br /&gt;
Install Kibana with this apt command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y kibana&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the kibana.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /etc/kibana/kibana.yml&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment the server.port, server.hos and elasticsearch.url lines.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
server.port: 5601&lt;br /&gt;
&lt;br /&gt;
server.host: &amp;quot;localhost&amp;quot;&lt;br /&gt;
&lt;br /&gt;
elasticsearch.url: &amp;quot;http://localhost:9200&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Add Kibana to run at boot and start it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl enable kibana&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start kibana&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana will run on port 5601 as node application.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
netstat -plntu&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana installation is done, now we need to install Nginx and configure it as a reverse proxy to be able to access Kibana from the public IP address.&lt;br /&gt;
&lt;br /&gt;
Next, install the Nginx and apache2-utils packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo apt-get install -y nginx apache2-utils&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Apache2-utils is a package that contains tools for the webserver that work with Nginx as well, we will use htpasswd basic authentication for Kibana.&lt;br /&gt;
&lt;br /&gt;
Nginx has been installed. Now we need to create a new virtual host configuration file in the Nginx sites-available directory. Create a new file &#039;kibana&#039; with nano.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/nginx/&lt;br /&gt;
vim sites-available/kibana&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
    listen 80;&lt;br /&gt;
 &lt;br /&gt;
    server_name elk-stack.co;&lt;br /&gt;
 &lt;br /&gt;
    auth_basic &amp;quot;Restricted Access&amp;quot;;&lt;br /&gt;
    auth_basic_user_file /etc/nginx/.kibana-user;&lt;br /&gt;
 &lt;br /&gt;
    location / {&lt;br /&gt;
        proxy_pass http://localhost:5601;&lt;br /&gt;
        proxy_http_version 1.1;&lt;br /&gt;
        proxy_set_header Upgrade $http_upgrade;&lt;br /&gt;
        proxy_set_header Connection &#039;upgrade&#039;;&lt;br /&gt;
        proxy_set_header Host $host;&lt;br /&gt;
        proxy_cache_bypass $http_upgrade;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano&lt;br /&gt;
&lt;br /&gt;
Create a new basic authentication file with the htpasswd command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo htpasswd -c /etc/nginx/.kibana-user admin&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
TYPE YOUR PASSWORD&lt;br /&gt;
&lt;br /&gt;
Activate the kibana virtual host by creating a symbolic link from the kibana file in &#039;sites-available&#039; to the &#039;sites-enabled&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ln -s /etc/nginx/sites-available/kibana /etc/nginx/sites-enabled/ &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Test the nginx configuration and make sure there is no error, then add nginx to run at boot time and restart nginx.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
nginx -t&lt;br /&gt;
&lt;br /&gt;
systemctl enable nginx&lt;br /&gt;
&lt;br /&gt;
systemctl restart nginx&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Step 4 - Install and Configure Logstash == &lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Logsatash to centralize server logs from client sources with filebeat, then filter and transform all data (Syslog) and transport it to the stash (Elasticsearch).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install Logstash 5 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y logstash&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Edit the hosts file with nano.&lt;br /&gt;
&lt;br /&gt;
nano /etc/hosts&lt;br /&gt;
&lt;br /&gt;
Add the server IP address and hostname.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;10.0.2.15    elk-master&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the hosts file and exit the editor.&lt;br /&gt;
&lt;br /&gt;
Now generate a new SSL certificate file with OpenSSL so the client sources can identify the elastic server.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/logstash/&lt;br /&gt;
&lt;br /&gt;
openssl req -subj /CN=elk-master -x509 -days 3650 -batch -nodes -newkey rsa:4096 -keyout logstash.key -out logstash.crt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change the &#039;/CN&#039; value to the elastic server hostname.&lt;br /&gt;
&lt;br /&gt;
Certificate files will be created in the &#039;/etc/logstash/&#039; directory.&lt;br /&gt;
&lt;br /&gt;
Next, we will create the configuration files for logstash. We will create a configuration file &#039;filebeat-input.conf&#039; as input file from filebeat, &#039;syslog-filter.conf&#039; for syslog processing, and then a &#039;output-elasticsearch.conf&#039; file to define the Elasticsearch output.&lt;br /&gt;
&lt;br /&gt;
Go to the logstash configuration directory and create the new configuration files in the &#039;conf.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/logstash/&lt;br /&gt;
&lt;br /&gt;
nano conf.d/filebeat-input.conf&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Input configuration, paste configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input {&lt;br /&gt;
  beats {&lt;br /&gt;
    port =&amp;gt; 5443&lt;br /&gt;
    type =&amp;gt; syslog&lt;br /&gt;
    ssl =&amp;gt; true&lt;br /&gt;
    ssl_certificate =&amp;gt; &amp;quot;/etc/logstash/logstash.crt&amp;quot;&lt;br /&gt;
    ssl_key =&amp;gt; &amp;quot;/etc/logstash/logstash.key&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Create the syslog-filter.conf file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano conf.d/syslog-filter.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
filter {&lt;br /&gt;
  if [type] == &amp;quot;syslog&amp;quot; {&lt;br /&gt;
    grok {&lt;br /&gt;
      match =&amp;gt; { &amp;quot;message&amp;quot; =&amp;gt; &amp;quot;%{SYSLOGTIMESTAMP:syslog_timestamp} %{SYSLOGHOST:syslog_hostname} %{DATA:syslog_program}(?:\[%{POSINT:syslog_pid}\])?: %{GREEDYDATA:syslog_message}&amp;quot; }&lt;br /&gt;
      add_field =&amp;gt; [ &amp;quot;received_at&amp;quot;, &amp;quot;%{@timestamp}&amp;quot; ]&lt;br /&gt;
      add_field =&amp;gt; [ &amp;quot;received_from&amp;quot;, &amp;quot;%{host}&amp;quot; ]&lt;br /&gt;
    }&lt;br /&gt;
    date {&lt;br /&gt;
      match =&amp;gt; [ &amp;quot;syslog_timestamp&amp;quot;, &amp;quot;MMM  d HH:mm:ss&amp;quot;, &amp;quot;MMM dd HH:mm:ss&amp;quot; ]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We use a filter plugin named &#039;grok&#039; to parse the syslog files.&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Create the output configuration file &#039;output-elasticsearch.conf&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano conf.d/output-elasticsearch.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
output {&lt;br /&gt;
  elasticsearch { hosts =&amp;gt; [&amp;quot;localhost:9200&amp;quot;]&lt;br /&gt;
    hosts =&amp;gt; &amp;quot;localhost:9200&amp;quot;&lt;br /&gt;
    manage_template =&amp;gt; false&lt;br /&gt;
    index =&amp;gt; &amp;quot;%{[@metadata][beat]}-%{+YYYY.MM.dd}&amp;quot;&lt;br /&gt;
    document_type =&amp;gt; &amp;quot;%{[@metadata][type]}&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
When this is done, add logstash to start at boot time and start the service.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable logstash&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start logstash&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mdhasan</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=File:Elk-master-hostd.PNG&amp;diff=123803</id>
		<title>File:Elk-master-hostd.PNG</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=File:Elk-master-hostd.PNG&amp;diff=123803"/>
		<updated>2017-06-21T20:07:07Z</updated>

		<summary type="html">&lt;p&gt;Mdhasan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Mdhasan</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123802</id>
		<title>Logging and monitoring with Elastic stack on Ubuntu 16.04</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123802"/>
		<updated>2017-06-21T20:06:31Z</updated>

		<summary type="html">&lt;p&gt;Mdhasan: /* Virtual Box setup */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
Logging and monitoring of IT systems is very important part of information security. Proper system logs and monitoring can prevent cyber attacks or service failure. In this wiki we will learn how configure logging and monitoring with ELK stack in Ubuntu server 16.04, what is alternatives (Graylog) of ELK stack and disadvantages of ELK stack.      &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Elasticsearch&#039;&#039;&#039; is an open source search engine based on Lucene, developed in java. It provides a distributed and multitenant [https://en.wikipedia.org/wiki/Full-text_search full-text search engine] with an HTTP Dashboard web-interface (Kibana) and JSON documents scheme. Elasticsearch is a scalable search engine that can be used to search for all types of documents, including log file. Elasticsearch is the heart of the &#039;Elastic Stack&#039; or ELK Stack.&amp;lt;ref&amp;gt;[https://www.elastic.co/products/elasticsearch] Elastic Search Homepage&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Logstash&#039;&#039;&#039; is an open source, server-side data processing pipeline that ingests data from a multitude of sources simultaneously, transforms it, and then sends it to Elasticsearch.&amp;lt;ref&amp;gt;[https://www.elastic.co/products/logstash] Logstash homepahe&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Kibana&#039;&#039;&#039; is a data visualization interface for Elasticsearch. Kibana provides a pretty dashboard (web interfaces), it allows you to manage and visualize all data from Elasticsearch on your own. &amp;lt;ref&amp;gt;[https://www.elastic.co/products/kibana] kibana homepage&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Prerequisite ==&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit server with 4GB of RAM, hostname - elk-master&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit client with 1 GB of RAM, hostname - elk-client&lt;br /&gt;
&lt;br /&gt;
Following installation steps from 1 to 4 is collected from &lt;br /&gt;
&lt;br /&gt;
[http://www.howtoforge.com HowToFroge.com]&amp;lt;ref&amp;gt;[http://thehackernews.com/2013/10/importance-of-logs-and-log-management.html]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Virtual Box setup ==&lt;br /&gt;
&lt;br /&gt;
As we are going to use Ubuntu server 16.04, which has no Graphical user interface (GUI). It is better to add a GUI client to Ubuntu server and ssh to virtual box setup. Here I will show to how to connect to Ubuntu server from a Ubuntu desktop client via SSH in Virtual box. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Step 1 - Virtual box Networking&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
- Select the Virtual machine Ubuntu server 16.04&lt;br /&gt;
- go to settings &amp;gt; network&lt;br /&gt;
- set Adapter 1 as Internal network (It is better to setup static IP for adapter 1)&lt;br /&gt;
- Also Add another network NAT (So the server will have internet access )&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Step 2 - Setup static IP in Ubuntu server (elk-master)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
- Become a root user &amp;lt;code&amp;gt; sudo -i &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Enable SSH by running following commands&amp;lt;ref&amp;gt;[https://askubuntu.com/questions/218344/why-am-i-getting-a-port-22-connection-refused-error open port 22 ]&amp;lt;/ref&amp;gt;&lt;br /&gt;
192&lt;br /&gt;
&amp;lt;code&amp;gt; &lt;br /&gt;
sudo apt-get update&lt;br /&gt;
&lt;br /&gt;
sudo apt-get install openssh-server&lt;br /&gt;
&lt;br /&gt;
sudo ufw allow 22&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Set up static IP&lt;br /&gt;
&lt;br /&gt;
run this command &amp;lt;code&amp;gt; nano /etc/network/interfaces &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you set a static IP for primary network as screenshot:&lt;br /&gt;
&lt;br /&gt;
[[File:Static-ip-elk-master.PNG]]&lt;br /&gt;
&lt;br /&gt;
- Now go to &amp;lt;code&amp;gt;nano /etc/hosts &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add IP addresses of elk-master and elk-client as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
192.168.2.105 elk-master&lt;br /&gt;
192.168.2.106 elk-client&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 1 - Install Java ==&lt;br /&gt;
&lt;br /&gt;
Java is required for the Elastic stack deployment. Elasticsearch requires Java 8. It is recommended to use the Oracle JDK 1.8. We will install Java 8 from a PPA repository.&lt;br /&gt;
&lt;br /&gt;
Install the new package &#039;&#039;&#039;&#039;python-software-properties&#039;&#039;&#039;&#039; so we can add a new repository easily with an apt command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y python-software-properties software-properties-common apt-transport-https&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the new Java 8 PPA repository with the &#039;add-apt-repository&#039; command, then update the repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo add-apt-repository ppa:webupd8team/java -y &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install Java 8 from the PPA webpub8 repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y oracle-java8-installer&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 2 - Install and Configure Elasticsearch ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Elasticsearch. Install Elasticsearch from the elastic repository and configure it to run on the localhost IP.&lt;br /&gt;
&lt;br /&gt;
Before installing Elasticsearch, add the elastic repository key to the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add - &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add elastic 5.x repository to the &#039;sources.list.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; echo &amp;quot;deb https://artifacts.elastic.co/packages/5.x/apt stable main&amp;quot; | sudo tee -a /etc/apt/sources.list.d/elastic-5.x.list &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Update the repository and install Elasticsearch 5.1 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Elasticsearch is installed. Now go to the configuration directory and edit the elasticsaerch.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; cd /etc/elasticsearch/ &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano elasticsearch.yml &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enable memory lock for Elasticsearch by removing the comment on line 43. We do this to disable swapping memory for Elasticsearchto avoid overloading the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; bootstrap.memory_lock: true &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the &#039;Network&#039; block, uncomment the network.host and http.port lines.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;network.host: localhost&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;http.port: 9200&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Now edit the elasticsearch service file for the memory lock mlockall configuration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /usr/lib/systemd/system/elasticsearch.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment LimitMEMLOCK line.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;LimitMEMLOCK=infinity&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit.&lt;br /&gt;
&lt;br /&gt;
Edit the default configuration for Elasticsearch in the /etc/default directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano /etc/default/elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment line 60 and make sure the value is &#039;unlimited&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;MAX_LOCKED_MEMORY=unlimited&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
The Elasticsearch configuration is finished. Elasticsearch will run under localhost IP address with port 9200 and we disabled swap memory by enabling mlockall on the Ubuntu server.&lt;br /&gt;
&lt;br /&gt;
Reload the Elasticsearch service file and enable it to run on the boot time, then start the service.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl daemon-reload&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable elasticsearch&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start elasticsearch&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Wait a sec for Elasticsearch to run, then check the open port on the server, make sure the &#039;state&#039; for port 9200 is &#039;LISTEN&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;netstat -plntu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then check the memory lock to ensure that mlockall is enabled. Also check that Elasticsearch is running with the commands below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
curl -XGET &#039;localhost:9200/_nodes?filter_path=**.mlockall&amp;amp;pretty&#039;&lt;br /&gt;
&lt;br /&gt;
curl -XGET &#039;localhost:9200/?pretty&#039;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see the results below.&lt;br /&gt;
&lt;br /&gt;
== Step 3 - Install and Configure Kibana with Nginx ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Kibana behind a Nginx web server. Kibana will listen on the localhost IP address only and Nginx acts as the reverse proxy for the Kibana application.&lt;br /&gt;
&lt;br /&gt;
Install Kibana with this apt command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y kibana&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the kibana.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /etc/kibana/kibana.yml&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment the server.port, server.hos and elasticsearch.url lines.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
server.port: 5601&lt;br /&gt;
&lt;br /&gt;
server.host: &amp;quot;localhost&amp;quot;&lt;br /&gt;
&lt;br /&gt;
elasticsearch.url: &amp;quot;http://localhost:9200&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Add Kibana to run at boot and start it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl enable kibana&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start kibana&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana will run on port 5601 as node application.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
netstat -plntu&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana installation is done, now we need to install Nginx and configure it as a reverse proxy to be able to access Kibana from the public IP address.&lt;br /&gt;
&lt;br /&gt;
Next, install the Nginx and apache2-utils packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo apt-get install -y nginx apache2-utils&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Apache2-utils is a package that contains tools for the webserver that work with Nginx as well, we will use htpasswd basic authentication for Kibana.&lt;br /&gt;
&lt;br /&gt;
Nginx has been installed. Now we need to create a new virtual host configuration file in the Nginx sites-available directory. Create a new file &#039;kibana&#039; with nano.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/nginx/&lt;br /&gt;
vim sites-available/kibana&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
    listen 80;&lt;br /&gt;
 &lt;br /&gt;
    server_name elk-stack.co;&lt;br /&gt;
 &lt;br /&gt;
    auth_basic &amp;quot;Restricted Access&amp;quot;;&lt;br /&gt;
    auth_basic_user_file /etc/nginx/.kibana-user;&lt;br /&gt;
 &lt;br /&gt;
    location / {&lt;br /&gt;
        proxy_pass http://localhost:5601;&lt;br /&gt;
        proxy_http_version 1.1;&lt;br /&gt;
        proxy_set_header Upgrade $http_upgrade;&lt;br /&gt;
        proxy_set_header Connection &#039;upgrade&#039;;&lt;br /&gt;
        proxy_set_header Host $host;&lt;br /&gt;
        proxy_cache_bypass $http_upgrade;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano&lt;br /&gt;
&lt;br /&gt;
Create a new basic authentication file with the htpasswd command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo htpasswd -c /etc/nginx/.kibana-user admin&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
TYPE YOUR PASSWORD&lt;br /&gt;
&lt;br /&gt;
Activate the kibana virtual host by creating a symbolic link from the kibana file in &#039;sites-available&#039; to the &#039;sites-enabled&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ln -s /etc/nginx/sites-available/kibana /etc/nginx/sites-enabled/ &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Test the nginx configuration and make sure there is no error, then add nginx to run at boot time and restart nginx.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
nginx -t&lt;br /&gt;
&lt;br /&gt;
systemctl enable nginx&lt;br /&gt;
&lt;br /&gt;
systemctl restart nginx&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Step 4 - Install and Configure Logstash == &lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Logsatash to centralize server logs from client sources with filebeat, then filter and transform all data (Syslog) and transport it to the stash (Elasticsearch).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install Logstash 5 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y logstash&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Edit the hosts file with nano.&lt;br /&gt;
&lt;br /&gt;
nano /etc/hosts&lt;br /&gt;
&lt;br /&gt;
Add the server IP address and hostname.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;10.0.2.15    elk-master&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the hosts file and exit the editor.&lt;br /&gt;
&lt;br /&gt;
Now generate a new SSL certificate file with OpenSSL so the client sources can identify the elastic server.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/logstash/&lt;br /&gt;
&lt;br /&gt;
openssl req -subj /CN=elk-master -x509 -days 3650 -batch -nodes -newkey rsa:4096 -keyout logstash.key -out logstash.crt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change the &#039;/CN&#039; value to the elastic server hostname.&lt;br /&gt;
&lt;br /&gt;
Certificate files will be created in the &#039;/etc/logstash/&#039; directory.&lt;br /&gt;
&lt;br /&gt;
Next, we will create the configuration files for logstash. We will create a configuration file &#039;filebeat-input.conf&#039; as input file from filebeat, &#039;syslog-filter.conf&#039; for syslog processing, and then a &#039;output-elasticsearch.conf&#039; file to define the Elasticsearch output.&lt;br /&gt;
&lt;br /&gt;
Go to the logstash configuration directory and create the new configuration files in the &#039;conf.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/logstash/&lt;br /&gt;
&lt;br /&gt;
nano conf.d/filebeat-input.conf&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Input configuration, paste configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input {&lt;br /&gt;
  beats {&lt;br /&gt;
    port =&amp;gt; 5443&lt;br /&gt;
    type =&amp;gt; syslog&lt;br /&gt;
    ssl =&amp;gt; true&lt;br /&gt;
    ssl_certificate =&amp;gt; &amp;quot;/etc/logstash/logstash.crt&amp;quot;&lt;br /&gt;
    ssl_key =&amp;gt; &amp;quot;/etc/logstash/logstash.key&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Create the syslog-filter.conf file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano conf.d/syslog-filter.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
filter {&lt;br /&gt;
  if [type] == &amp;quot;syslog&amp;quot; {&lt;br /&gt;
    grok {&lt;br /&gt;
      match =&amp;gt; { &amp;quot;message&amp;quot; =&amp;gt; &amp;quot;%{SYSLOGTIMESTAMP:syslog_timestamp} %{SYSLOGHOST:syslog_hostname} %{DATA:syslog_program}(?:\[%{POSINT:syslog_pid}\])?: %{GREEDYDATA:syslog_message}&amp;quot; }&lt;br /&gt;
      add_field =&amp;gt; [ &amp;quot;received_at&amp;quot;, &amp;quot;%{@timestamp}&amp;quot; ]&lt;br /&gt;
      add_field =&amp;gt; [ &amp;quot;received_from&amp;quot;, &amp;quot;%{host}&amp;quot; ]&lt;br /&gt;
    }&lt;br /&gt;
    date {&lt;br /&gt;
      match =&amp;gt; [ &amp;quot;syslog_timestamp&amp;quot;, &amp;quot;MMM  d HH:mm:ss&amp;quot;, &amp;quot;MMM dd HH:mm:ss&amp;quot; ]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We use a filter plugin named &#039;grok&#039; to parse the syslog files.&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Create the output configuration file &#039;output-elasticsearch.conf&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano conf.d/output-elasticsearch.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
output {&lt;br /&gt;
  elasticsearch { hosts =&amp;gt; [&amp;quot;localhost:9200&amp;quot;]&lt;br /&gt;
    hosts =&amp;gt; &amp;quot;localhost:9200&amp;quot;&lt;br /&gt;
    manage_template =&amp;gt; false&lt;br /&gt;
    index =&amp;gt; &amp;quot;%{[@metadata][beat]}-%{+YYYY.MM.dd}&amp;quot;&lt;br /&gt;
    document_type =&amp;gt; &amp;quot;%{[@metadata][type]}&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
When this is done, add logstash to start at boot time and start the service.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable logstash&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start logstash&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mdhasan</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123801</id>
		<title>Logging and monitoring with Elastic stack on Ubuntu 16.04</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123801"/>
		<updated>2017-06-21T20:01:49Z</updated>

		<summary type="html">&lt;p&gt;Mdhasan: /* Virtual Box setup */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
Logging and monitoring of IT systems is very important part of information security. Proper system logs and monitoring can prevent cyber attacks or service failure. In this wiki we will learn how configure logging and monitoring with ELK stack in Ubuntu server 16.04, what is alternatives (Graylog) of ELK stack and disadvantages of ELK stack.      &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Elasticsearch&#039;&#039;&#039; is an open source search engine based on Lucene, developed in java. It provides a distributed and multitenant [https://en.wikipedia.org/wiki/Full-text_search full-text search engine] with an HTTP Dashboard web-interface (Kibana) and JSON documents scheme. Elasticsearch is a scalable search engine that can be used to search for all types of documents, including log file. Elasticsearch is the heart of the &#039;Elastic Stack&#039; or ELK Stack.&amp;lt;ref&amp;gt;[https://www.elastic.co/products/elasticsearch] Elastic Search Homepage&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Logstash&#039;&#039;&#039; is an open source, server-side data processing pipeline that ingests data from a multitude of sources simultaneously, transforms it, and then sends it to Elasticsearch.&amp;lt;ref&amp;gt;[https://www.elastic.co/products/logstash] Logstash homepahe&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Kibana&#039;&#039;&#039; is a data visualization interface for Elasticsearch. Kibana provides a pretty dashboard (web interfaces), it allows you to manage and visualize all data from Elasticsearch on your own. &amp;lt;ref&amp;gt;[https://www.elastic.co/products/kibana] kibana homepage&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Prerequisite ==&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit server with 4GB of RAM, hostname - elk-master&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit client with 1 GB of RAM, hostname - elk-client&lt;br /&gt;
&lt;br /&gt;
Following installation steps from 1 to 4 is collected from &lt;br /&gt;
&lt;br /&gt;
[http://www.howtoforge.com HowToFroge.com]&amp;lt;ref&amp;gt;[http://thehackernews.com/2013/10/importance-of-logs-and-log-management.html]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Virtual Box setup ==&lt;br /&gt;
&lt;br /&gt;
As we are going to use Ubuntu server 16.04, which has no Graphical user interface (GUI). It is better to add a GUI client to Ubuntu server and ssh to virtual box setup. Here I will show to how to connect to Ubuntu server from a Ubuntu desktop client via SSH in Virtual box. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Step 1 - Virtual box Networking&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
- Select the Virtual machine Ubuntu server 16.04&lt;br /&gt;
- go to settings &amp;gt; network&lt;br /&gt;
- set Adapter 1 as Internal network (It is better to setup static IP for adapter 1)&lt;br /&gt;
- Also Add another network NAT (So the server will have internet access )&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Step 2 - Setup static IP in Ubuntu server (elk-master)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
- Become a root user &amp;lt;code&amp;gt; sudo -i &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Enable SSH by running following commands&amp;lt;ref&amp;gt;[https://askubuntu.com/questions/218344/why-am-i-getting-a-port-22-connection-refused-error open port 22 ]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; &lt;br /&gt;
sudo apt-get update&lt;br /&gt;
&lt;br /&gt;
sudo apt-get install openssh-server&lt;br /&gt;
&lt;br /&gt;
sudo ufw allow 22&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
- Set up static IP&lt;br /&gt;
&lt;br /&gt;
run this command &amp;lt;code&amp;gt; nano /etc/network/interfaces &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now you set a static IP for primary network as screenshot:&lt;br /&gt;
&lt;br /&gt;
[[File:Static-ip-elk-master.PNG]]&lt;br /&gt;
&lt;br /&gt;
== Step 1 - Install Java ==&lt;br /&gt;
&lt;br /&gt;
Java is required for the Elastic stack deployment. Elasticsearch requires Java 8. It is recommended to use the Oracle JDK 1.8. We will install Java 8 from a PPA repository.&lt;br /&gt;
&lt;br /&gt;
Install the new package &#039;&#039;&#039;&#039;python-software-properties&#039;&#039;&#039;&#039; so we can add a new repository easily with an apt command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y python-software-properties software-properties-common apt-transport-https&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the new Java 8 PPA repository with the &#039;add-apt-repository&#039; command, then update the repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo add-apt-repository ppa:webupd8team/java -y &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install Java 8 from the PPA webpub8 repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y oracle-java8-installer&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 2 - Install and Configure Elasticsearch ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Elasticsearch. Install Elasticsearch from the elastic repository and configure it to run on the localhost IP.&lt;br /&gt;
&lt;br /&gt;
Before installing Elasticsearch, add the elastic repository key to the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add - &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add elastic 5.x repository to the &#039;sources.list.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; echo &amp;quot;deb https://artifacts.elastic.co/packages/5.x/apt stable main&amp;quot; | sudo tee -a /etc/apt/sources.list.d/elastic-5.x.list &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Update the repository and install Elasticsearch 5.1 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Elasticsearch is installed. Now go to the configuration directory and edit the elasticsaerch.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; cd /etc/elasticsearch/ &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano elasticsearch.yml &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enable memory lock for Elasticsearch by removing the comment on line 43. We do this to disable swapping memory for Elasticsearchto avoid overloading the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; bootstrap.memory_lock: true &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the &#039;Network&#039; block, uncomment the network.host and http.port lines.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;network.host: localhost&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;http.port: 9200&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Now edit the elasticsearch service file for the memory lock mlockall configuration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /usr/lib/systemd/system/elasticsearch.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment LimitMEMLOCK line.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;LimitMEMLOCK=infinity&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit.&lt;br /&gt;
&lt;br /&gt;
Edit the default configuration for Elasticsearch in the /etc/default directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano /etc/default/elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment line 60 and make sure the value is &#039;unlimited&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;MAX_LOCKED_MEMORY=unlimited&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
The Elasticsearch configuration is finished. Elasticsearch will run under localhost IP address with port 9200 and we disabled swap memory by enabling mlockall on the Ubuntu server.&lt;br /&gt;
&lt;br /&gt;
Reload the Elasticsearch service file and enable it to run on the boot time, then start the service.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl daemon-reload&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable elasticsearch&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start elasticsearch&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Wait a sec for Elasticsearch to run, then check the open port on the server, make sure the &#039;state&#039; for port 9200 is &#039;LISTEN&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;netstat -plntu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then check the memory lock to ensure that mlockall is enabled. Also check that Elasticsearch is running with the commands below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
curl -XGET &#039;localhost:9200/_nodes?filter_path=**.mlockall&amp;amp;pretty&#039;&lt;br /&gt;
&lt;br /&gt;
curl -XGET &#039;localhost:9200/?pretty&#039;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see the results below.&lt;br /&gt;
&lt;br /&gt;
== Step 3 - Install and Configure Kibana with Nginx ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Kibana behind a Nginx web server. Kibana will listen on the localhost IP address only and Nginx acts as the reverse proxy for the Kibana application.&lt;br /&gt;
&lt;br /&gt;
Install Kibana with this apt command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y kibana&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the kibana.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /etc/kibana/kibana.yml&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment the server.port, server.hos and elasticsearch.url lines.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
server.port: 5601&lt;br /&gt;
&lt;br /&gt;
server.host: &amp;quot;localhost&amp;quot;&lt;br /&gt;
&lt;br /&gt;
elasticsearch.url: &amp;quot;http://localhost:9200&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Add Kibana to run at boot and start it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl enable kibana&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start kibana&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana will run on port 5601 as node application.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
netstat -plntu&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana installation is done, now we need to install Nginx and configure it as a reverse proxy to be able to access Kibana from the public IP address.&lt;br /&gt;
&lt;br /&gt;
Next, install the Nginx and apache2-utils packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo apt-get install -y nginx apache2-utils&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Apache2-utils is a package that contains tools for the webserver that work with Nginx as well, we will use htpasswd basic authentication for Kibana.&lt;br /&gt;
&lt;br /&gt;
Nginx has been installed. Now we need to create a new virtual host configuration file in the Nginx sites-available directory. Create a new file &#039;kibana&#039; with nano.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/nginx/&lt;br /&gt;
vim sites-available/kibana&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
    listen 80;&lt;br /&gt;
 &lt;br /&gt;
    server_name elk-stack.co;&lt;br /&gt;
 &lt;br /&gt;
    auth_basic &amp;quot;Restricted Access&amp;quot;;&lt;br /&gt;
    auth_basic_user_file /etc/nginx/.kibana-user;&lt;br /&gt;
 &lt;br /&gt;
    location / {&lt;br /&gt;
        proxy_pass http://localhost:5601;&lt;br /&gt;
        proxy_http_version 1.1;&lt;br /&gt;
        proxy_set_header Upgrade $http_upgrade;&lt;br /&gt;
        proxy_set_header Connection &#039;upgrade&#039;;&lt;br /&gt;
        proxy_set_header Host $host;&lt;br /&gt;
        proxy_cache_bypass $http_upgrade;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano&lt;br /&gt;
&lt;br /&gt;
Create a new basic authentication file with the htpasswd command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo htpasswd -c /etc/nginx/.kibana-user admin&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
TYPE YOUR PASSWORD&lt;br /&gt;
&lt;br /&gt;
Activate the kibana virtual host by creating a symbolic link from the kibana file in &#039;sites-available&#039; to the &#039;sites-enabled&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ln -s /etc/nginx/sites-available/kibana /etc/nginx/sites-enabled/ &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Test the nginx configuration and make sure there is no error, then add nginx to run at boot time and restart nginx.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
nginx -t&lt;br /&gt;
&lt;br /&gt;
systemctl enable nginx&lt;br /&gt;
&lt;br /&gt;
systemctl restart nginx&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Step 4 - Install and Configure Logstash == &lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Logsatash to centralize server logs from client sources with filebeat, then filter and transform all data (Syslog) and transport it to the stash (Elasticsearch).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install Logstash 5 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y logstash&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Edit the hosts file with nano.&lt;br /&gt;
&lt;br /&gt;
nano /etc/hosts&lt;br /&gt;
&lt;br /&gt;
Add the server IP address and hostname.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;10.0.2.15    elk-master&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the hosts file and exit the editor.&lt;br /&gt;
&lt;br /&gt;
Now generate a new SSL certificate file with OpenSSL so the client sources can identify the elastic server.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/logstash/&lt;br /&gt;
&lt;br /&gt;
openssl req -subj /CN=elk-master -x509 -days 3650 -batch -nodes -newkey rsa:4096 -keyout logstash.key -out logstash.crt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change the &#039;/CN&#039; value to the elastic server hostname.&lt;br /&gt;
&lt;br /&gt;
Certificate files will be created in the &#039;/etc/logstash/&#039; directory.&lt;br /&gt;
&lt;br /&gt;
Next, we will create the configuration files for logstash. We will create a configuration file &#039;filebeat-input.conf&#039; as input file from filebeat, &#039;syslog-filter.conf&#039; for syslog processing, and then a &#039;output-elasticsearch.conf&#039; file to define the Elasticsearch output.&lt;br /&gt;
&lt;br /&gt;
Go to the logstash configuration directory and create the new configuration files in the &#039;conf.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/logstash/&lt;br /&gt;
&lt;br /&gt;
nano conf.d/filebeat-input.conf&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Input configuration, paste configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input {&lt;br /&gt;
  beats {&lt;br /&gt;
    port =&amp;gt; 5443&lt;br /&gt;
    type =&amp;gt; syslog&lt;br /&gt;
    ssl =&amp;gt; true&lt;br /&gt;
    ssl_certificate =&amp;gt; &amp;quot;/etc/logstash/logstash.crt&amp;quot;&lt;br /&gt;
    ssl_key =&amp;gt; &amp;quot;/etc/logstash/logstash.key&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Create the syslog-filter.conf file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano conf.d/syslog-filter.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
filter {&lt;br /&gt;
  if [type] == &amp;quot;syslog&amp;quot; {&lt;br /&gt;
    grok {&lt;br /&gt;
      match =&amp;gt; { &amp;quot;message&amp;quot; =&amp;gt; &amp;quot;%{SYSLOGTIMESTAMP:syslog_timestamp} %{SYSLOGHOST:syslog_hostname} %{DATA:syslog_program}(?:\[%{POSINT:syslog_pid}\])?: %{GREEDYDATA:syslog_message}&amp;quot; }&lt;br /&gt;
      add_field =&amp;gt; [ &amp;quot;received_at&amp;quot;, &amp;quot;%{@timestamp}&amp;quot; ]&lt;br /&gt;
      add_field =&amp;gt; [ &amp;quot;received_from&amp;quot;, &amp;quot;%{host}&amp;quot; ]&lt;br /&gt;
    }&lt;br /&gt;
    date {&lt;br /&gt;
      match =&amp;gt; [ &amp;quot;syslog_timestamp&amp;quot;, &amp;quot;MMM  d HH:mm:ss&amp;quot;, &amp;quot;MMM dd HH:mm:ss&amp;quot; ]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We use a filter plugin named &#039;grok&#039; to parse the syslog files.&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Create the output configuration file &#039;output-elasticsearch.conf&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano conf.d/output-elasticsearch.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
output {&lt;br /&gt;
  elasticsearch { hosts =&amp;gt; [&amp;quot;localhost:9200&amp;quot;]&lt;br /&gt;
    hosts =&amp;gt; &amp;quot;localhost:9200&amp;quot;&lt;br /&gt;
    manage_template =&amp;gt; false&lt;br /&gt;
    index =&amp;gt; &amp;quot;%{[@metadata][beat]}-%{+YYYY.MM.dd}&amp;quot;&lt;br /&gt;
    document_type =&amp;gt; &amp;quot;%{[@metadata][type]}&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
When this is done, add logstash to start at boot time and start the service.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable logstash&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start logstash&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mdhasan</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=File:Static-ip-elk-master.PNG&amp;diff=123800</id>
		<title>File:Static-ip-elk-master.PNG</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=File:Static-ip-elk-master.PNG&amp;diff=123800"/>
		<updated>2017-06-21T20:01:21Z</updated>

		<summary type="html">&lt;p&gt;Mdhasan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</summary>
		<author><name>Mdhasan</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123799</id>
		<title>Logging and monitoring with Elastic stack on Ubuntu 16.04</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123799"/>
		<updated>2017-06-21T19:55:21Z</updated>

		<summary type="html">&lt;p&gt;Mdhasan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
Logging and monitoring of IT systems is very important part of information security. Proper system logs and monitoring can prevent cyber attacks or service failure. In this wiki we will learn how configure logging and monitoring with ELK stack in Ubuntu server 16.04, what is alternatives (Graylog) of ELK stack and disadvantages of ELK stack.      &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Elasticsearch&#039;&#039;&#039; is an open source search engine based on Lucene, developed in java. It provides a distributed and multitenant [https://en.wikipedia.org/wiki/Full-text_search full-text search engine] with an HTTP Dashboard web-interface (Kibana) and JSON documents scheme. Elasticsearch is a scalable search engine that can be used to search for all types of documents, including log file. Elasticsearch is the heart of the &#039;Elastic Stack&#039; or ELK Stack.&amp;lt;ref&amp;gt;[https://www.elastic.co/products/elasticsearch] Elastic Search Homepage&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Logstash&#039;&#039;&#039; is an open source, server-side data processing pipeline that ingests data from a multitude of sources simultaneously, transforms it, and then sends it to Elasticsearch.&amp;lt;ref&amp;gt;[https://www.elastic.co/products/logstash] Logstash homepahe&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Kibana&#039;&#039;&#039; is a data visualization interface for Elasticsearch. Kibana provides a pretty dashboard (web interfaces), it allows you to manage and visualize all data from Elasticsearch on your own. &amp;lt;ref&amp;gt;[https://www.elastic.co/products/kibana] kibana homepage&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Prerequisite ==&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit server with 4GB of RAM, hostname - elk-master&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit client with 1 GB of RAM, hostname - elk-client&lt;br /&gt;
&lt;br /&gt;
Following installation steps from 1 to 4 is collected from &lt;br /&gt;
&lt;br /&gt;
[http://www.howtoforge.com HowToFroge.com]&amp;lt;ref&amp;gt;[http://thehackernews.com/2013/10/importance-of-logs-and-log-management.html]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Virtual Box setup ==&lt;br /&gt;
&lt;br /&gt;
As we are going to use Ubuntu server 16.04, which has no Graphical user interface (GUI). It is better to add a GUI client to Ubuntu server and ssh to virtual box setup. Here I will show to how to connect to Ubuntu server from a Ubuntu desktop client via SSH in Virtual box. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Step 1 - Virtual box Networking&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
- Select the Virtual machine Ubuntu server 16.04&lt;br /&gt;
- go to settings &amp;gt; network&lt;br /&gt;
- set Adapter 1 as Internal network (It is better to setup static IP for adapter 1)&lt;br /&gt;
- Also Add another network NAT (So the server will have internet access )&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Step 2 - Setup static IP in Ubuntu server (elk-master)&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
- Enable SSH by running following commands&amp;lt;ref&amp;gt;[https://askubuntu.com/questions/218344/why-am-i-getting-a-port-22-connection-refused-error open port 22 ]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; &lt;br /&gt;
sudo apt-get update&lt;br /&gt;
sudo apt-get install openssh-server&lt;br /&gt;
sudo ufw allow 22&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 1 - Install Java ==&lt;br /&gt;
&lt;br /&gt;
Java is required for the Elastic stack deployment. Elasticsearch requires Java 8. It is recommended to use the Oracle JDK 1.8. We will install Java 8 from a PPA repository.&lt;br /&gt;
&lt;br /&gt;
Install the new package &#039;&#039;&#039;&#039;python-software-properties&#039;&#039;&#039;&#039; so we can add a new repository easily with an apt command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y python-software-properties software-properties-common apt-transport-https&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the new Java 8 PPA repository with the &#039;add-apt-repository&#039; command, then update the repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo add-apt-repository ppa:webupd8team/java -y &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install Java 8 from the PPA webpub8 repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y oracle-java8-installer&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 2 - Install and Configure Elasticsearch ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Elasticsearch. Install Elasticsearch from the elastic repository and configure it to run on the localhost IP.&lt;br /&gt;
&lt;br /&gt;
Before installing Elasticsearch, add the elastic repository key to the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add - &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add elastic 5.x repository to the &#039;sources.list.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; echo &amp;quot;deb https://artifacts.elastic.co/packages/5.x/apt stable main&amp;quot; | sudo tee -a /etc/apt/sources.list.d/elastic-5.x.list &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Update the repository and install Elasticsearch 5.1 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Elasticsearch is installed. Now go to the configuration directory and edit the elasticsaerch.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; cd /etc/elasticsearch/ &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano elasticsearch.yml &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enable memory lock for Elasticsearch by removing the comment on line 43. We do this to disable swapping memory for Elasticsearchto avoid overloading the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; bootstrap.memory_lock: true &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the &#039;Network&#039; block, uncomment the network.host and http.port lines.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;network.host: localhost&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;http.port: 9200&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Now edit the elasticsearch service file for the memory lock mlockall configuration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /usr/lib/systemd/system/elasticsearch.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment LimitMEMLOCK line.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;LimitMEMLOCK=infinity&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit.&lt;br /&gt;
&lt;br /&gt;
Edit the default configuration for Elasticsearch in the /etc/default directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano /etc/default/elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment line 60 and make sure the value is &#039;unlimited&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;MAX_LOCKED_MEMORY=unlimited&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
The Elasticsearch configuration is finished. Elasticsearch will run under localhost IP address with port 9200 and we disabled swap memory by enabling mlockall on the Ubuntu server.&lt;br /&gt;
&lt;br /&gt;
Reload the Elasticsearch service file and enable it to run on the boot time, then start the service.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl daemon-reload&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable elasticsearch&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start elasticsearch&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Wait a sec for Elasticsearch to run, then check the open port on the server, make sure the &#039;state&#039; for port 9200 is &#039;LISTEN&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;netstat -plntu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then check the memory lock to ensure that mlockall is enabled. Also check that Elasticsearch is running with the commands below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
curl -XGET &#039;localhost:9200/_nodes?filter_path=**.mlockall&amp;amp;pretty&#039;&lt;br /&gt;
&lt;br /&gt;
curl -XGET &#039;localhost:9200/?pretty&#039;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see the results below.&lt;br /&gt;
&lt;br /&gt;
== Step 3 - Install and Configure Kibana with Nginx ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Kibana behind a Nginx web server. Kibana will listen on the localhost IP address only and Nginx acts as the reverse proxy for the Kibana application.&lt;br /&gt;
&lt;br /&gt;
Install Kibana with this apt command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y kibana&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the kibana.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /etc/kibana/kibana.yml&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment the server.port, server.hos and elasticsearch.url lines.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
server.port: 5601&lt;br /&gt;
&lt;br /&gt;
server.host: &amp;quot;localhost&amp;quot;&lt;br /&gt;
&lt;br /&gt;
elasticsearch.url: &amp;quot;http://localhost:9200&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Add Kibana to run at boot and start it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl enable kibana&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start kibana&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana will run on port 5601 as node application.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
netstat -plntu&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana installation is done, now we need to install Nginx and configure it as a reverse proxy to be able to access Kibana from the public IP address.&lt;br /&gt;
&lt;br /&gt;
Next, install the Nginx and apache2-utils packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo apt-get install -y nginx apache2-utils&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Apache2-utils is a package that contains tools for the webserver that work with Nginx as well, we will use htpasswd basic authentication for Kibana.&lt;br /&gt;
&lt;br /&gt;
Nginx has been installed. Now we need to create a new virtual host configuration file in the Nginx sites-available directory. Create a new file &#039;kibana&#039; with nano.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/nginx/&lt;br /&gt;
vim sites-available/kibana&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
    listen 80;&lt;br /&gt;
 &lt;br /&gt;
    server_name elk-stack.co;&lt;br /&gt;
 &lt;br /&gt;
    auth_basic &amp;quot;Restricted Access&amp;quot;;&lt;br /&gt;
    auth_basic_user_file /etc/nginx/.kibana-user;&lt;br /&gt;
 &lt;br /&gt;
    location / {&lt;br /&gt;
        proxy_pass http://localhost:5601;&lt;br /&gt;
        proxy_http_version 1.1;&lt;br /&gt;
        proxy_set_header Upgrade $http_upgrade;&lt;br /&gt;
        proxy_set_header Connection &#039;upgrade&#039;;&lt;br /&gt;
        proxy_set_header Host $host;&lt;br /&gt;
        proxy_cache_bypass $http_upgrade;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano&lt;br /&gt;
&lt;br /&gt;
Create a new basic authentication file with the htpasswd command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo htpasswd -c /etc/nginx/.kibana-user admin&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
TYPE YOUR PASSWORD&lt;br /&gt;
&lt;br /&gt;
Activate the kibana virtual host by creating a symbolic link from the kibana file in &#039;sites-available&#039; to the &#039;sites-enabled&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ln -s /etc/nginx/sites-available/kibana /etc/nginx/sites-enabled/ &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Test the nginx configuration and make sure there is no error, then add nginx to run at boot time and restart nginx.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
nginx -t&lt;br /&gt;
&lt;br /&gt;
systemctl enable nginx&lt;br /&gt;
&lt;br /&gt;
systemctl restart nginx&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Step 4 - Install and Configure Logstash == &lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Logsatash to centralize server logs from client sources with filebeat, then filter and transform all data (Syslog) and transport it to the stash (Elasticsearch).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install Logstash 5 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y logstash&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Edit the hosts file with nano.&lt;br /&gt;
&lt;br /&gt;
nano /etc/hosts&lt;br /&gt;
&lt;br /&gt;
Add the server IP address and hostname.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;10.0.2.15    elk-master&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the hosts file and exit the editor.&lt;br /&gt;
&lt;br /&gt;
Now generate a new SSL certificate file with OpenSSL so the client sources can identify the elastic server.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/logstash/&lt;br /&gt;
&lt;br /&gt;
openssl req -subj /CN=elk-master -x509 -days 3650 -batch -nodes -newkey rsa:4096 -keyout logstash.key -out logstash.crt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change the &#039;/CN&#039; value to the elastic server hostname.&lt;br /&gt;
&lt;br /&gt;
Certificate files will be created in the &#039;/etc/logstash/&#039; directory.&lt;br /&gt;
&lt;br /&gt;
Next, we will create the configuration files for logstash. We will create a configuration file &#039;filebeat-input.conf&#039; as input file from filebeat, &#039;syslog-filter.conf&#039; for syslog processing, and then a &#039;output-elasticsearch.conf&#039; file to define the Elasticsearch output.&lt;br /&gt;
&lt;br /&gt;
Go to the logstash configuration directory and create the new configuration files in the &#039;conf.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/logstash/&lt;br /&gt;
&lt;br /&gt;
nano conf.d/filebeat-input.conf&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Input configuration, paste configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input {&lt;br /&gt;
  beats {&lt;br /&gt;
    port =&amp;gt; 5443&lt;br /&gt;
    type =&amp;gt; syslog&lt;br /&gt;
    ssl =&amp;gt; true&lt;br /&gt;
    ssl_certificate =&amp;gt; &amp;quot;/etc/logstash/logstash.crt&amp;quot;&lt;br /&gt;
    ssl_key =&amp;gt; &amp;quot;/etc/logstash/logstash.key&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Create the syslog-filter.conf file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano conf.d/syslog-filter.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
filter {&lt;br /&gt;
  if [type] == &amp;quot;syslog&amp;quot; {&lt;br /&gt;
    grok {&lt;br /&gt;
      match =&amp;gt; { &amp;quot;message&amp;quot; =&amp;gt; &amp;quot;%{SYSLOGTIMESTAMP:syslog_timestamp} %{SYSLOGHOST:syslog_hostname} %{DATA:syslog_program}(?:\[%{POSINT:syslog_pid}\])?: %{GREEDYDATA:syslog_message}&amp;quot; }&lt;br /&gt;
      add_field =&amp;gt; [ &amp;quot;received_at&amp;quot;, &amp;quot;%{@timestamp}&amp;quot; ]&lt;br /&gt;
      add_field =&amp;gt; [ &amp;quot;received_from&amp;quot;, &amp;quot;%{host}&amp;quot; ]&lt;br /&gt;
    }&lt;br /&gt;
    date {&lt;br /&gt;
      match =&amp;gt; [ &amp;quot;syslog_timestamp&amp;quot;, &amp;quot;MMM  d HH:mm:ss&amp;quot;, &amp;quot;MMM dd HH:mm:ss&amp;quot; ]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We use a filter plugin named &#039;grok&#039; to parse the syslog files.&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Create the output configuration file &#039;output-elasticsearch.conf&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano conf.d/output-elasticsearch.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
output {&lt;br /&gt;
  elasticsearch { hosts =&amp;gt; [&amp;quot;localhost:9200&amp;quot;]&lt;br /&gt;
    hosts =&amp;gt; &amp;quot;localhost:9200&amp;quot;&lt;br /&gt;
    manage_template =&amp;gt; false&lt;br /&gt;
    index =&amp;gt; &amp;quot;%{[@metadata][beat]}-%{+YYYY.MM.dd}&amp;quot;&lt;br /&gt;
    document_type =&amp;gt; &amp;quot;%{[@metadata][type]}&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
When this is done, add logstash to start at boot time and start the service.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable logstash&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start logstash&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mdhasan</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123798</id>
		<title>Logging and monitoring with Elastic stack on Ubuntu 16.04</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123798"/>
		<updated>2017-06-21T16:57:26Z</updated>

		<summary type="html">&lt;p&gt;Mdhasan: /* Step 2 - Install and Configure Elasticsearch */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
Logging and monitoring of IT systems is very important part of information security. Proper system logs and monitoring can prevent cyber attacks or service failure. In this wiki we will learn how configure logging and monitoring with ELK stack in Ubuntu server 16.04, what is alternatives (Graylog) of ELK stack and disadvantages of ELK stack.      &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Elasticsearch&#039;&#039;&#039; is an open source search engine based on Lucene, developed in java. It provides a distributed and multitenant [https://en.wikipedia.org/wiki/Full-text_search full-text search engine] with an HTTP Dashboard web-interface (Kibana) and JSON documents scheme. Elasticsearch is a scalable search engine that can be used to search for all types of documents, including log file. Elasticsearch is the heart of the &#039;Elastic Stack&#039; or ELK Stack.&amp;lt;ref&amp;gt;[https://www.elastic.co/products/elasticsearch] Elastic Search Homepage&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Logstash&#039;&#039;&#039; is an open source, server-side data processing pipeline that ingests data from a multitude of sources simultaneously, transforms it, and then sends it to Elasticsearch.&amp;lt;ref&amp;gt;[https://www.elastic.co/products/logstash] Logstash homepahe&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Kibana&#039;&#039;&#039; is a data visualization interface for Elasticsearch. Kibana provides a pretty dashboard (web interfaces), it allows you to manage and visualize all data from Elasticsearch on your own. &amp;lt;ref&amp;gt;[https://www.elastic.co/products/kibana] kibana homepage&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Prerequisite ==&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit server with 4GB of RAM, hostname - elk-master&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit client with 1 GB of RAM, hostname - elk-client&lt;br /&gt;
&lt;br /&gt;
Following installation steps from 1 to 4 is collected from &lt;br /&gt;
&lt;br /&gt;
[http://www.howtoforge.com HowToFroge.com]&amp;lt;ref&amp;gt;[http://thehackernews.com/2013/10/importance-of-logs-and-log-management.html]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 1 - Install Java ==&lt;br /&gt;
&lt;br /&gt;
Java is required for the Elastic stack deployment. Elasticsearch requires Java 8. It is recommended to use the Oracle JDK 1.8. We will install Java 8 from a PPA repository.&lt;br /&gt;
&lt;br /&gt;
Install the new package &#039;&#039;&#039;&#039;python-software-properties&#039;&#039;&#039;&#039; so we can add a new repository easily with an apt command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y python-software-properties software-properties-common apt-transport-https&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the new Java 8 PPA repository with the &#039;add-apt-repository&#039; command, then update the repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo add-apt-repository ppa:webupd8team/java -y &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install Java 8 from the PPA webpub8 repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y oracle-java8-installer&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 2 - Install and Configure Elasticsearch ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Elasticsearch. Install Elasticsearch from the elastic repository and configure it to run on the localhost IP.&lt;br /&gt;
&lt;br /&gt;
Before installing Elasticsearch, add the elastic repository key to the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add - &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add elastic 5.x repository to the &#039;sources.list.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; echo &amp;quot;deb https://artifacts.elastic.co/packages/5.x/apt stable main&amp;quot; | sudo tee -a /etc/apt/sources.list.d/elastic-5.x.list &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Update the repository and install Elasticsearch 5.1 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Elasticsearch is installed. Now go to the configuration directory and edit the elasticsaerch.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; cd /etc/elasticsearch/ &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano elasticsearch.yml &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enable memory lock for Elasticsearch by removing the comment on line 43. We do this to disable swapping memory for Elasticsearchto avoid overloading the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; bootstrap.memory_lock: true &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the &#039;Network&#039; block, uncomment the network.host and http.port lines.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;network.host: localhost&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;http.port: 9200&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Now edit the elasticsearch service file for the memory lock mlockall configuration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /usr/lib/systemd/system/elasticsearch.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment LimitMEMLOCK line.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;LimitMEMLOCK=infinity&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit.&lt;br /&gt;
&lt;br /&gt;
Edit the default configuration for Elasticsearch in the /etc/default directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano /etc/default/elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment line 60 and make sure the value is &#039;unlimited&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;MAX_LOCKED_MEMORY=unlimited&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
The Elasticsearch configuration is finished. Elasticsearch will run under localhost IP address with port 9200 and we disabled swap memory by enabling mlockall on the Ubuntu server.&lt;br /&gt;
&lt;br /&gt;
Reload the Elasticsearch service file and enable it to run on the boot time, then start the service.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl daemon-reload&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable elasticsearch&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start elasticsearch&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Wait a sec for Elasticsearch to run, then check the open port on the server, make sure the &#039;state&#039; for port 9200 is &#039;LISTEN&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;netstat -plntu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then check the memory lock to ensure that mlockall is enabled. Also check that Elasticsearch is running with the commands below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
curl -XGET &#039;localhost:9200/_nodes?filter_path=**.mlockall&amp;amp;pretty&#039;&lt;br /&gt;
&lt;br /&gt;
curl -XGET &#039;localhost:9200/?pretty&#039;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see the results below.&lt;br /&gt;
&lt;br /&gt;
== Step 3 - Install and Configure Kibana with Nginx ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Kibana behind a Nginx web server. Kibana will listen on the localhost IP address only and Nginx acts as the reverse proxy for the Kibana application.&lt;br /&gt;
&lt;br /&gt;
Install Kibana with this apt command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y kibana&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the kibana.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /etc/kibana/kibana.yml&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment the server.port, server.hos and elasticsearch.url lines.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
server.port: 5601&lt;br /&gt;
&lt;br /&gt;
server.host: &amp;quot;localhost&amp;quot;&lt;br /&gt;
&lt;br /&gt;
elasticsearch.url: &amp;quot;http://localhost:9200&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Add Kibana to run at boot and start it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl enable kibana&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start kibana&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana will run on port 5601 as node application.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
netstat -plntu&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana installation is done, now we need to install Nginx and configure it as a reverse proxy to be able to access Kibana from the public IP address.&lt;br /&gt;
&lt;br /&gt;
Next, install the Nginx and apache2-utils packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo apt-get install -y nginx apache2-utils&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Apache2-utils is a package that contains tools for the webserver that work with Nginx as well, we will use htpasswd basic authentication for Kibana.&lt;br /&gt;
&lt;br /&gt;
Nginx has been installed. Now we need to create a new virtual host configuration file in the Nginx sites-available directory. Create a new file &#039;kibana&#039; with nano.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/nginx/&lt;br /&gt;
vim sites-available/kibana&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
    listen 80;&lt;br /&gt;
 &lt;br /&gt;
    server_name elk-stack.co;&lt;br /&gt;
 &lt;br /&gt;
    auth_basic &amp;quot;Restricted Access&amp;quot;;&lt;br /&gt;
    auth_basic_user_file /etc/nginx/.kibana-user;&lt;br /&gt;
 &lt;br /&gt;
    location / {&lt;br /&gt;
        proxy_pass http://localhost:5601;&lt;br /&gt;
        proxy_http_version 1.1;&lt;br /&gt;
        proxy_set_header Upgrade $http_upgrade;&lt;br /&gt;
        proxy_set_header Connection &#039;upgrade&#039;;&lt;br /&gt;
        proxy_set_header Host $host;&lt;br /&gt;
        proxy_cache_bypass $http_upgrade;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano&lt;br /&gt;
&lt;br /&gt;
Create a new basic authentication file with the htpasswd command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo htpasswd -c /etc/nginx/.kibana-user admin&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
TYPE YOUR PASSWORD&lt;br /&gt;
&lt;br /&gt;
Activate the kibana virtual host by creating a symbolic link from the kibana file in &#039;sites-available&#039; to the &#039;sites-enabled&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ln -s /etc/nginx/sites-available/kibana /etc/nginx/sites-enabled/ &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Test the nginx configuration and make sure there is no error, then add nginx to run at boot time and restart nginx.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
nginx -t&lt;br /&gt;
&lt;br /&gt;
systemctl enable nginx&lt;br /&gt;
&lt;br /&gt;
systemctl restart nginx&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Step 4 - Install and Configure Logstash == &lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Logsatash to centralize server logs from client sources with filebeat, then filter and transform all data (Syslog) and transport it to the stash (Elasticsearch).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install Logstash 5 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y logstash&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Edit the hosts file with nano.&lt;br /&gt;
&lt;br /&gt;
nano /etc/hosts&lt;br /&gt;
&lt;br /&gt;
Add the server IP address and hostname.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;10.0.2.15    elk-master&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the hosts file and exit the editor.&lt;br /&gt;
&lt;br /&gt;
Now generate a new SSL certificate file with OpenSSL so the client sources can identify the elastic server.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/logstash/&lt;br /&gt;
&lt;br /&gt;
openssl req -subj /CN=elk-master -x509 -days 3650 -batch -nodes -newkey rsa:4096 -keyout logstash.key -out logstash.crt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change the &#039;/CN&#039; value to the elastic server hostname.&lt;br /&gt;
&lt;br /&gt;
Certificate files will be created in the &#039;/etc/logstash/&#039; directory.&lt;br /&gt;
&lt;br /&gt;
Next, we will create the configuration files for logstash. We will create a configuration file &#039;filebeat-input.conf&#039; as input file from filebeat, &#039;syslog-filter.conf&#039; for syslog processing, and then a &#039;output-elasticsearch.conf&#039; file to define the Elasticsearch output.&lt;br /&gt;
&lt;br /&gt;
Go to the logstash configuration directory and create the new configuration files in the &#039;conf.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/logstash/&lt;br /&gt;
&lt;br /&gt;
nano conf.d/filebeat-input.conf&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Input configuration, paste configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input {&lt;br /&gt;
  beats {&lt;br /&gt;
    port =&amp;gt; 5443&lt;br /&gt;
    type =&amp;gt; syslog&lt;br /&gt;
    ssl =&amp;gt; true&lt;br /&gt;
    ssl_certificate =&amp;gt; &amp;quot;/etc/logstash/logstash.crt&amp;quot;&lt;br /&gt;
    ssl_key =&amp;gt; &amp;quot;/etc/logstash/logstash.key&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Create the syslog-filter.conf file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano conf.d/syslog-filter.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
filter {&lt;br /&gt;
  if [type] == &amp;quot;syslog&amp;quot; {&lt;br /&gt;
    grok {&lt;br /&gt;
      match =&amp;gt; { &amp;quot;message&amp;quot; =&amp;gt; &amp;quot;%{SYSLOGTIMESTAMP:syslog_timestamp} %{SYSLOGHOST:syslog_hostname} %{DATA:syslog_program}(?:\[%{POSINT:syslog_pid}\])?: %{GREEDYDATA:syslog_message}&amp;quot; }&lt;br /&gt;
      add_field =&amp;gt; [ &amp;quot;received_at&amp;quot;, &amp;quot;%{@timestamp}&amp;quot; ]&lt;br /&gt;
      add_field =&amp;gt; [ &amp;quot;received_from&amp;quot;, &amp;quot;%{host}&amp;quot; ]&lt;br /&gt;
    }&lt;br /&gt;
    date {&lt;br /&gt;
      match =&amp;gt; [ &amp;quot;syslog_timestamp&amp;quot;, &amp;quot;MMM  d HH:mm:ss&amp;quot;, &amp;quot;MMM dd HH:mm:ss&amp;quot; ]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We use a filter plugin named &#039;grok&#039; to parse the syslog files.&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Create the output configuration file &#039;output-elasticsearch.conf&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano conf.d/output-elasticsearch.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
output {&lt;br /&gt;
  elasticsearch { hosts =&amp;gt; [&amp;quot;localhost:9200&amp;quot;]&lt;br /&gt;
    hosts =&amp;gt; &amp;quot;localhost:9200&amp;quot;&lt;br /&gt;
    manage_template =&amp;gt; false&lt;br /&gt;
    index =&amp;gt; &amp;quot;%{[@metadata][beat]}-%{+YYYY.MM.dd}&amp;quot;&lt;br /&gt;
    document_type =&amp;gt; &amp;quot;%{[@metadata][type]}&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
When this is done, add logstash to start at boot time and start the service.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable logstash&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start logstash&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mdhasan</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123797</id>
		<title>Logging and monitoring with Elastic stack on Ubuntu 16.04</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123797"/>
		<updated>2017-06-21T16:54:46Z</updated>

		<summary type="html">&lt;p&gt;Mdhasan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&lt;br /&gt;
Logging and monitoring of IT systems is very important part of information security. Proper system logs and monitoring can prevent cyber attacks or service failure. In this wiki we will learn how configure logging and monitoring with ELK stack in Ubuntu server 16.04, what is alternatives (Graylog) of ELK stack and disadvantages of ELK stack.      &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Elasticsearch&#039;&#039;&#039; is an open source search engine based on Lucene, developed in java. It provides a distributed and multitenant [https://en.wikipedia.org/wiki/Full-text_search full-text search engine] with an HTTP Dashboard web-interface (Kibana) and JSON documents scheme. Elasticsearch is a scalable search engine that can be used to search for all types of documents, including log file. Elasticsearch is the heart of the &#039;Elastic Stack&#039; or ELK Stack.&amp;lt;ref&amp;gt;[https://www.elastic.co/products/elasticsearch] Elastic Search Homepage&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Logstash&#039;&#039;&#039; is an open source, server-side data processing pipeline that ingests data from a multitude of sources simultaneously, transforms it, and then sends it to Elasticsearch.&amp;lt;ref&amp;gt;[https://www.elastic.co/products/logstash] Logstash homepahe&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Kibana&#039;&#039;&#039; is a data visualization interface for Elasticsearch. Kibana provides a pretty dashboard (web interfaces), it allows you to manage and visualize all data from Elasticsearch on your own. &amp;lt;ref&amp;gt;[https://www.elastic.co/products/kibana] kibana homepage&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Prerequisite ==&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit server with 4GB of RAM, hostname - elk-master&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit client with 1 GB of RAM, hostname - elk-client&lt;br /&gt;
&lt;br /&gt;
Following installation steps from 1 to 4 is collected from &lt;br /&gt;
&lt;br /&gt;
[http://www.howtoforge.com HowToFroge.com]&amp;lt;ref&amp;gt;[http://thehackernews.com/2013/10/importance-of-logs-and-log-management.html]&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 1 - Install Java ==&lt;br /&gt;
&lt;br /&gt;
Java is required for the Elastic stack deployment. Elasticsearch requires Java 8. It is recommended to use the Oracle JDK 1.8. We will install Java 8 from a PPA repository.&lt;br /&gt;
&lt;br /&gt;
Install the new package &#039;&#039;&#039;&#039;python-software-properties&#039;&#039;&#039;&#039; so we can add a new repository easily with an apt command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y python-software-properties software-properties-common apt-transport-https&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the new Java 8 PPA repository with the &#039;add-apt-repository&#039; command, then update the repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo add-apt-repository ppa:webupd8team/java -y &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install Java 8 from the PPA webpub8 repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y oracle-java8-installer&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 2 - Install and Configure Elasticsearch ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Elasticsearch. Install Elasticsearch from the elastic repository and configure it to run on the localhost IP.&lt;br /&gt;
&lt;br /&gt;
Before installing Elasticsearch, add the elastic repository key to the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add - &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add elastic 5.x repository to the &#039;sources.list.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; echo &amp;quot;deb https://artifacts.elastic.co/packages/5.x/apt stable main&amp;quot; | sudo tee -a /etc/apt/sources.list.d/elastic-5.x.list &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Update the repository and install Elasticsearch 5.1 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Elasticsearch is installed. Now go to the configuration directory and edit the elasticsaerch.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; cd /etc/elasticsearch/ &amp;lt;code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano elasticsearch.yml &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enable memory lock for Elasticsearch by removing the comment on line 43. We do this to disable swapping memory for Elasticsearchto avoid overloading the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; bootstrap.memory_lock: true &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the &#039;Network&#039; block, uncomment the network.host and http.port lines.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;network.host: localhost&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;http.port: 9200&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Now edit the elasticsearch service file for the memory lock mlockall configuration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /usr/lib/systemd/system/elasticsearch.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment LimitMEMLOCK line.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;LimitMEMLOCK=infinity&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit.&lt;br /&gt;
&lt;br /&gt;
Edit the default configuration for Elasticsearch in the /etc/default directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano /etc/default/elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment line 60 and make sure the value is &#039;unlimited&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;MAX_LOCKED_MEMORY=unlimited&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
The Elasticsearch configuration is finished. Elasticsearch will run under localhost IP address with port 9200 and we disabled swap memory by enabling mlockall on the Ubuntu server.&lt;br /&gt;
&lt;br /&gt;
Reload the Elasticsearch service file and enable it to run on the boot time, then start the service.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl daemon-reload&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable elasticsearch&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start elasticsearch&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Wait a sec for Elasticsearch to run, then check the open port on the server, make sure the &#039;state&#039; for port 9200 is &#039;LISTEN&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;netstat -plntu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then check the memory lock to ensure that mlockall is enabled. Also check that Elasticsearch is running with the commands below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
curl -XGET &#039;localhost:9200/_nodes?filter_path=**.mlockall&amp;amp;pretty&#039;&lt;br /&gt;
&lt;br /&gt;
curl -XGET &#039;localhost:9200/?pretty&#039;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see the results below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Step 3 - Install and Configure Kibana with Nginx ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Kibana behind a Nginx web server. Kibana will listen on the localhost IP address only and Nginx acts as the reverse proxy for the Kibana application.&lt;br /&gt;
&lt;br /&gt;
Install Kibana with this apt command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y kibana&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the kibana.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /etc/kibana/kibana.yml&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment the server.port, server.hos and elasticsearch.url lines.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
server.port: 5601&lt;br /&gt;
&lt;br /&gt;
server.host: &amp;quot;localhost&amp;quot;&lt;br /&gt;
&lt;br /&gt;
elasticsearch.url: &amp;quot;http://localhost:9200&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Add Kibana to run at boot and start it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl enable kibana&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start kibana&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana will run on port 5601 as node application.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
netstat -plntu&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana installation is done, now we need to install Nginx and configure it as a reverse proxy to be able to access Kibana from the public IP address.&lt;br /&gt;
&lt;br /&gt;
Next, install the Nginx and apache2-utils packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo apt-get install -y nginx apache2-utils&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Apache2-utils is a package that contains tools for the webserver that work with Nginx as well, we will use htpasswd basic authentication for Kibana.&lt;br /&gt;
&lt;br /&gt;
Nginx has been installed. Now we need to create a new virtual host configuration file in the Nginx sites-available directory. Create a new file &#039;kibana&#039; with nano.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/nginx/&lt;br /&gt;
vim sites-available/kibana&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
    listen 80;&lt;br /&gt;
 &lt;br /&gt;
    server_name elk-stack.co;&lt;br /&gt;
 &lt;br /&gt;
    auth_basic &amp;quot;Restricted Access&amp;quot;;&lt;br /&gt;
    auth_basic_user_file /etc/nginx/.kibana-user;&lt;br /&gt;
 &lt;br /&gt;
    location / {&lt;br /&gt;
        proxy_pass http://localhost:5601;&lt;br /&gt;
        proxy_http_version 1.1;&lt;br /&gt;
        proxy_set_header Upgrade $http_upgrade;&lt;br /&gt;
        proxy_set_header Connection &#039;upgrade&#039;;&lt;br /&gt;
        proxy_set_header Host $host;&lt;br /&gt;
        proxy_cache_bypass $http_upgrade;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano&lt;br /&gt;
&lt;br /&gt;
Create a new basic authentication file with the htpasswd command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo htpasswd -c /etc/nginx/.kibana-user admin&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
TYPE YOUR PASSWORD&lt;br /&gt;
&lt;br /&gt;
Activate the kibana virtual host by creating a symbolic link from the kibana file in &#039;sites-available&#039; to the &#039;sites-enabled&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ln -s /etc/nginx/sites-available/kibana /etc/nginx/sites-enabled/ &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Test the nginx configuration and make sure there is no error, then add nginx to run at boot time and restart nginx.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
nginx -t&lt;br /&gt;
&lt;br /&gt;
systemctl enable nginx&lt;br /&gt;
&lt;br /&gt;
systemctl restart nginx&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Step 4 - Install and Configure Logstash == &lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Logsatash to centralize server logs from client sources with filebeat, then filter and transform all data (Syslog) and transport it to the stash (Elasticsearch).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install Logstash 5 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y logstash&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Edit the hosts file with nano.&lt;br /&gt;
&lt;br /&gt;
nano /etc/hosts&lt;br /&gt;
&lt;br /&gt;
Add the server IP address and hostname.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;10.0.2.15    elk-master&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the hosts file and exit the editor.&lt;br /&gt;
&lt;br /&gt;
Now generate a new SSL certificate file with OpenSSL so the client sources can identify the elastic server.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/logstash/&lt;br /&gt;
&lt;br /&gt;
openssl req -subj /CN=elk-master -x509 -days 3650 -batch -nodes -newkey rsa:4096 -keyout logstash.key -out logstash.crt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change the &#039;/CN&#039; value to the elastic server hostname.&lt;br /&gt;
&lt;br /&gt;
Certificate files will be created in the &#039;/etc/logstash/&#039; directory.&lt;br /&gt;
&lt;br /&gt;
Next, we will create the configuration files for logstash. We will create a configuration file &#039;filebeat-input.conf&#039; as input file from filebeat, &#039;syslog-filter.conf&#039; for syslog processing, and then a &#039;output-elasticsearch.conf&#039; file to define the Elasticsearch output.&lt;br /&gt;
&lt;br /&gt;
Go to the logstash configuration directory and create the new configuration files in the &#039;conf.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/logstash/&lt;br /&gt;
&lt;br /&gt;
nano conf.d/filebeat-input.conf&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Input configuration, paste configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input {&lt;br /&gt;
  beats {&lt;br /&gt;
    port =&amp;gt; 5443&lt;br /&gt;
    type =&amp;gt; syslog&lt;br /&gt;
    ssl =&amp;gt; true&lt;br /&gt;
    ssl_certificate =&amp;gt; &amp;quot;/etc/logstash/logstash.crt&amp;quot;&lt;br /&gt;
    ssl_key =&amp;gt; &amp;quot;/etc/logstash/logstash.key&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Create the syslog-filter.conf file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano conf.d/syslog-filter.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
filter {&lt;br /&gt;
  if [type] == &amp;quot;syslog&amp;quot; {&lt;br /&gt;
    grok {&lt;br /&gt;
      match =&amp;gt; { &amp;quot;message&amp;quot; =&amp;gt; &amp;quot;%{SYSLOGTIMESTAMP:syslog_timestamp} %{SYSLOGHOST:syslog_hostname} %{DATA:syslog_program}(?:\[%{POSINT:syslog_pid}\])?: %{GREEDYDATA:syslog_message}&amp;quot; }&lt;br /&gt;
      add_field =&amp;gt; [ &amp;quot;received_at&amp;quot;, &amp;quot;%{@timestamp}&amp;quot; ]&lt;br /&gt;
      add_field =&amp;gt; [ &amp;quot;received_from&amp;quot;, &amp;quot;%{host}&amp;quot; ]&lt;br /&gt;
    }&lt;br /&gt;
    date {&lt;br /&gt;
      match =&amp;gt; [ &amp;quot;syslog_timestamp&amp;quot;, &amp;quot;MMM  d HH:mm:ss&amp;quot;, &amp;quot;MMM dd HH:mm:ss&amp;quot; ]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We use a filter plugin named &#039;grok&#039; to parse the syslog files.&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Create the output configuration file &#039;output-elasticsearch.conf&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano conf.d/output-elasticsearch.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
output {&lt;br /&gt;
  elasticsearch { hosts =&amp;gt; [&amp;quot;localhost:9200&amp;quot;]&lt;br /&gt;
    hosts =&amp;gt; &amp;quot;localhost:9200&amp;quot;&lt;br /&gt;
    manage_template =&amp;gt; false&lt;br /&gt;
    index =&amp;gt; &amp;quot;%{[@metadata][beat]}-%{+YYYY.MM.dd}&amp;quot;&lt;br /&gt;
    document_type =&amp;gt; &amp;quot;%{[@metadata][type]}&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
When this is done, add logstash to start at boot time and start the service.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable logstash&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start logstash&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mdhasan</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123796</id>
		<title>Logging and monitoring with Elastic stack on Ubuntu 16.04</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123796"/>
		<updated>2017-06-21T16:36:50Z</updated>

		<summary type="html">&lt;p&gt;Mdhasan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&#039;&#039;&#039;Elasticsearch&#039;&#039;&#039; is an open source search engine based on Lucene, developed in java. It provides a distributed and multitenant [https://en.wikipedia.org/wiki/Full-text_search full-text search engine] with an HTTP Dashboard web-interface (Kibana) and JSON documents scheme. Elasticsearch is a scalable search engine that can be used to search for all types of documents, including log file. Elasticsearch is the heart of the &#039;Elastic Stack&#039; or ELK Stack.&amp;lt;ref&amp;gt;[https://www.elastic.co/products/elasticsearch] Elastic Search Homepage&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Logstash&#039;&#039;&#039; is an open source, server-side data processing pipeline that ingests data from a multitude of sources simultaneously, transforms it, and then sends it to Elasticsearch.&amp;lt;ref&amp;gt;[https://www.elastic.co/products/logstash] Logstash homepahe&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Kibana&#039;&#039;&#039; is a data visualization interface for Elasticsearch. Kibana provides a pretty dashboard (web interfaces), it allows you to manage and visualize all data from Elasticsearch on your own. &amp;lt;ref&amp;gt;[https://www.elastic.co/products/kibana] kibana homepage&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:https://www.stratalux.com/wp-content/uploads/2016/06/Will-Migrating-to-the-Cloud-Save-Money-5.png]]&lt;br /&gt;
&lt;br /&gt;
In this HOW TO, I will show you how to install and configure Elastic Stack on a single Ubuntu 16.04 server for monitoring server logs and how to install &#039;Elastic beats&#039; on client PCs with Ubuntu 16.04.&lt;br /&gt;
&lt;br /&gt;
== Prerequisite ==&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit server with 4GB of RAM, hostname - elk-master&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit client with 1 GB of RAM, hostname - elk-client&lt;br /&gt;
&lt;br /&gt;
== Step 1 - Install Java ==&lt;br /&gt;
&lt;br /&gt;
Java is required for the Elastic stack deployment. Elasticsearch requires Java 8. It is recommended to use the Oracle JDK 1.8. We will install Java 8 from a PPA repository.&lt;br /&gt;
&lt;br /&gt;
Install the new package &#039;&#039;&#039;&#039;python-software-properties&#039;&#039;&#039;&#039; so we can add a new repository easily with an apt command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y python-software-properties software-properties-common apt-transport-https&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the new Java 8 PPA repository with the &#039;add-apt-repository&#039; command, then update the repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo add-apt-repository ppa:webupd8team/java -y &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install Java 8 from the PPA webpub8 repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y oracle-java8-installer&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 2 - Install and Configure Elasticsearch ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Elasticsearch. Install Elasticsearch from the elastic repository and configure it to run on the localhost IP.&lt;br /&gt;
&lt;br /&gt;
Before installing Elasticsearch, add the elastic repository key to the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add - &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add elastic 5.x repository to the &#039;sources.list.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; echo &amp;quot;deb https://artifacts.elastic.co/packages/5.x/apt stable main&amp;quot; | sudo tee -a /etc/apt/sources.list.d/elastic-5.x.list &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Update the repository and install Elasticsearch 5.1 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Elasticsearch is installed. Now go to the configuration directory and edit the elasticsaerch.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; cd /etc/elasticsearch/ &amp;lt;code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano elasticsearch.yml &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enable memory lock for Elasticsearch by removing the comment on line 43. We do this to disable swapping memory for Elasticsearchto avoid overloading the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; bootstrap.memory_lock: true &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the &#039;Network&#039; block, uncomment the network.host and http.port lines.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;network.host: localhost&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;http.port: 9200&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Now edit the elasticsearch service file for the memory lock mlockall configuration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /usr/lib/systemd/system/elasticsearch.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment LimitMEMLOCK line.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;LimitMEMLOCK=infinity&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit.&lt;br /&gt;
&lt;br /&gt;
Edit the default configuration for Elasticsearch in the /etc/default directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano /etc/default/elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment line 60 and make sure the value is &#039;unlimited&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;MAX_LOCKED_MEMORY=unlimited&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
The Elasticsearch configuration is finished. Elasticsearch will run under localhost IP address with port 9200 and we disabled swap memory by enabling mlockall on the Ubuntu server.&lt;br /&gt;
&lt;br /&gt;
Reload the Elasticsearch service file and enable it to run on the boot time, then start the service.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl daemon-reload&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable elasticsearch&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start elasticsearch&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Wait a sec for Elasticsearch to run, then check the open port on the server, make sure the &#039;state&#039; for port 9200 is &#039;LISTEN&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;netstat -plntu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then check the memory lock to ensure that mlockall is enabled. Also check that Elasticsearch is running with the commands below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
curl -XGET &#039;localhost:9200/_nodes?filter_path=**.mlockall&amp;amp;pretty&#039;&lt;br /&gt;
&lt;br /&gt;
curl -XGET &#039;localhost:9200/?pretty&#039;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see the results below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Step 3 - Install and Configure Kibana with Nginx ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Kibana behind a Nginx web server. Kibana will listen on the localhost IP address only and Nginx acts as the reverse proxy for the Kibana application.&lt;br /&gt;
&lt;br /&gt;
Install Kibana with this apt command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y kibana&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the kibana.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /etc/kibana/kibana.yml&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment the server.port, server.hos and elasticsearch.url lines.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
server.port: 5601&lt;br /&gt;
&lt;br /&gt;
server.host: &amp;quot;localhost&amp;quot;&lt;br /&gt;
&lt;br /&gt;
elasticsearch.url: &amp;quot;http://localhost:9200&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Add Kibana to run at boot and start it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl enable kibana&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start kibana&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana will run on port 5601 as node application.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
netstat -plntu&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana installation is done, now we need to install Nginx and configure it as a reverse proxy to be able to access Kibana from the public IP address.&lt;br /&gt;
&lt;br /&gt;
Next, install the Nginx and apache2-utils packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo apt-get install -y nginx apache2-utils&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Apache2-utils is a package that contains tools for the webserver that work with Nginx as well, we will use htpasswd basic authentication for Kibana.&lt;br /&gt;
&lt;br /&gt;
Nginx has been installed. Now we need to create a new virtual host configuration file in the Nginx sites-available directory. Create a new file &#039;kibana&#039; with nano.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/nginx/&lt;br /&gt;
vim sites-available/kibana&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
    listen 80;&lt;br /&gt;
 &lt;br /&gt;
    server_name elk-stack.co;&lt;br /&gt;
 &lt;br /&gt;
    auth_basic &amp;quot;Restricted Access&amp;quot;;&lt;br /&gt;
    auth_basic_user_file /etc/nginx/.kibana-user;&lt;br /&gt;
 &lt;br /&gt;
    location / {&lt;br /&gt;
        proxy_pass http://localhost:5601;&lt;br /&gt;
        proxy_http_version 1.1;&lt;br /&gt;
        proxy_set_header Upgrade $http_upgrade;&lt;br /&gt;
        proxy_set_header Connection &#039;upgrade&#039;;&lt;br /&gt;
        proxy_set_header Host $host;&lt;br /&gt;
        proxy_cache_bypass $http_upgrade;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano&lt;br /&gt;
&lt;br /&gt;
Create a new basic authentication file with the htpasswd command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo htpasswd -c /etc/nginx/.kibana-user admin&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
TYPE YOUR PASSWORD&lt;br /&gt;
&lt;br /&gt;
Activate the kibana virtual host by creating a symbolic link from the kibana file in &#039;sites-available&#039; to the &#039;sites-enabled&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ln -s /etc/nginx/sites-available/kibana /etc/nginx/sites-enabled/ &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Test the nginx configuration and make sure there is no error, then add nginx to run at boot time and restart nginx.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
nginx -t&lt;br /&gt;
&lt;br /&gt;
systemctl enable nginx&lt;br /&gt;
&lt;br /&gt;
systemctl restart nginx&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Step 4 - Install and Configure Logstash == &lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Logsatash to centralize server logs from client sources with filebeat, then filter and transform all data (Syslog) and transport it to the stash (Elasticsearch).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install Logstash 5 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y logstash&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Edit the hosts file with nano.&lt;br /&gt;
&lt;br /&gt;
nano /etc/hosts&lt;br /&gt;
&lt;br /&gt;
Add the server IP address and hostname.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;10.0.2.15    elk-master&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the hosts file and exit the editor.&lt;br /&gt;
&lt;br /&gt;
Now generate a new SSL certificate file with OpenSSL so the client sources can identify the elastic server.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/logstash/&lt;br /&gt;
&lt;br /&gt;
openssl req -subj /CN=elk-master -x509 -days 3650 -batch -nodes -newkey rsa:4096 -keyout logstash.key -out logstash.crt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change the &#039;/CN&#039; value to the elastic server hostname.&lt;br /&gt;
&lt;br /&gt;
Certificate files will be created in the &#039;/etc/logstash/&#039; directory.&lt;br /&gt;
&lt;br /&gt;
Next, we will create the configuration files for logstash. We will create a configuration file &#039;filebeat-input.conf&#039; as input file from filebeat, &#039;syslog-filter.conf&#039; for syslog processing, and then a &#039;output-elasticsearch.conf&#039; file to define the Elasticsearch output.&lt;br /&gt;
&lt;br /&gt;
Go to the logstash configuration directory and create the new configuration files in the &#039;conf.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/logstash/&lt;br /&gt;
&lt;br /&gt;
nano conf.d/filebeat-input.conf&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Input configuration, paste configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input {&lt;br /&gt;
  beats {&lt;br /&gt;
    port =&amp;gt; 5443&lt;br /&gt;
    type =&amp;gt; syslog&lt;br /&gt;
    ssl =&amp;gt; true&lt;br /&gt;
    ssl_certificate =&amp;gt; &amp;quot;/etc/logstash/logstash.crt&amp;quot;&lt;br /&gt;
    ssl_key =&amp;gt; &amp;quot;/etc/logstash/logstash.key&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Create the syslog-filter.conf file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano conf.d/syslog-filter.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
filter {&lt;br /&gt;
  if [type] == &amp;quot;syslog&amp;quot; {&lt;br /&gt;
    grok {&lt;br /&gt;
      match =&amp;gt; { &amp;quot;message&amp;quot; =&amp;gt; &amp;quot;%{SYSLOGTIMESTAMP:syslog_timestamp} %{SYSLOGHOST:syslog_hostname} %{DATA:syslog_program}(?:\[%{POSINT:syslog_pid}\])?: %{GREEDYDATA:syslog_message}&amp;quot; }&lt;br /&gt;
      add_field =&amp;gt; [ &amp;quot;received_at&amp;quot;, &amp;quot;%{@timestamp}&amp;quot; ]&lt;br /&gt;
      add_field =&amp;gt; [ &amp;quot;received_from&amp;quot;, &amp;quot;%{host}&amp;quot; ]&lt;br /&gt;
    }&lt;br /&gt;
    date {&lt;br /&gt;
      match =&amp;gt; [ &amp;quot;syslog_timestamp&amp;quot;, &amp;quot;MMM  d HH:mm:ss&amp;quot;, &amp;quot;MMM dd HH:mm:ss&amp;quot; ]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We use a filter plugin named &#039;grok&#039; to parse the syslog files.&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Create the output configuration file &#039;output-elasticsearch.conf&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano conf.d/output-elasticsearch.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
output {&lt;br /&gt;
  elasticsearch { hosts =&amp;gt; [&amp;quot;localhost:9200&amp;quot;]&lt;br /&gt;
    hosts =&amp;gt; &amp;quot;localhost:9200&amp;quot;&lt;br /&gt;
    manage_template =&amp;gt; false&lt;br /&gt;
    index =&amp;gt; &amp;quot;%{[@metadata][beat]}-%{+YYYY.MM.dd}&amp;quot;&lt;br /&gt;
    document_type =&amp;gt; &amp;quot;%{[@metadata][type]}&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
When this is done, add logstash to start at boot time and start the service.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable logstash&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start logstash&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mdhasan</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123795</id>
		<title>Logging and monitoring with Elastic stack on Ubuntu 16.04</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123795"/>
		<updated>2017-06-21T16:35:20Z</updated>

		<summary type="html">&lt;p&gt;Mdhasan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&#039;&#039;&#039;Elasticsearch&#039;&#039;&#039; is an open source search engine based on Lucene, developed in java. It provides a distributed and multitenant [https://en.wikipedia.org/wiki/Full-text_search full-text search engine] with an HTTP Dashboard web-interface (Kibana) and JSON documents scheme. Elasticsearch is a scalable search engine that can be used to search for all types of documents, including log file. Elasticsearch is the heart of the &#039;Elastic Stack&#039; or ELK Stack.&amp;lt;ref&amp;gt;[https://www.elastic.co/products/elasticsearch] Elastic Search Homepage&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Logstash&#039;&#039;&#039; is an open source, server-side data processing pipeline that ingests data from a multitude of sources simultaneously, transforms it, and then sends it to Elasticsearch.&amp;lt;ref&amp;gt;[https://www.elastic.co/products/logstash] Logstash homepahe&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Kibana&#039;&#039;&#039; is a data visualization interface for Elasticsearch. Kibana provides a pretty dashboard (web interfaces), it allows you to manage and visualize all data from Elasticsearch on your own. &amp;lt;ref&amp;gt;[https://www.elastic.co/products/kibana] kibana homepage&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:https://www.stratalux.com/wp-content/uploads/2016/06/Will-Migrating-to-the-Cloud-Save-Money-5.png]]&lt;br /&gt;
&lt;br /&gt;
In this HOW TO, I will show you how to install and configure Elastic Stack on a single Ubuntu 16.04 server for monitoring server logs and how to install &#039;Elastic beats&#039; on client PCs with Ubuntu 16.04.&lt;br /&gt;
&lt;br /&gt;
== Prerequisite ==&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit server with 4GB of RAM, hostname - elk-master&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit client with 1 GB of RAM, hostname - elk-client1&lt;br /&gt;
&lt;br /&gt;
== Step 1 - Install Java ==&lt;br /&gt;
&lt;br /&gt;
Java is required for the Elastic stack deployment. Elasticsearch requires Java 8. It is recommended to use the Oracle JDK 1.8. We will install Java 8 from a PPA repository.&lt;br /&gt;
&lt;br /&gt;
Install the new package &#039;&#039;&#039;&#039;python-software-properties&#039;&#039;&#039;&#039; so we can add a new repository easily with an apt command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y python-software-properties software-properties-common apt-transport-https&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the new Java 8 PPA repository with the &#039;add-apt-repository&#039; command, then update the repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo add-apt-repository ppa:webupd8team/java -y &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install Java 8 from the PPA webpub8 repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y oracle-java8-installer&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 2 - Install and Configure Elasticsearch ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Elasticsearch. Install Elasticsearch from the elastic repository and configure it to run on the localhost IP.&lt;br /&gt;
&lt;br /&gt;
Before installing Elasticsearch, add the elastic repository key to the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add - &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add elastic 5.x repository to the &#039;sources.list.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; echo &amp;quot;deb https://artifacts.elastic.co/packages/5.x/apt stable main&amp;quot; | sudo tee -a /etc/apt/sources.list.d/elastic-5.x.list &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Update the repository and install Elasticsearch 5.1 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Elasticsearch is installed. Now go to the configuration directory and edit the elasticsaerch.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; cd /etc/elasticsearch/ &amp;lt;code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano elasticsearch.yml &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enable memory lock for Elasticsearch by removing the comment on line 43. We do this to disable swapping memory for Elasticsearchto avoid overloading the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; bootstrap.memory_lock: true &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the &#039;Network&#039; block, uncomment the network.host and http.port lines.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;network.host: localhost&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;http.port: 9200&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Now edit the elasticsearch service file for the memory lock mlockall configuration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /usr/lib/systemd/system/elasticsearch.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment LimitMEMLOCK line.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;LimitMEMLOCK=infinity&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit.&lt;br /&gt;
&lt;br /&gt;
Edit the default configuration for Elasticsearch in the /etc/default directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano /etc/default/elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment line 60 and make sure the value is &#039;unlimited&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;MAX_LOCKED_MEMORY=unlimited&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
The Elasticsearch configuration is finished. Elasticsearch will run under localhost IP address with port 9200 and we disabled swap memory by enabling mlockall on the Ubuntu server.&lt;br /&gt;
&lt;br /&gt;
Reload the Elasticsearch service file and enable it to run on the boot time, then start the service.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl daemon-reload&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable elasticsearch&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start elasticsearch&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Wait a sec for Elasticsearch to run, then check the open port on the server, make sure the &#039;state&#039; for port 9200 is &#039;LISTEN&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;netstat -plntu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then check the memory lock to ensure that mlockall is enabled. Also check that Elasticsearch is running with the commands below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
curl -XGET &#039;localhost:9200/_nodes?filter_path=**.mlockall&amp;amp;pretty&#039;&lt;br /&gt;
&lt;br /&gt;
curl -XGET &#039;localhost:9200/?pretty&#039;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see the results below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Step 3 - Install and Configure Kibana with Nginx ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Kibana behind a Nginx web server. Kibana will listen on the localhost IP address only and Nginx acts as the reverse proxy for the Kibana application.&lt;br /&gt;
&lt;br /&gt;
Install Kibana with this apt command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y kibana&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the kibana.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /etc/kibana/kibana.yml&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment the server.port, server.hos and elasticsearch.url lines.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
server.port: 5601&lt;br /&gt;
&lt;br /&gt;
server.host: &amp;quot;localhost&amp;quot;&lt;br /&gt;
&lt;br /&gt;
elasticsearch.url: &amp;quot;http://localhost:9200&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Add Kibana to run at boot and start it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl enable kibana&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start kibana&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana will run on port 5601 as node application.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
netstat -plntu&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana installation is done, now we need to install Nginx and configure it as a reverse proxy to be able to access Kibana from the public IP address.&lt;br /&gt;
&lt;br /&gt;
Next, install the Nginx and apache2-utils packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo apt-get install -y nginx apache2-utils&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Apache2-utils is a package that contains tools for the webserver that work with Nginx as well, we will use htpasswd basic authentication for Kibana.&lt;br /&gt;
&lt;br /&gt;
Nginx has been installed. Now we need to create a new virtual host configuration file in the Nginx sites-available directory. Create a new file &#039;kibana&#039; with nano.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/nginx/&lt;br /&gt;
vim sites-available/kibana&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
    listen 80;&lt;br /&gt;
 &lt;br /&gt;
    server_name elk-stack.co;&lt;br /&gt;
 &lt;br /&gt;
    auth_basic &amp;quot;Restricted Access&amp;quot;;&lt;br /&gt;
    auth_basic_user_file /etc/nginx/.kibana-user;&lt;br /&gt;
 &lt;br /&gt;
    location / {&lt;br /&gt;
        proxy_pass http://localhost:5601;&lt;br /&gt;
        proxy_http_version 1.1;&lt;br /&gt;
        proxy_set_header Upgrade $http_upgrade;&lt;br /&gt;
        proxy_set_header Connection &#039;upgrade&#039;;&lt;br /&gt;
        proxy_set_header Host $host;&lt;br /&gt;
        proxy_cache_bypass $http_upgrade;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano&lt;br /&gt;
&lt;br /&gt;
Create a new basic authentication file with the htpasswd command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo htpasswd -c /etc/nginx/.kibana-user admin&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
TYPE YOUR PASSWORD&lt;br /&gt;
&lt;br /&gt;
Activate the kibana virtual host by creating a symbolic link from the kibana file in &#039;sites-available&#039; to the &#039;sites-enabled&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ln -s /etc/nginx/sites-available/kibana /etc/nginx/sites-enabled/ &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Test the nginx configuration and make sure there is no error, then add nginx to run at boot time and restart nginx.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
nginx -t&lt;br /&gt;
&lt;br /&gt;
systemctl enable nginx&lt;br /&gt;
&lt;br /&gt;
systemctl restart nginx&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Step 4 - Install and Configure Logstash == &lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Logsatash to centralize server logs from client sources with filebeat, then filter and transform all data (Syslog) and transport it to the stash (Elasticsearch).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install Logstash 5 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y logstash&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Edit the hosts file with nano.&lt;br /&gt;
&lt;br /&gt;
nano /etc/hosts&lt;br /&gt;
&lt;br /&gt;
Add the server IP address and hostname.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;10.0.2.15    elk-master&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the hosts file and exit the editor.&lt;br /&gt;
&lt;br /&gt;
Now generate a new SSL certificate file with OpenSSL so the client sources can identify the elastic server.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/logstash/&lt;br /&gt;
&lt;br /&gt;
openssl req -subj /CN=elk-master -x509 -days 3650 -batch -nodes -newkey rsa:4096 -keyout logstash.key -out logstash.crt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change the &#039;/CN&#039; value to the elastic server hostname.&lt;br /&gt;
&lt;br /&gt;
Certificate files will be created in the &#039;/etc/logstash/&#039; directory.&lt;br /&gt;
&lt;br /&gt;
Next, we will create the configuration files for logstash. We will create a configuration file &#039;filebeat-input.conf&#039; as input file from filebeat, &#039;syslog-filter.conf&#039; for syslog processing, and then a &#039;output-elasticsearch.conf&#039; file to define the Elasticsearch output.&lt;br /&gt;
&lt;br /&gt;
Go to the logstash configuration directory and create the new configuration files in the &#039;conf.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/logstash/&lt;br /&gt;
&lt;br /&gt;
nano conf.d/filebeat-input.conf&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Input configuration, paste configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input {&lt;br /&gt;
  beats {&lt;br /&gt;
    port =&amp;gt; 5443&lt;br /&gt;
    type =&amp;gt; syslog&lt;br /&gt;
    ssl =&amp;gt; true&lt;br /&gt;
    ssl_certificate =&amp;gt; &amp;quot;/etc/logstash/logstash.crt&amp;quot;&lt;br /&gt;
    ssl_key =&amp;gt; &amp;quot;/etc/logstash/logstash.key&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Create the syslog-filter.conf file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano conf.d/syslog-filter.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
filter {&lt;br /&gt;
  if [type] == &amp;quot;syslog&amp;quot; {&lt;br /&gt;
    grok {&lt;br /&gt;
      match =&amp;gt; { &amp;quot;message&amp;quot; =&amp;gt; &amp;quot;%{SYSLOGTIMESTAMP:syslog_timestamp} %{SYSLOGHOST:syslog_hostname} %{DATA:syslog_program}(?:\[%{POSINT:syslog_pid}\])?: %{GREEDYDATA:syslog_message}&amp;quot; }&lt;br /&gt;
      add_field =&amp;gt; [ &amp;quot;received_at&amp;quot;, &amp;quot;%{@timestamp}&amp;quot; ]&lt;br /&gt;
      add_field =&amp;gt; [ &amp;quot;received_from&amp;quot;, &amp;quot;%{host}&amp;quot; ]&lt;br /&gt;
    }&lt;br /&gt;
    date {&lt;br /&gt;
      match =&amp;gt; [ &amp;quot;syslog_timestamp&amp;quot;, &amp;quot;MMM  d HH:mm:ss&amp;quot;, &amp;quot;MMM dd HH:mm:ss&amp;quot; ]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We use a filter plugin named &#039;grok&#039; to parse the syslog files.&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Create the output configuration file &#039;output-elasticsearch.conf&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano conf.d/output-elasticsearch.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
output {&lt;br /&gt;
  elasticsearch { hosts =&amp;gt; [&amp;quot;localhost:9200&amp;quot;]&lt;br /&gt;
    hosts =&amp;gt; &amp;quot;localhost:9200&amp;quot;&lt;br /&gt;
    manage_template =&amp;gt; false&lt;br /&gt;
    index =&amp;gt; &amp;quot;%{[@metadata][beat]}-%{+YYYY.MM.dd}&amp;quot;&lt;br /&gt;
    document_type =&amp;gt; &amp;quot;%{[@metadata][type]}&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
When this is done, add logstash to start at boot time and start the service.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable logstash&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start logstash&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mdhasan</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123794</id>
		<title>Logging and monitoring with Elastic stack on Ubuntu 16.04</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123794"/>
		<updated>2017-06-21T16:33:30Z</updated>

		<summary type="html">&lt;p&gt;Mdhasan: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&#039;&#039;&#039;Elasticsearch&#039;&#039;&#039; is an open source search engine based on Lucene, developed in java. It provides a distributed and multitenant [https://en.wikipedia.org/wiki/Full-text_search full-text search engine] with an HTTP Dashboard web-interface (Kibana) and JSON documents scheme. Elasticsearch is a scalable search engine that can be used to search for all types of documents, including log file. Elasticsearch is the heart of the &#039;Elastic Stack&#039; or ELK Stack.&amp;lt;ref&amp;gt;[https://www.elastic.co/products/elasticsearch] Elastic Search Homepage&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Logstash&#039;&#039;&#039; is an open source, server-side data processing pipeline that ingests data from a multitude of sources simultaneously, transforms it, and then sends it to Elasticsearch.&amp;lt;ref&amp;gt;[https://www.elastic.co/products/logstash] Logstash homepahe&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Kibana&#039;&#039;&#039; is a data visualization interface for Elasticsearch. Kibana provides a pretty dashboard (web interfaces), it allows you to manage and visualize all data from Elasticsearch on your own. &amp;lt;ref&amp;gt;[https://www.elastic.co/products/kibana] kibana homepage&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:https://www.stratalux.com/wp-content/uploads/2016/06/Will-Migrating-to-the-Cloud-Save-Money-5.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this HOW TO, I will show you how to install and configure Elastic Stack on a single Ubuntu 16.04 server for monitoring server logs and how to install &#039;Elastic beats&#039; on client PCs with Ubuntu 16.04.&lt;br /&gt;
&lt;br /&gt;
== Prerequisite ==&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit server with 4GB of RAM, hostname - elk-master&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit client with 1 GB of RAM, hostname - elk-client1&lt;br /&gt;
&lt;br /&gt;
== Step 1 - Install Java ==&lt;br /&gt;
&lt;br /&gt;
Java is required for the Elastic stack deployment. Elasticsearch requires Java 8. It is recommended to use the Oracle JDK 1.8. We will install Java 8 from a PPA repository.&lt;br /&gt;
&lt;br /&gt;
Install the new package &#039;&#039;&#039;&#039;python-software-properties&#039;&#039;&#039;&#039; so we can add a new repository easily with an apt command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y python-software-properties software-properties-common apt-transport-https&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the new Java 8 PPA repository with the &#039;add-apt-repository&#039; command, then update the repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo add-apt-repository ppa:webupd8team/java -y &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install Java 8 from the PPA webpub8 repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y oracle-java8-installer&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 2 - Install and Configure Elasticsearch ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Elasticsearch. Install Elasticsearch from the elastic repository and configure it to run on the localhost IP.&lt;br /&gt;
&lt;br /&gt;
Before installing Elasticsearch, add the elastic repository key to the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add - &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add elastic 5.x repository to the &#039;sources.list.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; echo &amp;quot;deb https://artifacts.elastic.co/packages/5.x/apt stable main&amp;quot; | sudo tee -a /etc/apt/sources.list.d/elastic-5.x.list &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Update the repository and install Elasticsearch 5.1 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Elasticsearch is installed. Now go to the configuration directory and edit the elasticsaerch.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; cd /etc/elasticsearch/ &amp;lt;code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano elasticsearch.yml &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enable memory lock for Elasticsearch by removing the comment on line 43. We do this to disable swapping memory for Elasticsearchto avoid overloading the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; bootstrap.memory_lock: true &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the &#039;Network&#039; block, uncomment the network.host and http.port lines.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;network.host: localhost&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;http.port: 9200&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Now edit the elasticsearch service file for the memory lock mlockall configuration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /usr/lib/systemd/system/elasticsearch.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment LimitMEMLOCK line.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;LimitMEMLOCK=infinity&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit.&lt;br /&gt;
&lt;br /&gt;
Edit the default configuration for Elasticsearch in the /etc/default directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano /etc/default/elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment line 60 and make sure the value is &#039;unlimited&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;MAX_LOCKED_MEMORY=unlimited&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
The Elasticsearch configuration is finished. Elasticsearch will run under localhost IP address with port 9200 and we disabled swap memory by enabling mlockall on the Ubuntu server.&lt;br /&gt;
&lt;br /&gt;
Reload the Elasticsearch service file and enable it to run on the boot time, then start the service.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl daemon-reload&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable elasticsearch&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start elasticsearch&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Wait a sec for Elasticsearch to run, then check the open port on the server, make sure the &#039;state&#039; for port 9200 is &#039;LISTEN&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;netstat -plntu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then check the memory lock to ensure that mlockall is enabled. Also check that Elasticsearch is running with the commands below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
curl -XGET &#039;localhost:9200/_nodes?filter_path=**.mlockall&amp;amp;pretty&#039;&lt;br /&gt;
&lt;br /&gt;
curl -XGET &#039;localhost:9200/?pretty&#039;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see the results below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Step 3 - Install and Configure Kibana with Nginx ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Kibana behind a Nginx web server. Kibana will listen on the localhost IP address only and Nginx acts as the reverse proxy for the Kibana application.&lt;br /&gt;
&lt;br /&gt;
Install Kibana with this apt command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y kibana&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the kibana.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /etc/kibana/kibana.yml&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment the server.port, server.hos and elasticsearch.url lines.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
server.port: 5601&lt;br /&gt;
&lt;br /&gt;
server.host: &amp;quot;localhost&amp;quot;&lt;br /&gt;
&lt;br /&gt;
elasticsearch.url: &amp;quot;http://localhost:9200&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Add Kibana to run at boot and start it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl enable kibana&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start kibana&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana will run on port 5601 as node application.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
netstat -plntu&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana installation is done, now we need to install Nginx and configure it as a reverse proxy to be able to access Kibana from the public IP address.&lt;br /&gt;
&lt;br /&gt;
Next, install the Nginx and apache2-utils packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo apt-get install -y nginx apache2-utils&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Apache2-utils is a package that contains tools for the webserver that work with Nginx as well, we will use htpasswd basic authentication for Kibana.&lt;br /&gt;
&lt;br /&gt;
Nginx has been installed. Now we need to create a new virtual host configuration file in the Nginx sites-available directory. Create a new file &#039;kibana&#039; with nano.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/nginx/&lt;br /&gt;
vim sites-available/kibana&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
    listen 80;&lt;br /&gt;
 &lt;br /&gt;
    server_name elk-stack.co;&lt;br /&gt;
 &lt;br /&gt;
    auth_basic &amp;quot;Restricted Access&amp;quot;;&lt;br /&gt;
    auth_basic_user_file /etc/nginx/.kibana-user;&lt;br /&gt;
 &lt;br /&gt;
    location / {&lt;br /&gt;
        proxy_pass http://localhost:5601;&lt;br /&gt;
        proxy_http_version 1.1;&lt;br /&gt;
        proxy_set_header Upgrade $http_upgrade;&lt;br /&gt;
        proxy_set_header Connection &#039;upgrade&#039;;&lt;br /&gt;
        proxy_set_header Host $host;&lt;br /&gt;
        proxy_cache_bypass $http_upgrade;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano&lt;br /&gt;
&lt;br /&gt;
Create a new basic authentication file with the htpasswd command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo htpasswd -c /etc/nginx/.kibana-user admin&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
TYPE YOUR PASSWORD&lt;br /&gt;
&lt;br /&gt;
Activate the kibana virtual host by creating a symbolic link from the kibana file in &#039;sites-available&#039; to the &#039;sites-enabled&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ln -s /etc/nginx/sites-available/kibana /etc/nginx/sites-enabled/ &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Test the nginx configuration and make sure there is no error, then add nginx to run at boot time and restart nginx.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
nginx -t&lt;br /&gt;
&lt;br /&gt;
systemctl enable nginx&lt;br /&gt;
&lt;br /&gt;
systemctl restart nginx&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Step 4 - Install and Configure Logstash == &lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Logsatash to centralize server logs from client sources with filebeat, then filter and transform all data (Syslog) and transport it to the stash (Elasticsearch).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install Logstash 5 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y logstash&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Edit the hosts file with nano.&lt;br /&gt;
&lt;br /&gt;
nano /etc/hosts&lt;br /&gt;
&lt;br /&gt;
Add the server IP address and hostname.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;10.0.2.15    elk-master&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the hosts file and exit the editor.&lt;br /&gt;
&lt;br /&gt;
Now generate a new SSL certificate file with OpenSSL so the client sources can identify the elastic server.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/logstash/&lt;br /&gt;
&lt;br /&gt;
openssl req -subj /CN=elk-master -x509 -days 3650 -batch -nodes -newkey rsa:4096 -keyout logstash.key -out logstash.crt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change the &#039;/CN&#039; value to the elastic server hostname.&lt;br /&gt;
&lt;br /&gt;
Certificate files will be created in the &#039;/etc/logstash/&#039; directory.&lt;br /&gt;
&lt;br /&gt;
Next, we will create the configuration files for logstash. We will create a configuration file &#039;filebeat-input.conf&#039; as input file from filebeat, &#039;syslog-filter.conf&#039; for syslog processing, and then a &#039;output-elasticsearch.conf&#039; file to define the Elasticsearch output.&lt;br /&gt;
&lt;br /&gt;
Go to the logstash configuration directory and create the new configuration files in the &#039;conf.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/logstash/&lt;br /&gt;
&lt;br /&gt;
nano conf.d/filebeat-input.conf&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Input configuration, paste configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input {&lt;br /&gt;
  beats {&lt;br /&gt;
    port =&amp;gt; 5443&lt;br /&gt;
    type =&amp;gt; syslog&lt;br /&gt;
    ssl =&amp;gt; true&lt;br /&gt;
    ssl_certificate =&amp;gt; &amp;quot;/etc/logstash/logstash.crt&amp;quot;&lt;br /&gt;
    ssl_key =&amp;gt; &amp;quot;/etc/logstash/logstash.key&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Create the syslog-filter.conf file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano conf.d/syslog-filter.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
filter {&lt;br /&gt;
  if [type] == &amp;quot;syslog&amp;quot; {&lt;br /&gt;
    grok {&lt;br /&gt;
      match =&amp;gt; { &amp;quot;message&amp;quot; =&amp;gt; &amp;quot;%{SYSLOGTIMESTAMP:syslog_timestamp} %{SYSLOGHOST:syslog_hostname} %{DATA:syslog_program}(?:\[%{POSINT:syslog_pid}\])?: %{GREEDYDATA:syslog_message}&amp;quot; }&lt;br /&gt;
      add_field =&amp;gt; [ &amp;quot;received_at&amp;quot;, &amp;quot;%{@timestamp}&amp;quot; ]&lt;br /&gt;
      add_field =&amp;gt; [ &amp;quot;received_from&amp;quot;, &amp;quot;%{host}&amp;quot; ]&lt;br /&gt;
    }&lt;br /&gt;
    date {&lt;br /&gt;
      match =&amp;gt; [ &amp;quot;syslog_timestamp&amp;quot;, &amp;quot;MMM  d HH:mm:ss&amp;quot;, &amp;quot;MMM dd HH:mm:ss&amp;quot; ]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We use a filter plugin named &#039;grok&#039; to parse the syslog files.&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Create the output configuration file &#039;output-elasticsearch.conf&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano conf.d/output-elasticsearch.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
output {&lt;br /&gt;
  elasticsearch { hosts =&amp;gt; [&amp;quot;localhost:9200&amp;quot;]&lt;br /&gt;
    hosts =&amp;gt; &amp;quot;localhost:9200&amp;quot;&lt;br /&gt;
    manage_template =&amp;gt; false&lt;br /&gt;
    index =&amp;gt; &amp;quot;%{[@metadata][beat]}-%{+YYYY.MM.dd}&amp;quot;&lt;br /&gt;
    document_type =&amp;gt; &amp;quot;%{[@metadata][type]}&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
When this is done, add logstash to start at boot time and start the service.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable logstash&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start logstash&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mdhasan</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123793</id>
		<title>Logging and monitoring with Elastic stack on Ubuntu 16.04</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123793"/>
		<updated>2017-06-21T16:33:14Z</updated>

		<summary type="html">&lt;p&gt;Mdhasan: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&#039;&#039;&#039;Elasticsearch&#039;&#039;&#039; is an open source search engine based on Lucene, developed in java. It provides a distributed and multitenant [https://en.wikipedia.org/wiki/Full-text_search full-text search engine] with an HTTP Dashboard web-interface (Kibana) and JSON documents scheme. Elasticsearch is a scalable search engine that can be used to search for all types of documents, including log file. Elasticsearch is the heart of the &#039;Elastic Stack&#039; or ELK Stack.&amp;lt;ref&amp;gt;[https://www.elastic.co/products/elasticsearch] Elastic Search Homepage&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Logstash&#039;&#039;&#039; is an open source, server-side data processing pipeline that ingests data from a multitude of sources simultaneously, transforms it, and then sends it to Elasticsearch.&amp;lt;ref&amp;gt;[https://www.elastic.co/products/logstash] Logstash homepahe&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Kibana&#039;&#039;&#039; is a data visualization interface for Elasticsearch. Kibana provides a pretty dashboard (web interfaces), it allows you to manage and visualize all data from Elasticsearch on your own. &amp;lt;ref&amp;gt;[https://www.elastic.co/products/kibana] kibana homepage&amp;lt;/ref&amp;gt;[[File:https://www.stratalux.com/wp-content/uploads/2016/06/Will-Migrating-to-the-Cloud-Save-Money-5.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this HOW TO, I will show you how to install and configure Elastic Stack on a single Ubuntu 16.04 server for monitoring server logs and how to install &#039;Elastic beats&#039; on client PCs with Ubuntu 16.04.&lt;br /&gt;
&lt;br /&gt;
== Prerequisite ==&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit server with 4GB of RAM, hostname - elk-master&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit client with 1 GB of RAM, hostname - elk-client1&lt;br /&gt;
&lt;br /&gt;
== Step 1 - Install Java ==&lt;br /&gt;
&lt;br /&gt;
Java is required for the Elastic stack deployment. Elasticsearch requires Java 8. It is recommended to use the Oracle JDK 1.8. We will install Java 8 from a PPA repository.&lt;br /&gt;
&lt;br /&gt;
Install the new package &#039;&#039;&#039;&#039;python-software-properties&#039;&#039;&#039;&#039; so we can add a new repository easily with an apt command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y python-software-properties software-properties-common apt-transport-https&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the new Java 8 PPA repository with the &#039;add-apt-repository&#039; command, then update the repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo add-apt-repository ppa:webupd8team/java -y &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install Java 8 from the PPA webpub8 repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y oracle-java8-installer&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 2 - Install and Configure Elasticsearch ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Elasticsearch. Install Elasticsearch from the elastic repository and configure it to run on the localhost IP.&lt;br /&gt;
&lt;br /&gt;
Before installing Elasticsearch, add the elastic repository key to the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add - &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add elastic 5.x repository to the &#039;sources.list.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; echo &amp;quot;deb https://artifacts.elastic.co/packages/5.x/apt stable main&amp;quot; | sudo tee -a /etc/apt/sources.list.d/elastic-5.x.list &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Update the repository and install Elasticsearch 5.1 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Elasticsearch is installed. Now go to the configuration directory and edit the elasticsaerch.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; cd /etc/elasticsearch/ &amp;lt;code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano elasticsearch.yml &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enable memory lock for Elasticsearch by removing the comment on line 43. We do this to disable swapping memory for Elasticsearchto avoid overloading the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; bootstrap.memory_lock: true &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the &#039;Network&#039; block, uncomment the network.host and http.port lines.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;network.host: localhost&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;http.port: 9200&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Now edit the elasticsearch service file for the memory lock mlockall configuration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /usr/lib/systemd/system/elasticsearch.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment LimitMEMLOCK line.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;LimitMEMLOCK=infinity&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit.&lt;br /&gt;
&lt;br /&gt;
Edit the default configuration for Elasticsearch in the /etc/default directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano /etc/default/elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment line 60 and make sure the value is &#039;unlimited&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;MAX_LOCKED_MEMORY=unlimited&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
The Elasticsearch configuration is finished. Elasticsearch will run under localhost IP address with port 9200 and we disabled swap memory by enabling mlockall on the Ubuntu server.&lt;br /&gt;
&lt;br /&gt;
Reload the Elasticsearch service file and enable it to run on the boot time, then start the service.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl daemon-reload&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable elasticsearch&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start elasticsearch&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Wait a sec for Elasticsearch to run, then check the open port on the server, make sure the &#039;state&#039; for port 9200 is &#039;LISTEN&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;netstat -plntu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then check the memory lock to ensure that mlockall is enabled. Also check that Elasticsearch is running with the commands below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
curl -XGET &#039;localhost:9200/_nodes?filter_path=**.mlockall&amp;amp;pretty&#039;&lt;br /&gt;
&lt;br /&gt;
curl -XGET &#039;localhost:9200/?pretty&#039;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see the results below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Step 3 - Install and Configure Kibana with Nginx ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Kibana behind a Nginx web server. Kibana will listen on the localhost IP address only and Nginx acts as the reverse proxy for the Kibana application.&lt;br /&gt;
&lt;br /&gt;
Install Kibana with this apt command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y kibana&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the kibana.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /etc/kibana/kibana.yml&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment the server.port, server.hos and elasticsearch.url lines.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
server.port: 5601&lt;br /&gt;
&lt;br /&gt;
server.host: &amp;quot;localhost&amp;quot;&lt;br /&gt;
&lt;br /&gt;
elasticsearch.url: &amp;quot;http://localhost:9200&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Add Kibana to run at boot and start it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl enable kibana&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start kibana&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana will run on port 5601 as node application.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
netstat -plntu&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana installation is done, now we need to install Nginx and configure it as a reverse proxy to be able to access Kibana from the public IP address.&lt;br /&gt;
&lt;br /&gt;
Next, install the Nginx and apache2-utils packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo apt-get install -y nginx apache2-utils&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Apache2-utils is a package that contains tools for the webserver that work with Nginx as well, we will use htpasswd basic authentication for Kibana.&lt;br /&gt;
&lt;br /&gt;
Nginx has been installed. Now we need to create a new virtual host configuration file in the Nginx sites-available directory. Create a new file &#039;kibana&#039; with nano.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/nginx/&lt;br /&gt;
vim sites-available/kibana&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
    listen 80;&lt;br /&gt;
 &lt;br /&gt;
    server_name elk-stack.co;&lt;br /&gt;
 &lt;br /&gt;
    auth_basic &amp;quot;Restricted Access&amp;quot;;&lt;br /&gt;
    auth_basic_user_file /etc/nginx/.kibana-user;&lt;br /&gt;
 &lt;br /&gt;
    location / {&lt;br /&gt;
        proxy_pass http://localhost:5601;&lt;br /&gt;
        proxy_http_version 1.1;&lt;br /&gt;
        proxy_set_header Upgrade $http_upgrade;&lt;br /&gt;
        proxy_set_header Connection &#039;upgrade&#039;;&lt;br /&gt;
        proxy_set_header Host $host;&lt;br /&gt;
        proxy_cache_bypass $http_upgrade;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano&lt;br /&gt;
&lt;br /&gt;
Create a new basic authentication file with the htpasswd command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo htpasswd -c /etc/nginx/.kibana-user admin&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
TYPE YOUR PASSWORD&lt;br /&gt;
&lt;br /&gt;
Activate the kibana virtual host by creating a symbolic link from the kibana file in &#039;sites-available&#039; to the &#039;sites-enabled&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ln -s /etc/nginx/sites-available/kibana /etc/nginx/sites-enabled/ &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Test the nginx configuration and make sure there is no error, then add nginx to run at boot time and restart nginx.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
nginx -t&lt;br /&gt;
&lt;br /&gt;
systemctl enable nginx&lt;br /&gt;
&lt;br /&gt;
systemctl restart nginx&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Step 4 - Install and Configure Logstash == &lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Logsatash to centralize server logs from client sources with filebeat, then filter and transform all data (Syslog) and transport it to the stash (Elasticsearch).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install Logstash 5 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y logstash&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Edit the hosts file with nano.&lt;br /&gt;
&lt;br /&gt;
nano /etc/hosts&lt;br /&gt;
&lt;br /&gt;
Add the server IP address and hostname.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;10.0.2.15    elk-master&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the hosts file and exit the editor.&lt;br /&gt;
&lt;br /&gt;
Now generate a new SSL certificate file with OpenSSL so the client sources can identify the elastic server.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/logstash/&lt;br /&gt;
&lt;br /&gt;
openssl req -subj /CN=elk-master -x509 -days 3650 -batch -nodes -newkey rsa:4096 -keyout logstash.key -out logstash.crt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change the &#039;/CN&#039; value to the elastic server hostname.&lt;br /&gt;
&lt;br /&gt;
Certificate files will be created in the &#039;/etc/logstash/&#039; directory.&lt;br /&gt;
&lt;br /&gt;
Next, we will create the configuration files for logstash. We will create a configuration file &#039;filebeat-input.conf&#039; as input file from filebeat, &#039;syslog-filter.conf&#039; for syslog processing, and then a &#039;output-elasticsearch.conf&#039; file to define the Elasticsearch output.&lt;br /&gt;
&lt;br /&gt;
Go to the logstash configuration directory and create the new configuration files in the &#039;conf.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/logstash/&lt;br /&gt;
&lt;br /&gt;
nano conf.d/filebeat-input.conf&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Input configuration, paste configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input {&lt;br /&gt;
  beats {&lt;br /&gt;
    port =&amp;gt; 5443&lt;br /&gt;
    type =&amp;gt; syslog&lt;br /&gt;
    ssl =&amp;gt; true&lt;br /&gt;
    ssl_certificate =&amp;gt; &amp;quot;/etc/logstash/logstash.crt&amp;quot;&lt;br /&gt;
    ssl_key =&amp;gt; &amp;quot;/etc/logstash/logstash.key&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Create the syslog-filter.conf file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano conf.d/syslog-filter.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
filter {&lt;br /&gt;
  if [type] == &amp;quot;syslog&amp;quot; {&lt;br /&gt;
    grok {&lt;br /&gt;
      match =&amp;gt; { &amp;quot;message&amp;quot; =&amp;gt; &amp;quot;%{SYSLOGTIMESTAMP:syslog_timestamp} %{SYSLOGHOST:syslog_hostname} %{DATA:syslog_program}(?:\[%{POSINT:syslog_pid}\])?: %{GREEDYDATA:syslog_message}&amp;quot; }&lt;br /&gt;
      add_field =&amp;gt; [ &amp;quot;received_at&amp;quot;, &amp;quot;%{@timestamp}&amp;quot; ]&lt;br /&gt;
      add_field =&amp;gt; [ &amp;quot;received_from&amp;quot;, &amp;quot;%{host}&amp;quot; ]&lt;br /&gt;
    }&lt;br /&gt;
    date {&lt;br /&gt;
      match =&amp;gt; [ &amp;quot;syslog_timestamp&amp;quot;, &amp;quot;MMM  d HH:mm:ss&amp;quot;, &amp;quot;MMM dd HH:mm:ss&amp;quot; ]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We use a filter plugin named &#039;grok&#039; to parse the syslog files.&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Create the output configuration file &#039;output-elasticsearch.conf&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano conf.d/output-elasticsearch.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
output {&lt;br /&gt;
  elasticsearch { hosts =&amp;gt; [&amp;quot;localhost:9200&amp;quot;]&lt;br /&gt;
    hosts =&amp;gt; &amp;quot;localhost:9200&amp;quot;&lt;br /&gt;
    manage_template =&amp;gt; false&lt;br /&gt;
    index =&amp;gt; &amp;quot;%{[@metadata][beat]}-%{+YYYY.MM.dd}&amp;quot;&lt;br /&gt;
    document_type =&amp;gt; &amp;quot;%{[@metadata][type]}&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
When this is done, add logstash to start at boot time and start the service.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable logstash&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start logstash&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mdhasan</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123792</id>
		<title>Logging and monitoring with Elastic stack on Ubuntu 16.04</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123792"/>
		<updated>2017-06-21T16:30:37Z</updated>

		<summary type="html">&lt;p&gt;Mdhasan: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
&#039;&#039;&#039;Elasticsearch&#039;&#039;&#039; is an open source search engine based on Lucene, developed in java. It provides a distributed and multitenant [https://en.wikipedia.org/wiki/Full-text_search full-text search engine] with an HTTP Dashboard web-interface (Kibana) and JSON documents scheme. Elasticsearch is a scalable search engine that can be used to search for all types of documents, including log file. Elasticsearch is the heart of the &#039;Elastic Stack&#039; or ELK Stack.&amp;lt;ref&amp;gt;[https://www.elastic.co/products/elasticsearch] Elastic Search Homepage&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Logstash&#039;&#039;&#039; is an open source, server-side data processing pipeline that ingests data from a multitude of sources simultaneously, transforms it, and then sends it to Elasticsearch.&amp;lt;ref&amp;gt;[https://www.elastic.co/products/logstash] Logstash homepahe&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Kibana&#039;&#039;&#039; is a data visualization interface for Elasticsearch. Kibana provides a pretty dashboard (web interfaces), it allows you to manage and visualize all data from Elasticsearch on your own. &amp;lt;ref&amp;gt;[https://www.elastic.co/products/kibana] kibana homepage&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this HOW TO, I will show you how to install and configure Elastic Stack on a single Ubuntu 16.04 server for monitoring server logs and how to install &#039;Elastic beats&#039; on client PCs with Ubuntu 16.04.&lt;br /&gt;
&lt;br /&gt;
== Prerequisite ==&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit server with 4GB of RAM, hostname - elk-master&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit client with 1 GB of RAM, hostname - elk-client1&lt;br /&gt;
&lt;br /&gt;
== Step 1 - Install Java ==&lt;br /&gt;
&lt;br /&gt;
Java is required for the Elastic stack deployment. Elasticsearch requires Java 8. It is recommended to use the Oracle JDK 1.8. We will install Java 8 from a PPA repository.&lt;br /&gt;
&lt;br /&gt;
Install the new package &#039;&#039;&#039;&#039;python-software-properties&#039;&#039;&#039;&#039; so we can add a new repository easily with an apt command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y python-software-properties software-properties-common apt-transport-https&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the new Java 8 PPA repository with the &#039;add-apt-repository&#039; command, then update the repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo add-apt-repository ppa:webupd8team/java -y &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install Java 8 from the PPA webpub8 repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y oracle-java8-installer&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 2 - Install and Configure Elasticsearch ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Elasticsearch. Install Elasticsearch from the elastic repository and configure it to run on the localhost IP.&lt;br /&gt;
&lt;br /&gt;
Before installing Elasticsearch, add the elastic repository key to the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add - &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add elastic 5.x repository to the &#039;sources.list.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; echo &amp;quot;deb https://artifacts.elastic.co/packages/5.x/apt stable main&amp;quot; | sudo tee -a /etc/apt/sources.list.d/elastic-5.x.list &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Update the repository and install Elasticsearch 5.1 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Elasticsearch is installed. Now go to the configuration directory and edit the elasticsaerch.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; cd /etc/elasticsearch/ &amp;lt;code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano elasticsearch.yml &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enable memory lock for Elasticsearch by removing the comment on line 43. We do this to disable swapping memory for Elasticsearchto avoid overloading the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; bootstrap.memory_lock: true &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the &#039;Network&#039; block, uncomment the network.host and http.port lines.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;network.host: localhost&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;http.port: 9200&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Now edit the elasticsearch service file for the memory lock mlockall configuration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /usr/lib/systemd/system/elasticsearch.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment LimitMEMLOCK line.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;LimitMEMLOCK=infinity&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit.&lt;br /&gt;
&lt;br /&gt;
Edit the default configuration for Elasticsearch in the /etc/default directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano /etc/default/elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment line 60 and make sure the value is &#039;unlimited&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;MAX_LOCKED_MEMORY=unlimited&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
The Elasticsearch configuration is finished. Elasticsearch will run under localhost IP address with port 9200 and we disabled swap memory by enabling mlockall on the Ubuntu server.&lt;br /&gt;
&lt;br /&gt;
Reload the Elasticsearch service file and enable it to run on the boot time, then start the service.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl daemon-reload&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable elasticsearch&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start elasticsearch&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Wait a sec for Elasticsearch to run, then check the open port on the server, make sure the &#039;state&#039; for port 9200 is &#039;LISTEN&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;netstat -plntu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then check the memory lock to ensure that mlockall is enabled. Also check that Elasticsearch is running with the commands below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
curl -XGET &#039;localhost:9200/_nodes?filter_path=**.mlockall&amp;amp;pretty&#039;&lt;br /&gt;
&lt;br /&gt;
curl -XGET &#039;localhost:9200/?pretty&#039;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see the results below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Step 3 - Install and Configure Kibana with Nginx ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Kibana behind a Nginx web server. Kibana will listen on the localhost IP address only and Nginx acts as the reverse proxy for the Kibana application.&lt;br /&gt;
&lt;br /&gt;
Install Kibana with this apt command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y kibana&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the kibana.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /etc/kibana/kibana.yml&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment the server.port, server.hos and elasticsearch.url lines.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
server.port: 5601&lt;br /&gt;
&lt;br /&gt;
server.host: &amp;quot;localhost&amp;quot;&lt;br /&gt;
&lt;br /&gt;
elasticsearch.url: &amp;quot;http://localhost:9200&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Add Kibana to run at boot and start it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl enable kibana&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start kibana&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana will run on port 5601 as node application.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
netstat -plntu&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana installation is done, now we need to install Nginx and configure it as a reverse proxy to be able to access Kibana from the public IP address.&lt;br /&gt;
&lt;br /&gt;
Next, install the Nginx and apache2-utils packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo apt-get install -y nginx apache2-utils&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Apache2-utils is a package that contains tools for the webserver that work with Nginx as well, we will use htpasswd basic authentication for Kibana.&lt;br /&gt;
&lt;br /&gt;
Nginx has been installed. Now we need to create a new virtual host configuration file in the Nginx sites-available directory. Create a new file &#039;kibana&#039; with nano.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/nginx/&lt;br /&gt;
vim sites-available/kibana&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
    listen 80;&lt;br /&gt;
 &lt;br /&gt;
    server_name elk-stack.co;&lt;br /&gt;
 &lt;br /&gt;
    auth_basic &amp;quot;Restricted Access&amp;quot;;&lt;br /&gt;
    auth_basic_user_file /etc/nginx/.kibana-user;&lt;br /&gt;
 &lt;br /&gt;
    location / {&lt;br /&gt;
        proxy_pass http://localhost:5601;&lt;br /&gt;
        proxy_http_version 1.1;&lt;br /&gt;
        proxy_set_header Upgrade $http_upgrade;&lt;br /&gt;
        proxy_set_header Connection &#039;upgrade&#039;;&lt;br /&gt;
        proxy_set_header Host $host;&lt;br /&gt;
        proxy_cache_bypass $http_upgrade;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano&lt;br /&gt;
&lt;br /&gt;
Create a new basic authentication file with the htpasswd command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo htpasswd -c /etc/nginx/.kibana-user admin&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
TYPE YOUR PASSWORD&lt;br /&gt;
&lt;br /&gt;
Activate the kibana virtual host by creating a symbolic link from the kibana file in &#039;sites-available&#039; to the &#039;sites-enabled&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ln -s /etc/nginx/sites-available/kibana /etc/nginx/sites-enabled/ &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Test the nginx configuration and make sure there is no error, then add nginx to run at boot time and restart nginx.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
nginx -t&lt;br /&gt;
&lt;br /&gt;
systemctl enable nginx&lt;br /&gt;
&lt;br /&gt;
systemctl restart nginx&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Step 4 - Install and Configure Logstash == &lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Logsatash to centralize server logs from client sources with filebeat, then filter and transform all data (Syslog) and transport it to the stash (Elasticsearch).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install Logstash 5 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y logstash&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Edit the hosts file with nano.&lt;br /&gt;
&lt;br /&gt;
nano /etc/hosts&lt;br /&gt;
&lt;br /&gt;
Add the server IP address and hostname.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;10.0.2.15    elk-master&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the hosts file and exit the editor.&lt;br /&gt;
&lt;br /&gt;
Now generate a new SSL certificate file with OpenSSL so the client sources can identify the elastic server.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/logstash/&lt;br /&gt;
&lt;br /&gt;
openssl req -subj /CN=elk-master -x509 -days 3650 -batch -nodes -newkey rsa:4096 -keyout logstash.key -out logstash.crt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change the &#039;/CN&#039; value to the elastic server hostname.&lt;br /&gt;
&lt;br /&gt;
Certificate files will be created in the &#039;/etc/logstash/&#039; directory.&lt;br /&gt;
&lt;br /&gt;
Next, we will create the configuration files for logstash. We will create a configuration file &#039;filebeat-input.conf&#039; as input file from filebeat, &#039;syslog-filter.conf&#039; for syslog processing, and then a &#039;output-elasticsearch.conf&#039; file to define the Elasticsearch output.&lt;br /&gt;
&lt;br /&gt;
Go to the logstash configuration directory and create the new configuration files in the &#039;conf.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/logstash/&lt;br /&gt;
&lt;br /&gt;
nano conf.d/filebeat-input.conf&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Input configuration, paste configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input {&lt;br /&gt;
  beats {&lt;br /&gt;
    port =&amp;gt; 5443&lt;br /&gt;
    type =&amp;gt; syslog&lt;br /&gt;
    ssl =&amp;gt; true&lt;br /&gt;
    ssl_certificate =&amp;gt; &amp;quot;/etc/logstash/logstash.crt&amp;quot;&lt;br /&gt;
    ssl_key =&amp;gt; &amp;quot;/etc/logstash/logstash.key&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Create the syslog-filter.conf file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano conf.d/syslog-filter.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
filter {&lt;br /&gt;
  if [type] == &amp;quot;syslog&amp;quot; {&lt;br /&gt;
    grok {&lt;br /&gt;
      match =&amp;gt; { &amp;quot;message&amp;quot; =&amp;gt; &amp;quot;%{SYSLOGTIMESTAMP:syslog_timestamp} %{SYSLOGHOST:syslog_hostname} %{DATA:syslog_program}(?:\[%{POSINT:syslog_pid}\])?: %{GREEDYDATA:syslog_message}&amp;quot; }&lt;br /&gt;
      add_field =&amp;gt; [ &amp;quot;received_at&amp;quot;, &amp;quot;%{@timestamp}&amp;quot; ]&lt;br /&gt;
      add_field =&amp;gt; [ &amp;quot;received_from&amp;quot;, &amp;quot;%{host}&amp;quot; ]&lt;br /&gt;
    }&lt;br /&gt;
    date {&lt;br /&gt;
      match =&amp;gt; [ &amp;quot;syslog_timestamp&amp;quot;, &amp;quot;MMM  d HH:mm:ss&amp;quot;, &amp;quot;MMM dd HH:mm:ss&amp;quot; ]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We use a filter plugin named &#039;grok&#039; to parse the syslog files.&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Create the output configuration file &#039;output-elasticsearch.conf&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano conf.d/output-elasticsearch.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
output {&lt;br /&gt;
  elasticsearch { hosts =&amp;gt; [&amp;quot;localhost:9200&amp;quot;]&lt;br /&gt;
    hosts =&amp;gt; &amp;quot;localhost:9200&amp;quot;&lt;br /&gt;
    manage_template =&amp;gt; false&lt;br /&gt;
    index =&amp;gt; &amp;quot;%{[@metadata][beat]}-%{+YYYY.MM.dd}&amp;quot;&lt;br /&gt;
    document_type =&amp;gt; &amp;quot;%{[@metadata][type]}&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
When this is done, add logstash to start at boot time and start the service.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable logstash&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start logstash&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mdhasan</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123791</id>
		<title>Logging and monitoring with Elastic stack on Ubuntu 16.04</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123791"/>
		<updated>2017-06-21T16:29:58Z</updated>

		<summary type="html">&lt;p&gt;Mdhasan: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
Elasticsearch is an open source search engine based on Lucene, developed in java. It provides a distributed and multitenant [https://en.wikipedia.org/wiki/Full-text_search full-text search engine] with an HTTP Dashboard web-interface (Kibana) and JSON documents scheme. Elasticsearch is a scalable search engine that can be used to search for all types of documents, including log file. Elasticsearch is the heart of the &#039;Elastic Stack&#039; or ELK Stack.&amp;lt;ref&amp;gt;[https://www.elastic.co/products/elasticsearch] Elastic Search Homepage&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Logstash is an open source, server-side data processing pipeline that ingests data from a multitude of sources simultaneously, transforms it, and then sends it to Elasticsearch.&amp;lt;ref&amp;gt;[https://www.elastic.co/products/logstash] Logstash homepahe&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana is a data visualization interface for Elasticsearch. Kibana provides a pretty dashboard (web interfaces), it allows you to manage and visualize all data from Elasticsearch on your own. &amp;lt;ref&amp;gt;[https://www.elastic.co/products/kibana] kibana homepage&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this HOW TO, I will show you how to install and configure Elastic Stack on a single Ubuntu 16.04 server for monitoring server logs and how to install &#039;Elastic beats&#039; on client PCs with Ubuntu 16.04 and CentOS 7 operating system.&lt;br /&gt;
&lt;br /&gt;
== Prerequisite ==&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit server with 4GB of RAM, hostname - elk-master&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit client with 1 GB of RAM, hostname - elk-client1&lt;br /&gt;
&lt;br /&gt;
== Step 1 - Install Java ==&lt;br /&gt;
&lt;br /&gt;
Java is required for the Elastic stack deployment. Elasticsearch requires Java 8. It is recommended to use the Oracle JDK 1.8. We will install Java 8 from a PPA repository.&lt;br /&gt;
&lt;br /&gt;
Install the new package &#039;&#039;&#039;&#039;python-software-properties&#039;&#039;&#039;&#039; so we can add a new repository easily with an apt command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y python-software-properties software-properties-common apt-transport-https&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the new Java 8 PPA repository with the &#039;add-apt-repository&#039; command, then update the repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo add-apt-repository ppa:webupd8team/java -y &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install Java 8 from the PPA webpub8 repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y oracle-java8-installer&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 2 - Install and Configure Elasticsearch ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Elasticsearch. Install Elasticsearch from the elastic repository and configure it to run on the localhost IP.&lt;br /&gt;
&lt;br /&gt;
Before installing Elasticsearch, add the elastic repository key to the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add - &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add elastic 5.x repository to the &#039;sources.list.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; echo &amp;quot;deb https://artifacts.elastic.co/packages/5.x/apt stable main&amp;quot; | sudo tee -a /etc/apt/sources.list.d/elastic-5.x.list &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Update the repository and install Elasticsearch 5.1 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Elasticsearch is installed. Now go to the configuration directory and edit the elasticsaerch.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; cd /etc/elasticsearch/ &amp;lt;code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano elasticsearch.yml &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enable memory lock for Elasticsearch by removing the comment on line 43. We do this to disable swapping memory for Elasticsearchto avoid overloading the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; bootstrap.memory_lock: true &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the &#039;Network&#039; block, uncomment the network.host and http.port lines.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;network.host: localhost&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;http.port: 9200&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Now edit the elasticsearch service file for the memory lock mlockall configuration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /usr/lib/systemd/system/elasticsearch.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment LimitMEMLOCK line.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;LimitMEMLOCK=infinity&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit.&lt;br /&gt;
&lt;br /&gt;
Edit the default configuration for Elasticsearch in the /etc/default directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano /etc/default/elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment line 60 and make sure the value is &#039;unlimited&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;MAX_LOCKED_MEMORY=unlimited&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
The Elasticsearch configuration is finished. Elasticsearch will run under localhost IP address with port 9200 and we disabled swap memory by enabling mlockall on the Ubuntu server.&lt;br /&gt;
&lt;br /&gt;
Reload the Elasticsearch service file and enable it to run on the boot time, then start the service.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl daemon-reload&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable elasticsearch&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start elasticsearch&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Wait a sec for Elasticsearch to run, then check the open port on the server, make sure the &#039;state&#039; for port 9200 is &#039;LISTEN&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;netstat -plntu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then check the memory lock to ensure that mlockall is enabled. Also check that Elasticsearch is running with the commands below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
curl -XGET &#039;localhost:9200/_nodes?filter_path=**.mlockall&amp;amp;pretty&#039;&lt;br /&gt;
&lt;br /&gt;
curl -XGET &#039;localhost:9200/?pretty&#039;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see the results below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Step 3 - Install and Configure Kibana with Nginx ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Kibana behind a Nginx web server. Kibana will listen on the localhost IP address only and Nginx acts as the reverse proxy for the Kibana application.&lt;br /&gt;
&lt;br /&gt;
Install Kibana with this apt command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y kibana&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the kibana.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /etc/kibana/kibana.yml&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment the server.port, server.hos and elasticsearch.url lines.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
server.port: 5601&lt;br /&gt;
&lt;br /&gt;
server.host: &amp;quot;localhost&amp;quot;&lt;br /&gt;
&lt;br /&gt;
elasticsearch.url: &amp;quot;http://localhost:9200&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Add Kibana to run at boot and start it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl enable kibana&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start kibana&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana will run on port 5601 as node application.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
netstat -plntu&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana installation is done, now we need to install Nginx and configure it as a reverse proxy to be able to access Kibana from the public IP address.&lt;br /&gt;
&lt;br /&gt;
Next, install the Nginx and apache2-utils packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo apt-get install -y nginx apache2-utils&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Apache2-utils is a package that contains tools for the webserver that work with Nginx as well, we will use htpasswd basic authentication for Kibana.&lt;br /&gt;
&lt;br /&gt;
Nginx has been installed. Now we need to create a new virtual host configuration file in the Nginx sites-available directory. Create a new file &#039;kibana&#039; with nano.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/nginx/&lt;br /&gt;
vim sites-available/kibana&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
    listen 80;&lt;br /&gt;
 &lt;br /&gt;
    server_name elk-stack.co;&lt;br /&gt;
 &lt;br /&gt;
    auth_basic &amp;quot;Restricted Access&amp;quot;;&lt;br /&gt;
    auth_basic_user_file /etc/nginx/.kibana-user;&lt;br /&gt;
 &lt;br /&gt;
    location / {&lt;br /&gt;
        proxy_pass http://localhost:5601;&lt;br /&gt;
        proxy_http_version 1.1;&lt;br /&gt;
        proxy_set_header Upgrade $http_upgrade;&lt;br /&gt;
        proxy_set_header Connection &#039;upgrade&#039;;&lt;br /&gt;
        proxy_set_header Host $host;&lt;br /&gt;
        proxy_cache_bypass $http_upgrade;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano&lt;br /&gt;
&lt;br /&gt;
Create a new basic authentication file with the htpasswd command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo htpasswd -c /etc/nginx/.kibana-user admin&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
TYPE YOUR PASSWORD&lt;br /&gt;
&lt;br /&gt;
Activate the kibana virtual host by creating a symbolic link from the kibana file in &#039;sites-available&#039; to the &#039;sites-enabled&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ln -s /etc/nginx/sites-available/kibana /etc/nginx/sites-enabled/ &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Test the nginx configuration and make sure there is no error, then add nginx to run at boot time and restart nginx.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
nginx -t&lt;br /&gt;
&lt;br /&gt;
systemctl enable nginx&lt;br /&gt;
&lt;br /&gt;
systemctl restart nginx&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Step 4 - Install and Configure Logstash == &lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Logsatash to centralize server logs from client sources with filebeat, then filter and transform all data (Syslog) and transport it to the stash (Elasticsearch).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install Logstash 5 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y logstash&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Edit the hosts file with nano.&lt;br /&gt;
&lt;br /&gt;
nano /etc/hosts&lt;br /&gt;
&lt;br /&gt;
Add the server IP address and hostname.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;10.0.2.15    elk-master&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the hosts file and exit the editor.&lt;br /&gt;
&lt;br /&gt;
Now generate a new SSL certificate file with OpenSSL so the client sources can identify the elastic server.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/logstash/&lt;br /&gt;
&lt;br /&gt;
openssl req -subj /CN=elk-master -x509 -days 3650 -batch -nodes -newkey rsa:4096 -keyout logstash.key -out logstash.crt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change the &#039;/CN&#039; value to the elastic server hostname.&lt;br /&gt;
&lt;br /&gt;
Certificate files will be created in the &#039;/etc/logstash/&#039; directory.&lt;br /&gt;
&lt;br /&gt;
Next, we will create the configuration files for logstash. We will create a configuration file &#039;filebeat-input.conf&#039; as input file from filebeat, &#039;syslog-filter.conf&#039; for syslog processing, and then a &#039;output-elasticsearch.conf&#039; file to define the Elasticsearch output.&lt;br /&gt;
&lt;br /&gt;
Go to the logstash configuration directory and create the new configuration files in the &#039;conf.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/logstash/&lt;br /&gt;
&lt;br /&gt;
nano conf.d/filebeat-input.conf&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Input configuration, paste configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input {&lt;br /&gt;
  beats {&lt;br /&gt;
    port =&amp;gt; 5443&lt;br /&gt;
    type =&amp;gt; syslog&lt;br /&gt;
    ssl =&amp;gt; true&lt;br /&gt;
    ssl_certificate =&amp;gt; &amp;quot;/etc/logstash/logstash.crt&amp;quot;&lt;br /&gt;
    ssl_key =&amp;gt; &amp;quot;/etc/logstash/logstash.key&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Create the syslog-filter.conf file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano conf.d/syslog-filter.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
filter {&lt;br /&gt;
  if [type] == &amp;quot;syslog&amp;quot; {&lt;br /&gt;
    grok {&lt;br /&gt;
      match =&amp;gt; { &amp;quot;message&amp;quot; =&amp;gt; &amp;quot;%{SYSLOGTIMESTAMP:syslog_timestamp} %{SYSLOGHOST:syslog_hostname} %{DATA:syslog_program}(?:\[%{POSINT:syslog_pid}\])?: %{GREEDYDATA:syslog_message}&amp;quot; }&lt;br /&gt;
      add_field =&amp;gt; [ &amp;quot;received_at&amp;quot;, &amp;quot;%{@timestamp}&amp;quot; ]&lt;br /&gt;
      add_field =&amp;gt; [ &amp;quot;received_from&amp;quot;, &amp;quot;%{host}&amp;quot; ]&lt;br /&gt;
    }&lt;br /&gt;
    date {&lt;br /&gt;
      match =&amp;gt; [ &amp;quot;syslog_timestamp&amp;quot;, &amp;quot;MMM  d HH:mm:ss&amp;quot;, &amp;quot;MMM dd HH:mm:ss&amp;quot; ]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We use a filter plugin named &#039;grok&#039; to parse the syslog files.&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Create the output configuration file &#039;output-elasticsearch.conf&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano conf.d/output-elasticsearch.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
output {&lt;br /&gt;
  elasticsearch { hosts =&amp;gt; [&amp;quot;localhost:9200&amp;quot;]&lt;br /&gt;
    hosts =&amp;gt; &amp;quot;localhost:9200&amp;quot;&lt;br /&gt;
    manage_template =&amp;gt; false&lt;br /&gt;
    index =&amp;gt; &amp;quot;%{[@metadata][beat]}-%{+YYYY.MM.dd}&amp;quot;&lt;br /&gt;
    document_type =&amp;gt; &amp;quot;%{[@metadata][type]}&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
When this is done, add logstash to start at boot time and start the service.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable logstash&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start logstash&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mdhasan</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123790</id>
		<title>Logging and monitoring with Elastic stack on Ubuntu 16.04</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123790"/>
		<updated>2017-06-21T16:25:28Z</updated>

		<summary type="html">&lt;p&gt;Mdhasan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
Elasticsearch is an open source search engine based on Lucene, developed in java. It provides a distributed and multitenant [https://en.wikipedia.org/wiki/Full-text_search full-text search engine] with an HTTP Dashboard web-interface (Kibana) and JSON documents scheme. Elasticsearch is a scalable search engine that can be used to search for all types of documents, including log file. Elasticsearch is the heart of the &#039;Elastic Stack&#039; or ELK Stack.&amp;lt;ref&amp;gt;[https://www.elastic.co/products/elasticsearch] Elastic Search Homepage&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Logstash is an open source tool for managing system events and logs. It provides real-time pipelining to collect data. Logstash will collect the log or data, convert all data into JSON documents, and store them in Elasticsearch.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Kibana is a data visualization interface for Elasticsearch. Kibana provides a pretty dashboard (web interfaces), it allows you to manage and visualize all data from Elasticsearch on your own. It&#039;s not just beautiful, but also powerful.&lt;br /&gt;
&lt;br /&gt;
In this HOW TO, I will show you how to install and configure Elastic Stack on a single Ubuntu 16.04 server for monitoring server logs and how to install &#039;Elastic beats&#039; on client PCs with Ubuntu 16.04 and CentOS 7 operating system.&lt;br /&gt;
&lt;br /&gt;
== Prerequisite ==&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit server with 4GB of RAM, hostname - elk-master&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit client with 1 GB of RAM, hostname - elk-client1&lt;br /&gt;
&lt;br /&gt;
== Step 1 - Install Java ==&lt;br /&gt;
&lt;br /&gt;
Java is required for the Elastic stack deployment. Elasticsearch requires Java 8. It is recommended to use the Oracle JDK 1.8. We will install Java 8 from a PPA repository.&lt;br /&gt;
&lt;br /&gt;
Install the new package &#039;&#039;&#039;&#039;python-software-properties&#039;&#039;&#039;&#039; so we can add a new repository easily with an apt command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y python-software-properties software-properties-common apt-transport-https&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the new Java 8 PPA repository with the &#039;add-apt-repository&#039; command, then update the repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo add-apt-repository ppa:webupd8team/java -y &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install Java 8 from the PPA webpub8 repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y oracle-java8-installer&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 2 - Install and Configure Elasticsearch ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Elasticsearch. Install Elasticsearch from the elastic repository and configure it to run on the localhost IP.&lt;br /&gt;
&lt;br /&gt;
Before installing Elasticsearch, add the elastic repository key to the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add - &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add elastic 5.x repository to the &#039;sources.list.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; echo &amp;quot;deb https://artifacts.elastic.co/packages/5.x/apt stable main&amp;quot; | sudo tee -a /etc/apt/sources.list.d/elastic-5.x.list &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Update the repository and install Elasticsearch 5.1 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Elasticsearch is installed. Now go to the configuration directory and edit the elasticsaerch.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; cd /etc/elasticsearch/ &amp;lt;code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano elasticsearch.yml &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enable memory lock for Elasticsearch by removing the comment on line 43. We do this to disable swapping memory for Elasticsearchto avoid overloading the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; bootstrap.memory_lock: true &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the &#039;Network&#039; block, uncomment the network.host and http.port lines.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;network.host: localhost&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;http.port: 9200&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Now edit the elasticsearch service file for the memory lock mlockall configuration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /usr/lib/systemd/system/elasticsearch.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment LimitMEMLOCK line.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;LimitMEMLOCK=infinity&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit.&lt;br /&gt;
&lt;br /&gt;
Edit the default configuration for Elasticsearch in the /etc/default directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano /etc/default/elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment line 60 and make sure the value is &#039;unlimited&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;MAX_LOCKED_MEMORY=unlimited&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
The Elasticsearch configuration is finished. Elasticsearch will run under localhost IP address with port 9200 and we disabled swap memory by enabling mlockall on the Ubuntu server.&lt;br /&gt;
&lt;br /&gt;
Reload the Elasticsearch service file and enable it to run on the boot time, then start the service.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl daemon-reload&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable elasticsearch&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start elasticsearch&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Wait a sec for Elasticsearch to run, then check the open port on the server, make sure the &#039;state&#039; for port 9200 is &#039;LISTEN&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;netstat -plntu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then check the memory lock to ensure that mlockall is enabled. Also check that Elasticsearch is running with the commands below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
curl -XGET &#039;localhost:9200/_nodes?filter_path=**.mlockall&amp;amp;pretty&#039;&lt;br /&gt;
&lt;br /&gt;
curl -XGET &#039;localhost:9200/?pretty&#039;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see the results below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Step 3 - Install and Configure Kibana with Nginx ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Kibana behind a Nginx web server. Kibana will listen on the localhost IP address only and Nginx acts as the reverse proxy for the Kibana application.&lt;br /&gt;
&lt;br /&gt;
Install Kibana with this apt command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y kibana&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the kibana.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /etc/kibana/kibana.yml&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment the server.port, server.hos and elasticsearch.url lines.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
server.port: 5601&lt;br /&gt;
&lt;br /&gt;
server.host: &amp;quot;localhost&amp;quot;&lt;br /&gt;
&lt;br /&gt;
elasticsearch.url: &amp;quot;http://localhost:9200&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Add Kibana to run at boot and start it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl enable kibana&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start kibana&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana will run on port 5601 as node application.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
netstat -plntu&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana installation is done, now we need to install Nginx and configure it as a reverse proxy to be able to access Kibana from the public IP address.&lt;br /&gt;
&lt;br /&gt;
Next, install the Nginx and apache2-utils packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo apt-get install -y nginx apache2-utils&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Apache2-utils is a package that contains tools for the webserver that work with Nginx as well, we will use htpasswd basic authentication for Kibana.&lt;br /&gt;
&lt;br /&gt;
Nginx has been installed. Now we need to create a new virtual host configuration file in the Nginx sites-available directory. Create a new file &#039;kibana&#039; with nano.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/nginx/&lt;br /&gt;
vim sites-available/kibana&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
    listen 80;&lt;br /&gt;
 &lt;br /&gt;
    server_name elk-stack.co;&lt;br /&gt;
 &lt;br /&gt;
    auth_basic &amp;quot;Restricted Access&amp;quot;;&lt;br /&gt;
    auth_basic_user_file /etc/nginx/.kibana-user;&lt;br /&gt;
 &lt;br /&gt;
    location / {&lt;br /&gt;
        proxy_pass http://localhost:5601;&lt;br /&gt;
        proxy_http_version 1.1;&lt;br /&gt;
        proxy_set_header Upgrade $http_upgrade;&lt;br /&gt;
        proxy_set_header Connection &#039;upgrade&#039;;&lt;br /&gt;
        proxy_set_header Host $host;&lt;br /&gt;
        proxy_cache_bypass $http_upgrade;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano&lt;br /&gt;
&lt;br /&gt;
Create a new basic authentication file with the htpasswd command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo htpasswd -c /etc/nginx/.kibana-user admin&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
TYPE YOUR PASSWORD&lt;br /&gt;
&lt;br /&gt;
Activate the kibana virtual host by creating a symbolic link from the kibana file in &#039;sites-available&#039; to the &#039;sites-enabled&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ln -s /etc/nginx/sites-available/kibana /etc/nginx/sites-enabled/ &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Test the nginx configuration and make sure there is no error, then add nginx to run at boot time and restart nginx.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
nginx -t&lt;br /&gt;
&lt;br /&gt;
systemctl enable nginx&lt;br /&gt;
&lt;br /&gt;
systemctl restart nginx&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Step 4 - Install and Configure Logstash == &lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Logsatash to centralize server logs from client sources with filebeat, then filter and transform all data (Syslog) and transport it to the stash (Elasticsearch).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install Logstash 5 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y logstash&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Edit the hosts file with nano.&lt;br /&gt;
&lt;br /&gt;
nano /etc/hosts&lt;br /&gt;
&lt;br /&gt;
Add the server IP address and hostname.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;10.0.2.15    elk-master&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the hosts file and exit the editor.&lt;br /&gt;
&lt;br /&gt;
Now generate a new SSL certificate file with OpenSSL so the client sources can identify the elastic server.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/logstash/&lt;br /&gt;
&lt;br /&gt;
openssl req -subj /CN=elk-master -x509 -days 3650 -batch -nodes -newkey rsa:4096 -keyout logstash.key -out logstash.crt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change the &#039;/CN&#039; value to the elastic server hostname.&lt;br /&gt;
&lt;br /&gt;
Certificate files will be created in the &#039;/etc/logstash/&#039; directory.&lt;br /&gt;
&lt;br /&gt;
Next, we will create the configuration files for logstash. We will create a configuration file &#039;filebeat-input.conf&#039; as input file from filebeat, &#039;syslog-filter.conf&#039; for syslog processing, and then a &#039;output-elasticsearch.conf&#039; file to define the Elasticsearch output.&lt;br /&gt;
&lt;br /&gt;
Go to the logstash configuration directory and create the new configuration files in the &#039;conf.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/logstash/&lt;br /&gt;
&lt;br /&gt;
nano conf.d/filebeat-input.conf&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Input configuration, paste configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input {&lt;br /&gt;
  beats {&lt;br /&gt;
    port =&amp;gt; 5443&lt;br /&gt;
    type =&amp;gt; syslog&lt;br /&gt;
    ssl =&amp;gt; true&lt;br /&gt;
    ssl_certificate =&amp;gt; &amp;quot;/etc/logstash/logstash.crt&amp;quot;&lt;br /&gt;
    ssl_key =&amp;gt; &amp;quot;/etc/logstash/logstash.key&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Create the syslog-filter.conf file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano conf.d/syslog-filter.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
filter {&lt;br /&gt;
  if [type] == &amp;quot;syslog&amp;quot; {&lt;br /&gt;
    grok {&lt;br /&gt;
      match =&amp;gt; { &amp;quot;message&amp;quot; =&amp;gt; &amp;quot;%{SYSLOGTIMESTAMP:syslog_timestamp} %{SYSLOGHOST:syslog_hostname} %{DATA:syslog_program}(?:\[%{POSINT:syslog_pid}\])?: %{GREEDYDATA:syslog_message}&amp;quot; }&lt;br /&gt;
      add_field =&amp;gt; [ &amp;quot;received_at&amp;quot;, &amp;quot;%{@timestamp}&amp;quot; ]&lt;br /&gt;
      add_field =&amp;gt; [ &amp;quot;received_from&amp;quot;, &amp;quot;%{host}&amp;quot; ]&lt;br /&gt;
    }&lt;br /&gt;
    date {&lt;br /&gt;
      match =&amp;gt; [ &amp;quot;syslog_timestamp&amp;quot;, &amp;quot;MMM  d HH:mm:ss&amp;quot;, &amp;quot;MMM dd HH:mm:ss&amp;quot; ]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We use a filter plugin named &#039;grok&#039; to parse the syslog files.&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Create the output configuration file &#039;output-elasticsearch.conf&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano conf.d/output-elasticsearch.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
output {&lt;br /&gt;
  elasticsearch { hosts =&amp;gt; [&amp;quot;localhost:9200&amp;quot;]&lt;br /&gt;
    hosts =&amp;gt; &amp;quot;localhost:9200&amp;quot;&lt;br /&gt;
    manage_template =&amp;gt; false&lt;br /&gt;
    index =&amp;gt; &amp;quot;%{[@metadata][beat]}-%{+YYYY.MM.dd}&amp;quot;&lt;br /&gt;
    document_type =&amp;gt; &amp;quot;%{[@metadata][type]}&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
When this is done, add logstash to start at boot time and start the service.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable logstash&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start logstash&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mdhasan</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123789</id>
		<title>Logging and monitoring with Elastic stack on Ubuntu 16.04</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123789"/>
		<updated>2017-06-21T16:24:24Z</updated>

		<summary type="html">&lt;p&gt;Mdhasan: /* Introduction */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
Elasticsearch is an open source search engine based on Lucene, developed in java. It provides a distributed and multitenant full-text search engine with an HTTP Dashboard web-interface (Kibana) and JSON documents scheme. Elasticsearch is a scalable search engine that can be used to search for all types of documents, including log file. Elasticsearch is the heart of the &#039;Elastic Stack&#039; or ELK Stack.&amp;lt;ref&amp;gt;[https://www.elastic.co/products/elasticsearch] Elastic Search Homepage&amp;lt;/ref&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Logstash is an open source tool for managing system events and logs. It provides real-time pipelining to collect data. Logstash will collect the log or data, convert all data into JSON documents, and store them in Elasticsearch.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Kibana is a data visualization interface for Elasticsearch. Kibana provides a pretty dashboard (web interfaces), it allows you to manage and visualize all data from Elasticsearch on your own. It&#039;s not just beautiful, but also powerful.&lt;br /&gt;
&lt;br /&gt;
In this HOW TO, I will show you how to install and configure Elastic Stack on a single Ubuntu 16.04 server for monitoring server logs and how to install &#039;Elastic beats&#039; on client PCs with Ubuntu 16.04 and CentOS 7 operating system.&lt;br /&gt;
&lt;br /&gt;
== Prerequisite ==&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit server with 4GB of RAM, hostname - elk-master&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit client with 1 GB of RAM, hostname - elk-client1&lt;br /&gt;
&lt;br /&gt;
== Step 1 - Install Java ==&lt;br /&gt;
&lt;br /&gt;
Java is required for the Elastic stack deployment. Elasticsearch requires Java 8. It is recommended to use the Oracle JDK 1.8. We will install Java 8 from a PPA repository.&lt;br /&gt;
&lt;br /&gt;
Install the new package &#039;&#039;&#039;&#039;python-software-properties&#039;&#039;&#039;&#039; so we can add a new repository easily with an apt command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y python-software-properties software-properties-common apt-transport-https&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the new Java 8 PPA repository with the &#039;add-apt-repository&#039; command, then update the repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo add-apt-repository ppa:webupd8team/java -y &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install Java 8 from the PPA webpub8 repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y oracle-java8-installer&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 2 - Install and Configure Elasticsearch ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Elasticsearch. Install Elasticsearch from the elastic repository and configure it to run on the localhost IP.&lt;br /&gt;
&lt;br /&gt;
Before installing Elasticsearch, add the elastic repository key to the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add - &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add elastic 5.x repository to the &#039;sources.list.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; echo &amp;quot;deb https://artifacts.elastic.co/packages/5.x/apt stable main&amp;quot; | sudo tee -a /etc/apt/sources.list.d/elastic-5.x.list &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Update the repository and install Elasticsearch 5.1 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Elasticsearch is installed. Now go to the configuration directory and edit the elasticsaerch.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; cd /etc/elasticsearch/ &amp;lt;code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano elasticsearch.yml &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enable memory lock for Elasticsearch by removing the comment on line 43. We do this to disable swapping memory for Elasticsearchto avoid overloading the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; bootstrap.memory_lock: true &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the &#039;Network&#039; block, uncomment the network.host and http.port lines.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;network.host: localhost&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;http.port: 9200&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Now edit the elasticsearch service file for the memory lock mlockall configuration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /usr/lib/systemd/system/elasticsearch.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment LimitMEMLOCK line.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;LimitMEMLOCK=infinity&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit.&lt;br /&gt;
&lt;br /&gt;
Edit the default configuration for Elasticsearch in the /etc/default directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano /etc/default/elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment line 60 and make sure the value is &#039;unlimited&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;MAX_LOCKED_MEMORY=unlimited&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
The Elasticsearch configuration is finished. Elasticsearch will run under localhost IP address with port 9200 and we disabled swap memory by enabling mlockall on the Ubuntu server.&lt;br /&gt;
&lt;br /&gt;
Reload the Elasticsearch service file and enable it to run on the boot time, then start the service.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl daemon-reload&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable elasticsearch&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start elasticsearch&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Wait a sec for Elasticsearch to run, then check the open port on the server, make sure the &#039;state&#039; for port 9200 is &#039;LISTEN&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;netstat -plntu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then check the memory lock to ensure that mlockall is enabled. Also check that Elasticsearch is running with the commands below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
curl -XGET &#039;localhost:9200/_nodes?filter_path=**.mlockall&amp;amp;pretty&#039;&lt;br /&gt;
&lt;br /&gt;
curl -XGET &#039;localhost:9200/?pretty&#039;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see the results below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Step 3 - Install and Configure Kibana with Nginx ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Kibana behind a Nginx web server. Kibana will listen on the localhost IP address only and Nginx acts as the reverse proxy for the Kibana application.&lt;br /&gt;
&lt;br /&gt;
Install Kibana with this apt command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y kibana&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the kibana.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /etc/kibana/kibana.yml&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment the server.port, server.hos and elasticsearch.url lines.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
server.port: 5601&lt;br /&gt;
&lt;br /&gt;
server.host: &amp;quot;localhost&amp;quot;&lt;br /&gt;
&lt;br /&gt;
elasticsearch.url: &amp;quot;http://localhost:9200&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Add Kibana to run at boot and start it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl enable kibana&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start kibana&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana will run on port 5601 as node application.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
netstat -plntu&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana installation is done, now we need to install Nginx and configure it as a reverse proxy to be able to access Kibana from the public IP address.&lt;br /&gt;
&lt;br /&gt;
Next, install the Nginx and apache2-utils packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo apt-get install -y nginx apache2-utils&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Apache2-utils is a package that contains tools for the webserver that work with Nginx as well, we will use htpasswd basic authentication for Kibana.&lt;br /&gt;
&lt;br /&gt;
Nginx has been installed. Now we need to create a new virtual host configuration file in the Nginx sites-available directory. Create a new file &#039;kibana&#039; with nano.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/nginx/&lt;br /&gt;
vim sites-available/kibana&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
    listen 80;&lt;br /&gt;
 &lt;br /&gt;
    server_name elk-stack.co;&lt;br /&gt;
 &lt;br /&gt;
    auth_basic &amp;quot;Restricted Access&amp;quot;;&lt;br /&gt;
    auth_basic_user_file /etc/nginx/.kibana-user;&lt;br /&gt;
 &lt;br /&gt;
    location / {&lt;br /&gt;
        proxy_pass http://localhost:5601;&lt;br /&gt;
        proxy_http_version 1.1;&lt;br /&gt;
        proxy_set_header Upgrade $http_upgrade;&lt;br /&gt;
        proxy_set_header Connection &#039;upgrade&#039;;&lt;br /&gt;
        proxy_set_header Host $host;&lt;br /&gt;
        proxy_cache_bypass $http_upgrade;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano&lt;br /&gt;
&lt;br /&gt;
Create a new basic authentication file with the htpasswd command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo htpasswd -c /etc/nginx/.kibana-user admin&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
TYPE YOUR PASSWORD&lt;br /&gt;
&lt;br /&gt;
Activate the kibana virtual host by creating a symbolic link from the kibana file in &#039;sites-available&#039; to the &#039;sites-enabled&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ln -s /etc/nginx/sites-available/kibana /etc/nginx/sites-enabled/ &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Test the nginx configuration and make sure there is no error, then add nginx to run at boot time and restart nginx.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
nginx -t&lt;br /&gt;
&lt;br /&gt;
systemctl enable nginx&lt;br /&gt;
&lt;br /&gt;
systemctl restart nginx&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Step 4 - Install and Configure Logstash == &lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Logsatash to centralize server logs from client sources with filebeat, then filter and transform all data (Syslog) and transport it to the stash (Elasticsearch).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install Logstash 5 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y logstash&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Edit the hosts file with nano.&lt;br /&gt;
&lt;br /&gt;
nano /etc/hosts&lt;br /&gt;
&lt;br /&gt;
Add the server IP address and hostname.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;10.0.2.15    elk-master&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the hosts file and exit the editor.&lt;br /&gt;
&lt;br /&gt;
Now generate a new SSL certificate file with OpenSSL so the client sources can identify the elastic server.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/logstash/&lt;br /&gt;
&lt;br /&gt;
openssl req -subj /CN=elk-master -x509 -days 3650 -batch -nodes -newkey rsa:4096 -keyout logstash.key -out logstash.crt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change the &#039;/CN&#039; value to the elastic server hostname.&lt;br /&gt;
&lt;br /&gt;
Certificate files will be created in the &#039;/etc/logstash/&#039; directory.&lt;br /&gt;
&lt;br /&gt;
Next, we will create the configuration files for logstash. We will create a configuration file &#039;filebeat-input.conf&#039; as input file from filebeat, &#039;syslog-filter.conf&#039; for syslog processing, and then a &#039;output-elasticsearch.conf&#039; file to define the Elasticsearch output.&lt;br /&gt;
&lt;br /&gt;
Go to the logstash configuration directory and create the new configuration files in the &#039;conf.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/logstash/&lt;br /&gt;
&lt;br /&gt;
nano conf.d/filebeat-input.conf&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Input configuration, paste configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input {&lt;br /&gt;
  beats {&lt;br /&gt;
    port =&amp;gt; 5443&lt;br /&gt;
    type =&amp;gt; syslog&lt;br /&gt;
    ssl =&amp;gt; true&lt;br /&gt;
    ssl_certificate =&amp;gt; &amp;quot;/etc/logstash/logstash.crt&amp;quot;&lt;br /&gt;
    ssl_key =&amp;gt; &amp;quot;/etc/logstash/logstash.key&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Create the syslog-filter.conf file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano conf.d/syslog-filter.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
filter {&lt;br /&gt;
  if [type] == &amp;quot;syslog&amp;quot; {&lt;br /&gt;
    grok {&lt;br /&gt;
      match =&amp;gt; { &amp;quot;message&amp;quot; =&amp;gt; &amp;quot;%{SYSLOGTIMESTAMP:syslog_timestamp} %{SYSLOGHOST:syslog_hostname} %{DATA:syslog_program}(?:\[%{POSINT:syslog_pid}\])?: %{GREEDYDATA:syslog_message}&amp;quot; }&lt;br /&gt;
      add_field =&amp;gt; [ &amp;quot;received_at&amp;quot;, &amp;quot;%{@timestamp}&amp;quot; ]&lt;br /&gt;
      add_field =&amp;gt; [ &amp;quot;received_from&amp;quot;, &amp;quot;%{host}&amp;quot; ]&lt;br /&gt;
    }&lt;br /&gt;
    date {&lt;br /&gt;
      match =&amp;gt; [ &amp;quot;syslog_timestamp&amp;quot;, &amp;quot;MMM  d HH:mm:ss&amp;quot;, &amp;quot;MMM dd HH:mm:ss&amp;quot; ]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We use a filter plugin named &#039;grok&#039; to parse the syslog files.&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Create the output configuration file &#039;output-elasticsearch.conf&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano conf.d/output-elasticsearch.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
output {&lt;br /&gt;
  elasticsearch { hosts =&amp;gt; [&amp;quot;localhost:9200&amp;quot;]&lt;br /&gt;
    hosts =&amp;gt; &amp;quot;localhost:9200&amp;quot;&lt;br /&gt;
    manage_template =&amp;gt; false&lt;br /&gt;
    index =&amp;gt; &amp;quot;%{[@metadata][beat]}-%{+YYYY.MM.dd}&amp;quot;&lt;br /&gt;
    document_type =&amp;gt; &amp;quot;%{[@metadata][type]}&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
When this is done, add logstash to start at boot time and start the service.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable logstash&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start logstash&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mdhasan</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123777</id>
		<title>Logging and monitoring with Elastic stack on Ubuntu 16.04</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123777"/>
		<updated>2017-06-19T22:25:21Z</updated>

		<summary type="html">&lt;p&gt;Mdhasan: /* Prerequisite */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
Elasticsearch is an open source search engine based on Lucene, developed in java. It provides a distributed and multitenant full-text search engine with an HTTP Dashboard web-interface (Kibana) and JSON documents scheme. Elasticsearch is a scalable search engine that can be used to search for all types of documents, including log file. Elasticsearch is the heart of the &#039;Elastic Stack&#039; or ELK Stack.&lt;br /&gt;
&lt;br /&gt;
Logstash is an open source tool for managing system events and logs. It provides real-time pipelining to collect data. Logstash will collect the log or data, convert all data into JSON documents, and store them in Elasticsearch.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Kibana is a data visualization interface for Elasticsearch. Kibana provides a pretty dashboard (web interfaces), it allows you to manage and visualize all data from Elasticsearch on your own. It&#039;s not just beautiful, but also powerful.&lt;br /&gt;
&lt;br /&gt;
In this HOW TO, I will show you how to install and configure Elastic Stack on a single Ubuntu 16.04 server for monitoring server logs and how to install &#039;Elastic beats&#039; on client PCs with Ubuntu 16.04 and CentOS 7 operating system.&lt;br /&gt;
&lt;br /&gt;
== Prerequisite ==&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit server with 4GB of RAM, hostname - elk-master&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit client with 1 GB of RAM, hostname - elk-client1&lt;br /&gt;
&lt;br /&gt;
== Step 1 - Install Java ==&lt;br /&gt;
&lt;br /&gt;
Java is required for the Elastic stack deployment. Elasticsearch requires Java 8. It is recommended to use the Oracle JDK 1.8. We will install Java 8 from a PPA repository.&lt;br /&gt;
&lt;br /&gt;
Install the new package &#039;&#039;&#039;&#039;python-software-properties&#039;&#039;&#039;&#039; so we can add a new repository easily with an apt command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y python-software-properties software-properties-common apt-transport-https&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the new Java 8 PPA repository with the &#039;add-apt-repository&#039; command, then update the repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo add-apt-repository ppa:webupd8team/java -y &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install Java 8 from the PPA webpub8 repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y oracle-java8-installer&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 2 - Install and Configure Elasticsearch ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Elasticsearch. Install Elasticsearch from the elastic repository and configure it to run on the localhost IP.&lt;br /&gt;
&lt;br /&gt;
Before installing Elasticsearch, add the elastic repository key to the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add - &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add elastic 5.x repository to the &#039;sources.list.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; echo &amp;quot;deb https://artifacts.elastic.co/packages/5.x/apt stable main&amp;quot; | sudo tee -a /etc/apt/sources.list.d/elastic-5.x.list &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Update the repository and install Elasticsearch 5.1 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Elasticsearch is installed. Now go to the configuration directory and edit the elasticsaerch.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; cd /etc/elasticsearch/ &amp;lt;code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano elasticsearch.yml &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enable memory lock for Elasticsearch by removing the comment on line 43. We do this to disable swapping memory for Elasticsearchto avoid overloading the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; bootstrap.memory_lock: true &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the &#039;Network&#039; block, uncomment the network.host and http.port lines.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;network.host: localhost&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;http.port: 9200&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Now edit the elasticsearch service file for the memory lock mlockall configuration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /usr/lib/systemd/system/elasticsearch.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment LimitMEMLOCK line.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;LimitMEMLOCK=infinity&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit.&lt;br /&gt;
&lt;br /&gt;
Edit the default configuration for Elasticsearch in the /etc/default directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano /etc/default/elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment line 60 and make sure the value is &#039;unlimited&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;MAX_LOCKED_MEMORY=unlimited&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
The Elasticsearch configuration is finished. Elasticsearch will run under localhost IP address with port 9200 and we disabled swap memory by enabling mlockall on the Ubuntu server.&lt;br /&gt;
&lt;br /&gt;
Reload the Elasticsearch service file and enable it to run on the boot time, then start the service.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl daemon-reload&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable elasticsearch&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start elasticsearch&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Wait a sec for Elasticsearch to run, then check the open port on the server, make sure the &#039;state&#039; for port 9200 is &#039;LISTEN&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;netstat -plntu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then check the memory lock to ensure that mlockall is enabled. Also check that Elasticsearch is running with the commands below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
curl -XGET &#039;localhost:9200/_nodes?filter_path=**.mlockall&amp;amp;pretty&#039;&lt;br /&gt;
&lt;br /&gt;
curl -XGET &#039;localhost:9200/?pretty&#039;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see the results below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Step 3 - Install and Configure Kibana with Nginx ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Kibana behind a Nginx web server. Kibana will listen on the localhost IP address only and Nginx acts as the reverse proxy for the Kibana application.&lt;br /&gt;
&lt;br /&gt;
Install Kibana with this apt command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y kibana&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the kibana.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /etc/kibana/kibana.yml&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment the server.port, server.hos and elasticsearch.url lines.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
server.port: 5601&lt;br /&gt;
&lt;br /&gt;
server.host: &amp;quot;localhost&amp;quot;&lt;br /&gt;
&lt;br /&gt;
elasticsearch.url: &amp;quot;http://localhost:9200&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Add Kibana to run at boot and start it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl enable kibana&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start kibana&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana will run on port 5601 as node application.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
netstat -plntu&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana installation is done, now we need to install Nginx and configure it as a reverse proxy to be able to access Kibana from the public IP address.&lt;br /&gt;
&lt;br /&gt;
Next, install the Nginx and apache2-utils packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo apt-get install -y nginx apache2-utils&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Apache2-utils is a package that contains tools for the webserver that work with Nginx as well, we will use htpasswd basic authentication for Kibana.&lt;br /&gt;
&lt;br /&gt;
Nginx has been installed. Now we need to create a new virtual host configuration file in the Nginx sites-available directory. Create a new file &#039;kibana&#039; with nano.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/nginx/&lt;br /&gt;
vim sites-available/kibana&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
    listen 80;&lt;br /&gt;
 &lt;br /&gt;
    server_name elk-stack.co;&lt;br /&gt;
 &lt;br /&gt;
    auth_basic &amp;quot;Restricted Access&amp;quot;;&lt;br /&gt;
    auth_basic_user_file /etc/nginx/.kibana-user;&lt;br /&gt;
 &lt;br /&gt;
    location / {&lt;br /&gt;
        proxy_pass http://localhost:5601;&lt;br /&gt;
        proxy_http_version 1.1;&lt;br /&gt;
        proxy_set_header Upgrade $http_upgrade;&lt;br /&gt;
        proxy_set_header Connection &#039;upgrade&#039;;&lt;br /&gt;
        proxy_set_header Host $host;&lt;br /&gt;
        proxy_cache_bypass $http_upgrade;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano&lt;br /&gt;
&lt;br /&gt;
Create a new basic authentication file with the htpasswd command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo htpasswd -c /etc/nginx/.kibana-user admin&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
TYPE YOUR PASSWORD&lt;br /&gt;
&lt;br /&gt;
Activate the kibana virtual host by creating a symbolic link from the kibana file in &#039;sites-available&#039; to the &#039;sites-enabled&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ln -s /etc/nginx/sites-available/kibana /etc/nginx/sites-enabled/ &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Test the nginx configuration and make sure there is no error, then add nginx to run at boot time and restart nginx.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
nginx -t&lt;br /&gt;
&lt;br /&gt;
systemctl enable nginx&lt;br /&gt;
&lt;br /&gt;
systemctl restart nginx&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Step 4 - Install and Configure Logstash == &lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Logsatash to centralize server logs from client sources with filebeat, then filter and transform all data (Syslog) and transport it to the stash (Elasticsearch).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install Logstash 5 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y logstash&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Edit the hosts file with nano.&lt;br /&gt;
&lt;br /&gt;
nano /etc/hosts&lt;br /&gt;
&lt;br /&gt;
Add the server IP address and hostname.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;10.0.2.15    elk-master&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the hosts file and exit the editor.&lt;br /&gt;
&lt;br /&gt;
Now generate a new SSL certificate file with OpenSSL so the client sources can identify the elastic server.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/logstash/&lt;br /&gt;
&lt;br /&gt;
openssl req -subj /CN=elk-master -x509 -days 3650 -batch -nodes -newkey rsa:4096 -keyout logstash.key -out logstash.crt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change the &#039;/CN&#039; value to the elastic server hostname.&lt;br /&gt;
&lt;br /&gt;
Certificate files will be created in the &#039;/etc/logstash/&#039; directory.&lt;br /&gt;
&lt;br /&gt;
Next, we will create the configuration files for logstash. We will create a configuration file &#039;filebeat-input.conf&#039; as input file from filebeat, &#039;syslog-filter.conf&#039; for syslog processing, and then a &#039;output-elasticsearch.conf&#039; file to define the Elasticsearch output.&lt;br /&gt;
&lt;br /&gt;
Go to the logstash configuration directory and create the new configuration files in the &#039;conf.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/logstash/&lt;br /&gt;
&lt;br /&gt;
nano conf.d/filebeat-input.conf&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Input configuration, paste configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input {&lt;br /&gt;
  beats {&lt;br /&gt;
    port =&amp;gt; 5443&lt;br /&gt;
    type =&amp;gt; syslog&lt;br /&gt;
    ssl =&amp;gt; true&lt;br /&gt;
    ssl_certificate =&amp;gt; &amp;quot;/etc/logstash/logstash.crt&amp;quot;&lt;br /&gt;
    ssl_key =&amp;gt; &amp;quot;/etc/logstash/logstash.key&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Create the syslog-filter.conf file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano conf.d/syslog-filter.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
filter {&lt;br /&gt;
  if [type] == &amp;quot;syslog&amp;quot; {&lt;br /&gt;
    grok {&lt;br /&gt;
      match =&amp;gt; { &amp;quot;message&amp;quot; =&amp;gt; &amp;quot;%{SYSLOGTIMESTAMP:syslog_timestamp} %{SYSLOGHOST:syslog_hostname} %{DATA:syslog_program}(?:\[%{POSINT:syslog_pid}\])?: %{GREEDYDATA:syslog_message}&amp;quot; }&lt;br /&gt;
      add_field =&amp;gt; [ &amp;quot;received_at&amp;quot;, &amp;quot;%{@timestamp}&amp;quot; ]&lt;br /&gt;
      add_field =&amp;gt; [ &amp;quot;received_from&amp;quot;, &amp;quot;%{host}&amp;quot; ]&lt;br /&gt;
    }&lt;br /&gt;
    date {&lt;br /&gt;
      match =&amp;gt; [ &amp;quot;syslog_timestamp&amp;quot;, &amp;quot;MMM  d HH:mm:ss&amp;quot;, &amp;quot;MMM dd HH:mm:ss&amp;quot; ]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We use a filter plugin named &#039;grok&#039; to parse the syslog files.&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Create the output configuration file &#039;output-elasticsearch.conf&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano conf.d/output-elasticsearch.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
output {&lt;br /&gt;
  elasticsearch { hosts =&amp;gt; [&amp;quot;localhost:9200&amp;quot;]&lt;br /&gt;
    hosts =&amp;gt; &amp;quot;localhost:9200&amp;quot;&lt;br /&gt;
    manage_template =&amp;gt; false&lt;br /&gt;
    index =&amp;gt; &amp;quot;%{[@metadata][beat]}-%{+YYYY.MM.dd}&amp;quot;&lt;br /&gt;
    document_type =&amp;gt; &amp;quot;%{[@metadata][type]}&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
When this is done, add logstash to start at boot time and start the service.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable logstash&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start logstash&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mdhasan</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123776</id>
		<title>Logging and monitoring with Elastic stack on Ubuntu 16.04</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123776"/>
		<updated>2017-06-19T22:25:04Z</updated>

		<summary type="html">&lt;p&gt;Mdhasan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
Elasticsearch is an open source search engine based on Lucene, developed in java. It provides a distributed and multitenant full-text search engine with an HTTP Dashboard web-interface (Kibana) and JSON documents scheme. Elasticsearch is a scalable search engine that can be used to search for all types of documents, including log file. Elasticsearch is the heart of the &#039;Elastic Stack&#039; or ELK Stack.&lt;br /&gt;
&lt;br /&gt;
Logstash is an open source tool for managing system events and logs. It provides real-time pipelining to collect data. Logstash will collect the log or data, convert all data into JSON documents, and store them in Elasticsearch.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Kibana is a data visualization interface for Elasticsearch. Kibana provides a pretty dashboard (web interfaces), it allows you to manage and visualize all data from Elasticsearch on your own. It&#039;s not just beautiful, but also powerful.&lt;br /&gt;
&lt;br /&gt;
In this HOW TO, I will show you how to install and configure Elastic Stack on a single Ubuntu 16.04 server for monitoring server logs and how to install &#039;Elastic beats&#039; on client PCs with Ubuntu 16.04 and CentOS 7 operating system.&lt;br /&gt;
&lt;br /&gt;
== Prerequisite ==&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit server with 4GB of RAM, hostname - elk-master&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit client with 1 GB of RAM, hostname - elk-client1&lt;br /&gt;
&lt;br /&gt;
CentOS 7 64 bit client with 1GB of RAM, hostname - elk-client2&lt;br /&gt;
&lt;br /&gt;
== Step 1 - Install Java ==&lt;br /&gt;
&lt;br /&gt;
Java is required for the Elastic stack deployment. Elasticsearch requires Java 8. It is recommended to use the Oracle JDK 1.8. We will install Java 8 from a PPA repository.&lt;br /&gt;
&lt;br /&gt;
Install the new package &#039;&#039;&#039;&#039;python-software-properties&#039;&#039;&#039;&#039; so we can add a new repository easily with an apt command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y python-software-properties software-properties-common apt-transport-https&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the new Java 8 PPA repository with the &#039;add-apt-repository&#039; command, then update the repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo add-apt-repository ppa:webupd8team/java -y &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install Java 8 from the PPA webpub8 repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y oracle-java8-installer&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 2 - Install and Configure Elasticsearch ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Elasticsearch. Install Elasticsearch from the elastic repository and configure it to run on the localhost IP.&lt;br /&gt;
&lt;br /&gt;
Before installing Elasticsearch, add the elastic repository key to the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add - &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add elastic 5.x repository to the &#039;sources.list.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; echo &amp;quot;deb https://artifacts.elastic.co/packages/5.x/apt stable main&amp;quot; | sudo tee -a /etc/apt/sources.list.d/elastic-5.x.list &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Update the repository and install Elasticsearch 5.1 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Elasticsearch is installed. Now go to the configuration directory and edit the elasticsaerch.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; cd /etc/elasticsearch/ &amp;lt;code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano elasticsearch.yml &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enable memory lock for Elasticsearch by removing the comment on line 43. We do this to disable swapping memory for Elasticsearchto avoid overloading the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; bootstrap.memory_lock: true &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the &#039;Network&#039; block, uncomment the network.host and http.port lines.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;network.host: localhost&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;http.port: 9200&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Now edit the elasticsearch service file for the memory lock mlockall configuration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /usr/lib/systemd/system/elasticsearch.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment LimitMEMLOCK line.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;LimitMEMLOCK=infinity&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit.&lt;br /&gt;
&lt;br /&gt;
Edit the default configuration for Elasticsearch in the /etc/default directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano /etc/default/elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment line 60 and make sure the value is &#039;unlimited&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;MAX_LOCKED_MEMORY=unlimited&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
The Elasticsearch configuration is finished. Elasticsearch will run under localhost IP address with port 9200 and we disabled swap memory by enabling mlockall on the Ubuntu server.&lt;br /&gt;
&lt;br /&gt;
Reload the Elasticsearch service file and enable it to run on the boot time, then start the service.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl daemon-reload&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable elasticsearch&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start elasticsearch&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Wait a sec for Elasticsearch to run, then check the open port on the server, make sure the &#039;state&#039; for port 9200 is &#039;LISTEN&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;netstat -plntu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then check the memory lock to ensure that mlockall is enabled. Also check that Elasticsearch is running with the commands below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
curl -XGET &#039;localhost:9200/_nodes?filter_path=**.mlockall&amp;amp;pretty&#039;&lt;br /&gt;
&lt;br /&gt;
curl -XGET &#039;localhost:9200/?pretty&#039;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see the results below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Step 3 - Install and Configure Kibana with Nginx ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Kibana behind a Nginx web server. Kibana will listen on the localhost IP address only and Nginx acts as the reverse proxy for the Kibana application.&lt;br /&gt;
&lt;br /&gt;
Install Kibana with this apt command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y kibana&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the kibana.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /etc/kibana/kibana.yml&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment the server.port, server.hos and elasticsearch.url lines.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
server.port: 5601&lt;br /&gt;
&lt;br /&gt;
server.host: &amp;quot;localhost&amp;quot;&lt;br /&gt;
&lt;br /&gt;
elasticsearch.url: &amp;quot;http://localhost:9200&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Add Kibana to run at boot and start it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl enable kibana&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start kibana&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana will run on port 5601 as node application.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
netstat -plntu&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana installation is done, now we need to install Nginx and configure it as a reverse proxy to be able to access Kibana from the public IP address.&lt;br /&gt;
&lt;br /&gt;
Next, install the Nginx and apache2-utils packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo apt-get install -y nginx apache2-utils&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Apache2-utils is a package that contains tools for the webserver that work with Nginx as well, we will use htpasswd basic authentication for Kibana.&lt;br /&gt;
&lt;br /&gt;
Nginx has been installed. Now we need to create a new virtual host configuration file in the Nginx sites-available directory. Create a new file &#039;kibana&#039; with nano.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/nginx/&lt;br /&gt;
vim sites-available/kibana&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
    listen 80;&lt;br /&gt;
 &lt;br /&gt;
    server_name elk-stack.co;&lt;br /&gt;
 &lt;br /&gt;
    auth_basic &amp;quot;Restricted Access&amp;quot;;&lt;br /&gt;
    auth_basic_user_file /etc/nginx/.kibana-user;&lt;br /&gt;
 &lt;br /&gt;
    location / {&lt;br /&gt;
        proxy_pass http://localhost:5601;&lt;br /&gt;
        proxy_http_version 1.1;&lt;br /&gt;
        proxy_set_header Upgrade $http_upgrade;&lt;br /&gt;
        proxy_set_header Connection &#039;upgrade&#039;;&lt;br /&gt;
        proxy_set_header Host $host;&lt;br /&gt;
        proxy_cache_bypass $http_upgrade;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano&lt;br /&gt;
&lt;br /&gt;
Create a new basic authentication file with the htpasswd command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo htpasswd -c /etc/nginx/.kibana-user admin&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
TYPE YOUR PASSWORD&lt;br /&gt;
&lt;br /&gt;
Activate the kibana virtual host by creating a symbolic link from the kibana file in &#039;sites-available&#039; to the &#039;sites-enabled&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;ln -s /etc/nginx/sites-available/kibana /etc/nginx/sites-enabled/ &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Test the nginx configuration and make sure there is no error, then add nginx to run at boot time and restart nginx.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
nginx -t&lt;br /&gt;
&lt;br /&gt;
systemctl enable nginx&lt;br /&gt;
&lt;br /&gt;
systemctl restart nginx&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Step 4 - Install and Configure Logstash == &lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Logsatash to centralize server logs from client sources with filebeat, then filter and transform all data (Syslog) and transport it to the stash (Elasticsearch).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Install Logstash 5 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y logstash&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Edit the hosts file with nano.&lt;br /&gt;
&lt;br /&gt;
nano /etc/hosts&lt;br /&gt;
&lt;br /&gt;
Add the server IP address and hostname.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;10.0.2.15    elk-master&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the hosts file and exit the editor.&lt;br /&gt;
&lt;br /&gt;
Now generate a new SSL certificate file with OpenSSL so the client sources can identify the elastic server.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/logstash/&lt;br /&gt;
&lt;br /&gt;
openssl req -subj /CN=elk-master -x509 -days 3650 -batch -nodes -newkey rsa:4096 -keyout logstash.key -out logstash.crt&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Change the &#039;/CN&#039; value to the elastic server hostname.&lt;br /&gt;
&lt;br /&gt;
Certificate files will be created in the &#039;/etc/logstash/&#039; directory.&lt;br /&gt;
&lt;br /&gt;
Next, we will create the configuration files for logstash. We will create a configuration file &#039;filebeat-input.conf&#039; as input file from filebeat, &#039;syslog-filter.conf&#039; for syslog processing, and then a &#039;output-elasticsearch.conf&#039; file to define the Elasticsearch output.&lt;br /&gt;
&lt;br /&gt;
Go to the logstash configuration directory and create the new configuration files in the &#039;conf.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/logstash/&lt;br /&gt;
&lt;br /&gt;
nano conf.d/filebeat-input.conf&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Input configuration, paste configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
input {&lt;br /&gt;
  beats {&lt;br /&gt;
    port =&amp;gt; 5443&lt;br /&gt;
    type =&amp;gt; syslog&lt;br /&gt;
    ssl =&amp;gt; true&lt;br /&gt;
    ssl_certificate =&amp;gt; &amp;quot;/etc/logstash/logstash.crt&amp;quot;&lt;br /&gt;
    ssl_key =&amp;gt; &amp;quot;/etc/logstash/logstash.key&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Create the syslog-filter.conf file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano conf.d/syslog-filter.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
filter {&lt;br /&gt;
  if [type] == &amp;quot;syslog&amp;quot; {&lt;br /&gt;
    grok {&lt;br /&gt;
      match =&amp;gt; { &amp;quot;message&amp;quot; =&amp;gt; &amp;quot;%{SYSLOGTIMESTAMP:syslog_timestamp} %{SYSLOGHOST:syslog_hostname} %{DATA:syslog_program}(?:\[%{POSINT:syslog_pid}\])?: %{GREEDYDATA:syslog_message}&amp;quot; }&lt;br /&gt;
      add_field =&amp;gt; [ &amp;quot;received_at&amp;quot;, &amp;quot;%{@timestamp}&amp;quot; ]&lt;br /&gt;
      add_field =&amp;gt; [ &amp;quot;received_from&amp;quot;, &amp;quot;%{host}&amp;quot; ]&lt;br /&gt;
    }&lt;br /&gt;
    date {&lt;br /&gt;
      match =&amp;gt; [ &amp;quot;syslog_timestamp&amp;quot;, &amp;quot;MMM  d HH:mm:ss&amp;quot;, &amp;quot;MMM dd HH:mm:ss&amp;quot; ]&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We use a filter plugin named &#039;grok&#039; to parse the syslog files.&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
Create the output configuration file &#039;output-elasticsearch.conf&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano conf.d/output-elasticsearch.conf &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
output {&lt;br /&gt;
  elasticsearch { hosts =&amp;gt; [&amp;quot;localhost:9200&amp;quot;]&lt;br /&gt;
    hosts =&amp;gt; &amp;quot;localhost:9200&amp;quot;&lt;br /&gt;
    manage_template =&amp;gt; false&lt;br /&gt;
    index =&amp;gt; &amp;quot;%{[@metadata][beat]}-%{+YYYY.MM.dd}&amp;quot;&lt;br /&gt;
    document_type =&amp;gt; &amp;quot;%{[@metadata][type]}&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
When this is done, add logstash to start at boot time and start the service.&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable logstash&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start logstash&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mdhasan</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123775</id>
		<title>Logging and monitoring with Elastic stack on Ubuntu 16.04</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123775"/>
		<updated>2017-06-19T22:18:21Z</updated>

		<summary type="html">&lt;p&gt;Mdhasan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
Elasticsearch is an open source search engine based on Lucene, developed in java. It provides a distributed and multitenant full-text search engine with an HTTP Dashboard web-interface (Kibana) and JSON documents scheme. Elasticsearch is a scalable search engine that can be used to search for all types of documents, including log file. Elasticsearch is the heart of the &#039;Elastic Stack&#039; or ELK Stack.&lt;br /&gt;
&lt;br /&gt;
Logstash is an open source tool for managing system events and logs. It provides real-time pipelining to collect data. Logstash will collect the log or data, convert all data into JSON documents, and store them in Elasticsearch.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Kibana is a data visualization interface for Elasticsearch. Kibana provides a pretty dashboard (web interfaces), it allows you to manage and visualize all data from Elasticsearch on your own. It&#039;s not just beautiful, but also powerful.&lt;br /&gt;
&lt;br /&gt;
In this HOW TO, I will show you how to install and configure Elastic Stack on a single Ubuntu 16.04 server for monitoring server logs and how to install &#039;Elastic beats&#039; on client PCs with Ubuntu 16.04 and CentOS 7 operating system.&lt;br /&gt;
&lt;br /&gt;
== Prerequisite ==&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit server with 4GB of RAM, hostname - elk-master&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit client with 1 GB of RAM, hostname - elk-client1&lt;br /&gt;
&lt;br /&gt;
CentOS 7 64 bit client with 1GB of RAM, hostname - elk-client2&lt;br /&gt;
&lt;br /&gt;
== Step 1 - Install Java ==&lt;br /&gt;
&lt;br /&gt;
Java is required for the Elastic stack deployment. Elasticsearch requires Java 8. It is recommended to use the Oracle JDK 1.8. We will install Java 8 from a PPA repository.&lt;br /&gt;
&lt;br /&gt;
Install the new package &#039;&#039;&#039;&#039;python-software-properties&#039;&#039;&#039;&#039; so we can add a new repository easily with an apt command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y python-software-properties software-properties-common apt-transport-https&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the new Java 8 PPA repository with the &#039;add-apt-repository&#039; command, then update the repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo add-apt-repository ppa:webupd8team/java -y &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install Java 8 from the PPA webpub8 repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y oracle-java8-installer&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 2 - Install and Configure Elasticsearch ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Elasticsearch. Install Elasticsearch from the elastic repository and configure it to run on the localhost IP.&lt;br /&gt;
&lt;br /&gt;
Before installing Elasticsearch, add the elastic repository key to the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add - &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add elastic 5.x repository to the &#039;sources.list.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; echo &amp;quot;deb https://artifacts.elastic.co/packages/5.x/apt stable main&amp;quot; | sudo tee -a /etc/apt/sources.list.d/elastic-5.x.list &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Update the repository and install Elasticsearch 5.1 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Elasticsearch is installed. Now go to the configuration directory and edit the elasticsaerch.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; cd /etc/elasticsearch/ &amp;lt;code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano elasticsearch.yml &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enable memory lock for Elasticsearch by removing the comment on line 43. We do this to disable swapping memory for Elasticsearchto avoid overloading the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; bootstrap.memory_lock: true &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the &#039;Network&#039; block, uncomment the network.host and http.port lines.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;network.host: localhost&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;http.port: 9200&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Now edit the elasticsearch service file for the memory lock mlockall configuration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /usr/lib/systemd/system/elasticsearch.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment LimitMEMLOCK line.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;LimitMEMLOCK=infinity&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit.&lt;br /&gt;
&lt;br /&gt;
Edit the default configuration for Elasticsearch in the /etc/default directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano /etc/default/elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment line 60 and make sure the value is &#039;unlimited&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;MAX_LOCKED_MEMORY=unlimited&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
The Elasticsearch configuration is finished. Elasticsearch will run under localhost IP address with port 9200 and we disabled swap memory by enabling mlockall on the Ubuntu server.&lt;br /&gt;
&lt;br /&gt;
Reload the Elasticsearch service file and enable it to run on the boot time, then start the service.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl daemon-reload&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable elasticsearch&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start elasticsearch&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Wait a sec for Elasticsearch to run, then check the open port on the server, make sure the &#039;state&#039; for port 9200 is &#039;LISTEN&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;netstat -plntu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then check the memory lock to ensure that mlockall is enabled. Also check that Elasticsearch is running with the commands below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
curl -XGET &#039;localhost:9200/_nodes?filter_path=**.mlockall&amp;amp;pretty&#039;&lt;br /&gt;
&lt;br /&gt;
curl -XGET &#039;localhost:9200/?pretty&#039;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see the results below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Step 3 - Install and Configure Kibana with Nginx ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Kibana behind a Nginx web server. Kibana will listen on the localhost IP address only and Nginx acts as the reverse proxy for the Kibana application.&lt;br /&gt;
&lt;br /&gt;
Install Kibana with this apt command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y kibana&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now edit the kibana.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /etc/kibana/kibana.yml&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment the server.port, server.hos and elasticsearch.url lines.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
server.port: 5601&lt;br /&gt;
&lt;br /&gt;
server.host: &amp;quot;localhost&amp;quot;&lt;br /&gt;
&lt;br /&gt;
elasticsearch.url: &amp;quot;http://localhost:9200&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Add Kibana to run at boot and start it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl enable kibana&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start kibana&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana will run on port 5601 as node application.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
netstat -plntu&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Kibana installation is done, now we need to install Nginx and configure it as a reverse proxy to be able to access Kibana from the public IP address.&lt;br /&gt;
&lt;br /&gt;
Next, install the Nginx and apache2-utils packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo apt-get install -y nginx apache2-utils&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Apache2-utils is a package that contains tools for the webserver that work with Nginx as well, we will use htpasswd basic authentication for Kibana.&lt;br /&gt;
&lt;br /&gt;
Nginx has been installed. Now we need to create a new virtual host configuration file in the Nginx sites-available directory. Create a new file &#039;kibana&#039; with nano.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
cd /etc/nginx/&lt;br /&gt;
vim sites-available/kibana&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste configuration below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
    listen 80;&lt;br /&gt;
 &lt;br /&gt;
    server_name elk-stack.co;&lt;br /&gt;
 &lt;br /&gt;
    auth_basic &amp;quot;Restricted Access&amp;quot;;&lt;br /&gt;
    auth_basic_user_file /etc/nginx/.kibana-user;&lt;br /&gt;
 &lt;br /&gt;
    location / {&lt;br /&gt;
        proxy_pass http://localhost:5601;&lt;br /&gt;
        proxy_http_version 1.1;&lt;br /&gt;
        proxy_set_header Upgrade $http_upgrade;&lt;br /&gt;
        proxy_set_header Connection &#039;upgrade&#039;;&lt;br /&gt;
        proxy_set_header Host $host;&lt;br /&gt;
        proxy_cache_bypass $http_upgrade;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mdhasan</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123774</id>
		<title>Logging and monitoring with Elastic stack on Ubuntu 16.04</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123774"/>
		<updated>2017-06-19T22:11:44Z</updated>

		<summary type="html">&lt;p&gt;Mdhasan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
Elasticsearch is an open source search engine based on Lucene, developed in java. It provides a distributed and multitenant full-text search engine with an HTTP Dashboard web-interface (Kibana) and JSON documents scheme. Elasticsearch is a scalable search engine that can be used to search for all types of documents, including log file. Elasticsearch is the heart of the &#039;Elastic Stack&#039; or ELK Stack.&lt;br /&gt;
&lt;br /&gt;
Logstash is an open source tool for managing system events and logs. It provides real-time pipelining to collect data. Logstash will collect the log or data, convert all data into JSON documents, and store them in Elasticsearch.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Kibana is a data visualization interface for Elasticsearch. Kibana provides a pretty dashboard (web interfaces), it allows you to manage and visualize all data from Elasticsearch on your own. It&#039;s not just beautiful, but also powerful.&lt;br /&gt;
&lt;br /&gt;
In this HOW TO, I will show you how to install and configure Elastic Stack on a single Ubuntu 16.04 server for monitoring server logs and how to install &#039;Elastic beats&#039; on client PCs with Ubuntu 16.04 and CentOS 7 operating system.&lt;br /&gt;
&lt;br /&gt;
== Prerequisite ==&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit server with 4GB of RAM, hostname - elk-master&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit client with 1 GB of RAM, hostname - elk-client1&lt;br /&gt;
&lt;br /&gt;
CentOS 7 64 bit client with 1GB of RAM, hostname - elk-client2&lt;br /&gt;
&lt;br /&gt;
== Step 1 - Install Java ==&lt;br /&gt;
&lt;br /&gt;
Java is required for the Elastic stack deployment. Elasticsearch requires Java 8. It is recommended to use the Oracle JDK 1.8. We will install Java 8 from a PPA repository.&lt;br /&gt;
&lt;br /&gt;
Install the new package &#039;&#039;&#039;&#039;python-software-properties&#039;&#039;&#039;&#039; so we can add a new repository easily with an apt command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y python-software-properties software-properties-common apt-transport-https&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the new Java 8 PPA repository with the &#039;add-apt-repository&#039; command, then update the repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo add-apt-repository ppa:webupd8team/java -y &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install Java 8 from the PPA webpub8 repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y oracle-java8-installer&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 2 - Install and Configure Elasticsearch ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Elasticsearch. Install Elasticsearch from the elastic repository and configure it to run on the localhost IP.&lt;br /&gt;
&lt;br /&gt;
Before installing Elasticsearch, add the elastic repository key to the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add - &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add elastic 5.x repository to the &#039;sources.list.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; echo &amp;quot;deb https://artifacts.elastic.co/packages/5.x/apt stable main&amp;quot; | sudo tee -a /etc/apt/sources.list.d/elastic-5.x.list &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Update the repository and install Elasticsearch 5.1 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Elasticsearch is installed. Now go to the configuration directory and edit the elasticsaerch.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; cd /etc/elasticsearch/ &amp;lt;code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano elasticsearch.yml &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enable memory lock for Elasticsearch by removing the comment on line 43. We do this to disable swapping memory for Elasticsearchto avoid overloading the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; bootstrap.memory_lock: true &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the &#039;Network&#039; block, uncomment the network.host and http.port lines.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;network.host: localhost&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;http.port: 9200&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Now edit the elasticsearch service file for the memory lock mlockall configuration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /usr/lib/systemd/system/elasticsearch.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment LimitMEMLOCK line.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;LimitMEMLOCK=infinity&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit.&lt;br /&gt;
&lt;br /&gt;
Edit the default configuration for Elasticsearch in the /etc/default directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano /etc/default/elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment line 60 and make sure the value is &#039;unlimited&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;MAX_LOCKED_MEMORY=unlimited&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
The Elasticsearch configuration is finished. Elasticsearch will run under localhost IP address with port 9200 and we disabled swap memory by enabling mlockall on the Ubuntu server.&lt;br /&gt;
&lt;br /&gt;
Reload the Elasticsearch service file and enable it to run on the boot time, then start the service.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl daemon-reload&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable elasticsearch&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start elasticsearch&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Wait a sec for Elasticsearch to run, then check the open port on the server, make sure the &#039;state&#039; for port 9200 is &#039;LISTEN&#039;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;netstat -plntu&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then check the memory lock to ensure that mlockall is enabled. Also check that Elasticsearch is running with the commands below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
curl -XGET &#039;localhost:9200/_nodes?filter_path=**.mlockall&amp;amp;pretty&#039;&lt;br /&gt;
&lt;br /&gt;
curl -XGET &#039;localhost:9200/?pretty&#039;&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You will see the results below.&lt;/div&gt;</summary>
		<author><name>Mdhasan</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123773</id>
		<title>Logging and monitoring with Elastic stack on Ubuntu 16.04</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123773"/>
		<updated>2017-06-19T22:10:20Z</updated>

		<summary type="html">&lt;p&gt;Mdhasan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
Elasticsearch is an open source search engine based on Lucene, developed in java. It provides a distributed and multitenant full-text search engine with an HTTP Dashboard web-interface (Kibana) and JSON documents scheme. Elasticsearch is a scalable search engine that can be used to search for all types of documents, including log file. Elasticsearch is the heart of the &#039;Elastic Stack&#039; or ELK Stack.&lt;br /&gt;
&lt;br /&gt;
Logstash is an open source tool for managing system events and logs. It provides real-time pipelining to collect data. Logstash will collect the log or data, convert all data into JSON documents, and store them in Elasticsearch.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Kibana is a data visualization interface for Elasticsearch. Kibana provides a pretty dashboard (web interfaces), it allows you to manage and visualize all data from Elasticsearch on your own. It&#039;s not just beautiful, but also powerful.&lt;br /&gt;
&lt;br /&gt;
In this HOW TO, I will show you how to install and configure Elastic Stack on a single Ubuntu 16.04 server for monitoring server logs and how to install &#039;Elastic beats&#039; on client PCs with Ubuntu 16.04 and CentOS 7 operating system.&lt;br /&gt;
&lt;br /&gt;
== Prerequisite ==&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit server with 4GB of RAM, hostname - elk-master&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit client with 1 GB of RAM, hostname - elk-client1&lt;br /&gt;
&lt;br /&gt;
CentOS 7 64 bit client with 1GB of RAM, hostname - elk-client2&lt;br /&gt;
&lt;br /&gt;
== Step 1 - Install Java ==&lt;br /&gt;
&lt;br /&gt;
Java is required for the Elastic stack deployment. Elasticsearch requires Java 8. It is recommended to use the Oracle JDK 1.8. We will install Java 8 from a PPA repository.&lt;br /&gt;
&lt;br /&gt;
Install the new package &#039;&#039;&#039;&#039;python-software-properties&#039;&#039;&#039;&#039; so we can add a new repository easily with an apt command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y python-software-properties software-properties-common apt-transport-https&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the new Java 8 PPA repository with the &#039;add-apt-repository&#039; command, then update the repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo add-apt-repository ppa:webupd8team/java -y &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install Java 8 from the PPA webpub8 repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y oracle-java8-installer&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 2 - Install and Configure Elasticsearch ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Elasticsearch. Install Elasticsearch from the elastic repository and configure it to run on the localhost IP.&lt;br /&gt;
&lt;br /&gt;
Before installing Elasticsearch, add the elastic repository key to the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add - &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add elastic 5.x repository to the &#039;sources.list.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; echo &amp;quot;deb https://artifacts.elastic.co/packages/5.x/apt stable main&amp;quot; | sudo tee -a /etc/apt/sources.list.d/elastic-5.x.list &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Update the repository and install Elasticsearch 5.1 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Elasticsearch is installed. Now go to the configuration directory and edit the elasticsaerch.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; cd /etc/elasticsearch/ &amp;lt;code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano elasticsearch.yml &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enable memory lock for Elasticsearch by removing the comment on line 43. We do this to disable swapping memory for Elasticsearchto avoid overloading the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; bootstrap.memory_lock: true &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the &#039;Network&#039; block, uncomment the network.host and http.port lines.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;network.host: localhost&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;http.port: 9200&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Now edit the elasticsearch service file for the memory lock mlockall configuration.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /usr/lib/systemd/system/elasticsearch.service&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment LimitMEMLOCK line.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;LimitMEMLOCK=infinity&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit.&lt;br /&gt;
&lt;br /&gt;
Edit the default configuration for Elasticsearch in the /etc/default directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;nano /etc/default/elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Uncomment line 60 and make sure the value is &#039;unlimited&#039;.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;MAX_LOCKED_MEMORY=unlimited&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save and exit.&lt;br /&gt;
&lt;br /&gt;
The Elasticsearch configuration is finished. Elasticsearch will run under localhost IP address with port 9200 and we disabled swap memory by enabling mlockall on the Ubuntu server.&lt;br /&gt;
&lt;br /&gt;
Reload the Elasticsearch service file and enable it to run on the boot time, then start the service.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&lt;br /&gt;
sudo systemctl daemon-reload&lt;br /&gt;
&lt;br /&gt;
sudo systemctl enable elasticsearch&lt;br /&gt;
&lt;br /&gt;
sudo systemctl start elasticsearch&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mdhasan</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123772</id>
		<title>Logging and monitoring with Elastic stack on Ubuntu 16.04</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123772"/>
		<updated>2017-06-19T22:07:17Z</updated>

		<summary type="html">&lt;p&gt;Mdhasan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
Elasticsearch is an open source search engine based on Lucene, developed in java. It provides a distributed and multitenant full-text search engine with an HTTP Dashboard web-interface (Kibana) and JSON documents scheme. Elasticsearch is a scalable search engine that can be used to search for all types of documents, including log file. Elasticsearch is the heart of the &#039;Elastic Stack&#039; or ELK Stack.&lt;br /&gt;
&lt;br /&gt;
Logstash is an open source tool for managing system events and logs. It provides real-time pipelining to collect data. Logstash will collect the log or data, convert all data into JSON documents, and store them in Elasticsearch.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Kibana is a data visualization interface for Elasticsearch. Kibana provides a pretty dashboard (web interfaces), it allows you to manage and visualize all data from Elasticsearch on your own. It&#039;s not just beautiful, but also powerful.&lt;br /&gt;
&lt;br /&gt;
In this HOW TO, I will show you how to install and configure Elastic Stack on a single Ubuntu 16.04 server for monitoring server logs and how to install &#039;Elastic beats&#039; on client PCs with Ubuntu 16.04 and CentOS 7 operating system.&lt;br /&gt;
&lt;br /&gt;
== Prerequisite ==&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit server with 4GB of RAM, hostname - elk-master&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit client with 1 GB of RAM, hostname - elk-client1&lt;br /&gt;
&lt;br /&gt;
CentOS 7 64 bit client with 1GB of RAM, hostname - elk-client2&lt;br /&gt;
&lt;br /&gt;
== Step 1 - Install Java ==&lt;br /&gt;
&lt;br /&gt;
Java is required for the Elastic stack deployment. Elasticsearch requires Java 8. It is recommended to use the Oracle JDK 1.8. We will install Java 8 from a PPA repository.&lt;br /&gt;
&lt;br /&gt;
Install the new package &#039;&#039;&#039;&#039;python-software-properties&#039;&#039;&#039;&#039; so we can add a new repository easily with an apt command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y python-software-properties software-properties-common apt-transport-https&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the new Java 8 PPA repository with the &#039;add-apt-repository&#039; command, then update the repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo add-apt-repository ppa:webupd8team/java -y &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Install Java 8 from the PPA webpub8 repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y oracle-java8-installer&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Step 2 - Install and Configure Elasticsearch ==&lt;br /&gt;
&lt;br /&gt;
In this step, we will install and configure Elasticsearch. Install Elasticsearch from the elastic repository and configure it to run on the localhost IP.&lt;br /&gt;
&lt;br /&gt;
Before installing Elasticsearch, add the elastic repository key to the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add - &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add elastic 5.x repository to the &#039;sources.list.d&#039; directory.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; echo &amp;quot;deb https://artifacts.elastic.co/packages/5.x/apt stable main&amp;quot; | sudo tee -a /etc/apt/sources.list.d/elastic-5.x.list &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Update the repository and install Elasticsearch 5.1 with the apt command below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; sudo apt-get install -y elasticsearch &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Elasticsearch is installed. Now go to the configuration directory and edit the elasticsaerch.yml configuration file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; cd /etc/elasticsearch/ &amp;lt;code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano elasticsearch.yml &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Enable memory lock for Elasticsearch by removing the comment on line 43. We do this to disable swapping memory for Elasticsearchto avoid overloading the server.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; bootstrap.memory_lock: true &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the &#039;Network&#039; block, uncomment the network.host and http.port lines.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;network.host: localhost&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;http.port: 9200&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Save the file and exit nano.&lt;br /&gt;
&lt;br /&gt;
Now edit the elasticsearch service file for the memory lock mlockall configuration.&lt;/div&gt;</summary>
		<author><name>Mdhasan</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123771</id>
		<title>Logging and monitoring with Elastic stack on Ubuntu 16.04</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123771"/>
		<updated>2017-06-19T22:03:02Z</updated>

		<summary type="html">&lt;p&gt;Mdhasan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
Elasticsearch is an open source search engine based on Lucene, developed in java. It provides a distributed and multitenant full-text search engine with an HTTP Dashboard web-interface (Kibana) and JSON documents scheme. Elasticsearch is a scalable search engine that can be used to search for all types of documents, including log file. Elasticsearch is the heart of the &#039;Elastic Stack&#039; or ELK Stack.&lt;br /&gt;
&lt;br /&gt;
Logstash is an open source tool for managing system events and logs. It provides real-time pipelining to collect data. Logstash will collect the log or data, convert all data into JSON documents, and store them in Elasticsearch.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Kibana is a data visualization interface for Elasticsearch. Kibana provides a pretty dashboard (web interfaces), it allows you to manage and visualize all data from Elasticsearch on your own. It&#039;s not just beautiful, but also powerful.&lt;br /&gt;
&lt;br /&gt;
In this HOW TO, I will show you how to install and configure Elastic Stack on a single Ubuntu 16.04 server for monitoring server logs and how to install &#039;Elastic beats&#039; on client PCs with Ubuntu 16.04 and CentOS 7 operating system.&lt;br /&gt;
&lt;br /&gt;
== Prerequisite ==&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit server with 4GB of RAM, hostname - elk-master&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit client with 1 GB of RAM, hostname - elk-client1&lt;br /&gt;
&lt;br /&gt;
CentOS 7 64 bit client with 1GB of RAM, hostname - elk-client2&lt;br /&gt;
&lt;br /&gt;
== Step 1 - Install Java ==&lt;br /&gt;
&lt;br /&gt;
Java is required for the Elastic stack deployment. Elasticsearch requires Java 8. It is recommended to use the Oracle JDK 1.8. We will install Java 8 from a PPA repository.&lt;br /&gt;
&lt;br /&gt;
Install the new package &#039;&#039;&#039;&#039;python-software-properties&#039;&#039;&#039;&#039; so we can add a new repository easily with an apt command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y python-software-properties software-properties-common apt-transport-https&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Add the new Java 8 PPA repository with the &#039;add-apt-repository&#039; command, then update the repository.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo add-apt-repository ppa:webupd8team/java -y &amp;lt;/code&amp;gt;&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mdhasan</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123770</id>
		<title>Logging and monitoring with Elastic stack on Ubuntu 16.04</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123770"/>
		<updated>2017-06-19T22:02:13Z</updated>

		<summary type="html">&lt;p&gt;Mdhasan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
Elasticsearch is an open source search engine based on Lucene, developed in java. It provides a distributed and multitenant full-text search engine with an HTTP Dashboard web-interface (Kibana) and JSON documents scheme. Elasticsearch is a scalable search engine that can be used to search for all types of documents, including log file. Elasticsearch is the heart of the &#039;Elastic Stack&#039; or ELK Stack.&lt;br /&gt;
&lt;br /&gt;
Logstash is an open source tool for managing system events and logs. It provides real-time pipelining to collect data. Logstash will collect the log or data, convert all data into JSON documents, and store them in Elasticsearch.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Kibana is a data visualization interface for Elasticsearch. Kibana provides a pretty dashboard (web interfaces), it allows you to manage and visualize all data from Elasticsearch on your own. It&#039;s not just beautiful, but also powerful.&lt;br /&gt;
&lt;br /&gt;
In this HOW TO, I will show you how to install and configure Elastic Stack on a single Ubuntu 16.04 server for monitoring server logs and how to install &#039;Elastic beats&#039; on client PCs with Ubuntu 16.04 and CentOS 7 operating system.&lt;br /&gt;
&lt;br /&gt;
== Prerequisite ==&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit server with 4GB of RAM, hostname - elk-master&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit client with 1 GB of RAM, hostname - elk-client1&lt;br /&gt;
&lt;br /&gt;
CentOS 7 64 bit client with 1GB of RAM, hostname - elk-client2&lt;br /&gt;
&lt;br /&gt;
== Step 1 - Install Java ==&lt;br /&gt;
&lt;br /&gt;
Java is required for the Elastic stack deployment. Elasticsearch requires Java 8. It is recommended to use the Oracle JDK 1.8. We will install Java 8 from a PPA repository.&lt;br /&gt;
&lt;br /&gt;
Install the new package &#039;&#039;&#039;&#039;python-software-properties&#039;&#039;&#039;&#039; so we can add a new repository easily with an apt command.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get update &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;sudo apt-get install -y python-software-properties software-properties-common apt-transport-https&amp;lt;/code&amp;gt;&lt;/div&gt;</summary>
		<author><name>Mdhasan</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123769</id>
		<title>Logging and monitoring with Elastic stack on Ubuntu 16.04</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123769"/>
		<updated>2017-06-19T20:24:04Z</updated>

		<summary type="html">&lt;p&gt;Mdhasan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
Elasticsearch is an open source search engine based on Lucene, developed in java. It provides a distributed and multitenant full-text search engine with an HTTP Dashboard web-interface (Kibana) and JSON documents scheme. Elasticsearch is a scalable search engine that can be used to search for all types of documents, including log file. Elasticsearch is the heart of the &#039;Elastic Stack&#039; or ELK Stack.&lt;br /&gt;
&lt;br /&gt;
Logstash is an open source tool for managing system events and logs. It provides real-time pipelining to collect data. Logstash will collect the log or data, convert all data into JSON documents, and store them in Elasticsearch.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Kibana is a data visualization interface for Elasticsearch. Kibana provides a pretty dashboard (web interfaces), it allows you to manage and visualize all data from Elasticsearch on your own. It&#039;s not just beautiful, but also powerful.&lt;br /&gt;
&lt;br /&gt;
In this HOW TO, I will show you how to install and configure Elastic Stack on a single Ubuntu 16.04 server for monitoring server logs and how to install &#039;Elastic beats&#039; on client PCs with Ubuntu 16.04 and CentOS 7 operating system.&lt;br /&gt;
&lt;br /&gt;
== Prerequisite ==&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit server with 4GB of RAM, hostname - elk-master&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit client with 1 GB of RAM, hostname - elk-client1&lt;br /&gt;
&lt;br /&gt;
CentOS 7 64 bit client with 1GB of RAM, hostname - elk-client2&lt;br /&gt;
&lt;br /&gt;
== Step 1 - Install Java ==&lt;/div&gt;</summary>
		<author><name>Mdhasan</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123768</id>
		<title>Logging and monitoring with Elastic stack on Ubuntu 16.04</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123768"/>
		<updated>2017-06-19T20:23:37Z</updated>

		<summary type="html">&lt;p&gt;Mdhasan: /* Prerequisite */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
Elasticsearch is an open source search engine based on Lucene, developed in java. It provides a distributed and multitenant full-text search engine with an HTTP Dashboard web-interface (Kibana) and JSON documents scheme. Elasticsearch is a scalable search engine that can be used to search for all types of documents, including log file. Elasticsearch is the heart of the &#039;Elastic Stack&#039; or ELK Stack.&lt;br /&gt;
&lt;br /&gt;
Logstash is an open source tool for managing system events and logs. It provides real-time pipelining to collect data. Logstash will collect the log or data, convert all data into JSON documents, and store them in Elasticsearch.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Kibana is a data visualization interface for Elasticsearch. Kibana provides a pretty dashboard (web interfaces), it allows you to manage and visualize all data from Elasticsearch on your own. It&#039;s not just beautiful, but also powerful.&lt;br /&gt;
&lt;br /&gt;
In this HOW TO, I will show you how to install and configure Elastic Stack on a single Ubuntu 16.04 server for monitoring server logs and how to install &#039;Elastic beats&#039; on client PCs with Ubuntu 16.04 and CentOS 7 operating system.&lt;br /&gt;
&lt;br /&gt;
== Prerequisite ==&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit server with 4GB of RAM, hostname - elk-master&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit client with 1 GB of RAM, hostname - elk-client1&lt;br /&gt;
&lt;br /&gt;
CentOS 7 64 bit client with 1GB of RAM, hostname - elk-client2&lt;/div&gt;</summary>
		<author><name>Mdhasan</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123767</id>
		<title>Logging and monitoring with Elastic stack on Ubuntu 16.04</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123767"/>
		<updated>2017-06-19T20:23:23Z</updated>

		<summary type="html">&lt;p&gt;Mdhasan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Introduction==&lt;br /&gt;
Elasticsearch is an open source search engine based on Lucene, developed in java. It provides a distributed and multitenant full-text search engine with an HTTP Dashboard web-interface (Kibana) and JSON documents scheme. Elasticsearch is a scalable search engine that can be used to search for all types of documents, including log file. Elasticsearch is the heart of the &#039;Elastic Stack&#039; or ELK Stack.&lt;br /&gt;
&lt;br /&gt;
Logstash is an open source tool for managing system events and logs. It provides real-time pipelining to collect data. Logstash will collect the log or data, convert all data into JSON documents, and store them in Elasticsearch.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Kibana is a data visualization interface for Elasticsearch. Kibana provides a pretty dashboard (web interfaces), it allows you to manage and visualize all data from Elasticsearch on your own. It&#039;s not just beautiful, but also powerful.&lt;br /&gt;
&lt;br /&gt;
In this HOW TO, I will show you how to install and configure Elastic Stack on a single Ubuntu 16.04 server for monitoring server logs and how to install &#039;Elastic beats&#039; on client PCs with Ubuntu 16.04 and CentOS 7 operating system.&lt;br /&gt;
&lt;br /&gt;
== Prerequisite ==&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit server with 4GB of RAM, hostname - elk-master&lt;br /&gt;
Ubuntu 16.04 64 bit client with 1 GB of RAM, hostname - elk-client1&lt;br /&gt;
CentOS 7 64 bit client with 1GB of RAM, hostname - elk-client2&lt;/div&gt;</summary>
		<author><name>Mdhasan</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123766</id>
		<title>Logging and monitoring with Elastic stack on Ubuntu 16.04</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=Logging_and_monitoring_with_Elastic_stack_on_Ubuntu_16.04&amp;diff=123766"/>
		<updated>2017-06-19T20:23:01Z</updated>

		<summary type="html">&lt;p&gt;Mdhasan: Created page with &amp;quot;=Introduction= Elasticsearch is an open source search engine based on Lucene, developed in java. It provides a distributed and multitenant full-text search engine with an HTTP...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Introduction=&lt;br /&gt;
Elasticsearch is an open source search engine based on Lucene, developed in java. It provides a distributed and multitenant full-text search engine with an HTTP Dashboard web-interface (Kibana) and JSON documents scheme. Elasticsearch is a scalable search engine that can be used to search for all types of documents, including log file. Elasticsearch is the heart of the &#039;Elastic Stack&#039; or ELK Stack.&lt;br /&gt;
&lt;br /&gt;
Logstash is an open source tool for managing system events and logs. It provides real-time pipelining to collect data. Logstash will collect the log or data, convert all data into JSON documents, and store them in Elasticsearch.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Kibana is a data visualization interface for Elasticsearch. Kibana provides a pretty dashboard (web interfaces), it allows you to manage and visualize all data from Elasticsearch on your own. It&#039;s not just beautiful, but also powerful.&lt;br /&gt;
&lt;br /&gt;
In this HOW TO, I will show you how to install and configure Elastic Stack on a single Ubuntu 16.04 server for monitoring server logs and how to install &#039;Elastic beats&#039; on client PCs with Ubuntu 16.04 and CentOS 7 operating system.&lt;br /&gt;
&lt;br /&gt;
= Prerequisite =&lt;br /&gt;
&lt;br /&gt;
Ubuntu 16.04 64 bit server with 4GB of RAM, hostname - elk-master&lt;br /&gt;
Ubuntu 16.04 64 bit client with 1 GB of RAM, hostname - elk-client1&lt;br /&gt;
CentOS 7 64 bit client with 1GB of RAM, hostname - elk-client2&lt;/div&gt;</summary>
		<author><name>Mdhasan</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=How_to_Integrate_iRedMail_Roundcube_with_Samba4_AD_DC&amp;diff=123643</id>
		<title>How to Integrate iRedMail Roundcube with Samba4 AD DC</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=How_to_Integrate_iRedMail_Roundcube_with_Samba4_AD_DC&amp;diff=123643"/>
		<updated>2017-06-14T13:43:25Z</updated>

		<summary type="html">&lt;p&gt;Mdhasan: /* Sources */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;How to Integrate iRedMail Roundcube with Samba4 AD DC&lt;br /&gt;
&lt;br /&gt;
Page created by : Md Nazmul Hasan&lt;br /&gt;
&lt;br /&gt;
This is part of Authentication and Authorization course. &lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
The idea of this how to is to create a fresh SAMBA Active Directory Domain Controller in virtual Box and integrate iRedmail (mail server) installed on CENT OS 7.    &lt;br /&gt;
&lt;br /&gt;
= Installing Ubuntu server 16.04 on Virtual Box =&lt;br /&gt;
&lt;br /&gt;
- Create a virtual machine and install Ubuntu server 16.04&lt;br /&gt;
[https://www.tecmint.com/installation-of-ubuntu-16-04-server-edition/ click here for installtion guide]&lt;br /&gt;
&lt;br /&gt;
= Virtual box networking =&lt;br /&gt;
For installing Samba we need to set static IP Address on ubuntu server 16.04. So we need to add two network adapter on virtual box. In one adapter we need set the static IP and in another on will be in DHCP to get the internet access.&lt;br /&gt;
&lt;br /&gt;
- &#039;&#039;&#039;Set the first adapter as host only&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Host-only-adapter_in_vm.PNG]]&lt;br /&gt;
&lt;br /&gt;
- &#039;&#039;&#039;Set the second adapter as NAT&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Nat-adapter-in-vm.PNG]]&lt;br /&gt;
&lt;br /&gt;
- Login to Ubuntu server as root&lt;br /&gt;
&lt;br /&gt;
run &amp;lt;code&amp;gt; ifconfig &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make sure that both of the adapter is visible&lt;br /&gt;
&lt;br /&gt;
[[File:Ifconfig-both-adapter.PNG]]&lt;br /&gt;
&lt;br /&gt;
Don&#039;t panic if you cannot see one of the adapter&lt;br /&gt;
&lt;br /&gt;
Now run this command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /etc/network/interfaces &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set static IP on primary network interface and second network interface as DHCP&lt;br /&gt;
&lt;br /&gt;
[[File:Network-interface_in_vm.PNG]]&lt;br /&gt;
&lt;br /&gt;
= Installing Samba4 on Ubuntu server 16.04 =&lt;br /&gt;
&lt;br /&gt;
Now install SAMBA as follows:&lt;br /&gt;
&lt;br /&gt;
[https://www.tecmint.com/install-samba4-active-directory-ubuntu/ Follow the instruction here]&lt;br /&gt;
&lt;br /&gt;
= Installing Windows 10 on Virtual box =&lt;br /&gt;
&lt;br /&gt;
Create another virtual machine with two network adapter.&lt;br /&gt;
&lt;br /&gt;
- Host only and NAT&lt;br /&gt;
&lt;br /&gt;
- Install windows 10 &lt;br /&gt;
&lt;br /&gt;
- Set static IP on first adapter and same DNS server as Ubuntu server 16.04&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Same-dns-server.PNG]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
- Now join the with windows 10 to Samba Domain as follows &lt;br /&gt;
&lt;br /&gt;
[https://www.tecmint.com/manage-samba4-ad-from-windows-via-rsat/  Follow the instructions]&lt;br /&gt;
&lt;br /&gt;
- Restart and login as a domain user &lt;br /&gt;
&lt;br /&gt;
- Now download and install Remote Server Administration Tools for Windows 10 &lt;br /&gt;
&lt;br /&gt;
[https://www.microsoft.com/en-us/download/details.aspx?id=45520 Download RSAT]&lt;br /&gt;
&lt;br /&gt;
- Now open active directory users and computers&lt;br /&gt;
&lt;br /&gt;
- Now you will able to control the Active directory Domain controller from Windows 10 using GUI&lt;br /&gt;
&lt;br /&gt;
= Install CENT OS 7 on virtual box =&lt;br /&gt;
&lt;br /&gt;
Create another virtual machine with two network adapter as like Windows and Ubuntu server&lt;br /&gt;
&lt;br /&gt;
[https://www.tecmint.com/join-centos-7-to-samba4-active-directory/  Follow these instructions to install cent OS 7 and join to Samba domain]&lt;br /&gt;
&lt;br /&gt;
= Install iRedmail on Cent OS=&lt;br /&gt;
&lt;br /&gt;
[https://www.tecmint.com/install-iredmail-on-centos-7-for-samba4-ad-integration/ Follow these instruction to install iRedmail on Cent OS 7]&lt;br /&gt;
&lt;br /&gt;
= Integrate iRedMail Services to Samba4 AD DC =&lt;br /&gt;
&lt;br /&gt;
[https://www.tecmint.com/integrate-iredmail-to-samba4-ad-dc-on-centos-7/ Follow these instructions to integrate iRedmail to Samba4 AD DC]&lt;br /&gt;
&lt;br /&gt;
[https://www.tecmint.com/integrate-iredmail-roundcube-with-samba4-ad-dc/  follow these instructions to Integrate iRedmail Roundcube]&lt;br /&gt;
&lt;br /&gt;
= Conclusion = &lt;br /&gt;
&lt;br /&gt;
Samba AD DC is open source solution to Microsoft Active Directory. iRedmail mail server is great solution for email service.&lt;br /&gt;
&lt;br /&gt;
= Sources =&lt;br /&gt;
[https://www.samba.org/ samba]&lt;br /&gt;
&lt;br /&gt;
[https://www.microsoft.com/en-us/download/details.aspx?id=45520 RSAT]&lt;br /&gt;
&lt;br /&gt;
[https://www.ubuntu.com/download/server Ubuntu server]&lt;br /&gt;
&lt;br /&gt;
[http://www.iredmail.org/ iRedmail]&lt;/div&gt;</summary>
		<author><name>Mdhasan</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=How_to_Integrate_iRedMail_Roundcube_with_Samba4_AD_DC&amp;diff=123640</id>
		<title>How to Integrate iRedMail Roundcube with Samba4 AD DC</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=How_to_Integrate_iRedMail_Roundcube_with_Samba4_AD_DC&amp;diff=123640"/>
		<updated>2017-06-14T13:41:23Z</updated>

		<summary type="html">&lt;p&gt;Mdhasan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;How to Integrate iRedMail Roundcube with Samba4 AD DC&lt;br /&gt;
&lt;br /&gt;
Page created by : Md Nazmul Hasan&lt;br /&gt;
&lt;br /&gt;
This is part of Authentication and Authorization course. &lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
The idea of this how to is to create a fresh SAMBA Active Directory Domain Controller in virtual Box and integrate iRedmail (mail server) installed on CENT OS 7.    &lt;br /&gt;
&lt;br /&gt;
= Installing Ubuntu server 16.04 on Virtual Box =&lt;br /&gt;
&lt;br /&gt;
- Create a virtual machine and install Ubuntu server 16.04&lt;br /&gt;
[https://www.tecmint.com/installation-of-ubuntu-16-04-server-edition/ click here for installtion guide]&lt;br /&gt;
&lt;br /&gt;
= Virtual box networking =&lt;br /&gt;
For installing Samba we need to set static IP Address on ubuntu server 16.04. So we need to add two network adapter on virtual box. In one adapter we need set the static IP and in another on will be in DHCP to get the internet access.&lt;br /&gt;
&lt;br /&gt;
- &#039;&#039;&#039;Set the first adapter as host only&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Host-only-adapter_in_vm.PNG]]&lt;br /&gt;
&lt;br /&gt;
- &#039;&#039;&#039;Set the second adapter as NAT&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Nat-adapter-in-vm.PNG]]&lt;br /&gt;
&lt;br /&gt;
- Login to Ubuntu server as root&lt;br /&gt;
&lt;br /&gt;
run &amp;lt;code&amp;gt; ifconfig &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make sure that both of the adapter is visible&lt;br /&gt;
&lt;br /&gt;
[[File:Ifconfig-both-adapter.PNG]]&lt;br /&gt;
&lt;br /&gt;
Don&#039;t panic if you cannot see one of the adapter&lt;br /&gt;
&lt;br /&gt;
Now run this command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /etc/network/interfaces &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set static IP on primary network interface and second network interface as DHCP&lt;br /&gt;
&lt;br /&gt;
[[File:Network-interface_in_vm.PNG]]&lt;br /&gt;
&lt;br /&gt;
= Installing Samba4 on Ubuntu server 16.04 =&lt;br /&gt;
&lt;br /&gt;
Now install SAMBA as follows:&lt;br /&gt;
&lt;br /&gt;
[https://www.tecmint.com/install-samba4-active-directory-ubuntu/ Follow the instruction here]&lt;br /&gt;
&lt;br /&gt;
= Installing Windows 10 on Virtual box =&lt;br /&gt;
&lt;br /&gt;
Create another virtual machine with two network adapter.&lt;br /&gt;
&lt;br /&gt;
- Host only and NAT&lt;br /&gt;
&lt;br /&gt;
- Install windows 10 &lt;br /&gt;
&lt;br /&gt;
- Set static IP on first adapter and same DNS server as Ubuntu server 16.04&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Same-dns-server.PNG]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
- Now join the with windows 10 to Samba Domain as follows &lt;br /&gt;
&lt;br /&gt;
[https://www.tecmint.com/manage-samba4-ad-from-windows-via-rsat/  Follow the instructions]&lt;br /&gt;
&lt;br /&gt;
- Restart and login as a domain user &lt;br /&gt;
&lt;br /&gt;
- Now download and install Remote Server Administration Tools for Windows 10 &lt;br /&gt;
&lt;br /&gt;
[https://www.microsoft.com/en-us/download/details.aspx?id=45520 Download RSAT]&lt;br /&gt;
&lt;br /&gt;
- Now open active directory users and computers&lt;br /&gt;
&lt;br /&gt;
- Now you will able to control the Active directory Domain controller from Windows 10 using GUI&lt;br /&gt;
&lt;br /&gt;
= Install CENT OS 7 on virtual box =&lt;br /&gt;
&lt;br /&gt;
Create another virtual machine with two network adapter as like Windows and Ubuntu server&lt;br /&gt;
&lt;br /&gt;
[https://www.tecmint.com/join-centos-7-to-samba4-active-directory/  Follow these instructions to install cent OS 7 and join to Samba domain]&lt;br /&gt;
&lt;br /&gt;
= Install iRedmail on Cent OS=&lt;br /&gt;
&lt;br /&gt;
[https://www.tecmint.com/install-iredmail-on-centos-7-for-samba4-ad-integration/ Follow these instruction to install iRedmail on Cent OS 7]&lt;br /&gt;
&lt;br /&gt;
= Integrate iRedMail Services to Samba4 AD DC =&lt;br /&gt;
&lt;br /&gt;
[https://www.tecmint.com/integrate-iredmail-to-samba4-ad-dc-on-centos-7/ Follow these instructions to integrate iRedmail to Samba4 AD DC]&lt;br /&gt;
&lt;br /&gt;
[https://www.tecmint.com/integrate-iredmail-roundcube-with-samba4-ad-dc/  follow these instructions to Integrate iRedmail Roundcube]&lt;br /&gt;
&lt;br /&gt;
= Conclusion = &lt;br /&gt;
&lt;br /&gt;
Samba AD DC is open source solution to Microsoft Active Directory. iRedmail mail server is great solution for email service.&lt;br /&gt;
&lt;br /&gt;
= Sources =&lt;br /&gt;
[https://www.samba.org/]&lt;/div&gt;</summary>
		<author><name>Mdhasan</name></author>
	</entry>
	<entry>
		<id>https://wiki.itcollege.ee/index.php?title=How_to_Integrate_iRedMail_Roundcube_with_Samba4_AD_DC&amp;diff=123635</id>
		<title>How to Integrate iRedMail Roundcube with Samba4 AD DC</title>
		<link rel="alternate" type="text/html" href="https://wiki.itcollege.ee/index.php?title=How_to_Integrate_iRedMail_Roundcube_with_Samba4_AD_DC&amp;diff=123635"/>
		<updated>2017-06-14T13:39:06Z</updated>

		<summary type="html">&lt;p&gt;Mdhasan: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;How to Integrate iRedMail Roundcube with Samba4 AD DC&lt;br /&gt;
&lt;br /&gt;
Page created by : Md Nazmul Hasan&lt;br /&gt;
&lt;br /&gt;
This is part of Authentication and Authorization course. &lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
&lt;br /&gt;
The idea of this how to is to create a fresh SAMBA Active Directory Domain Controller in virtual Box and integrate iRedmail (mail server) installed on CENT OS 7.    &lt;br /&gt;
&lt;br /&gt;
= Installing Ubuntu server 16.04 on Virtual Box =&lt;br /&gt;
&lt;br /&gt;
- Create a virtual machine and install Ubuntu server 16.04&lt;br /&gt;
[https://www.tecmint.com/installation-of-ubuntu-16-04-server-edition/ click here for installtion guide]&lt;br /&gt;
&lt;br /&gt;
= Virtual box networking =&lt;br /&gt;
For installing Samba we need to set static IP Address on ubuntu server 16.04. So we need to add two network adapter on virtual box. In one adapter we need set the static IP and in another on will be in DHCP to get the internet access.&lt;br /&gt;
&lt;br /&gt;
- &#039;&#039;&#039;Set the first adapter as host only&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Host-only-adapter_in_vm.PNG]]&lt;br /&gt;
&lt;br /&gt;
- &#039;&#039;&#039;Set the second adapter as NAT&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
[[File:Nat-adapter-in-vm.PNG]]&lt;br /&gt;
&lt;br /&gt;
- Login to Ubuntu server as root&lt;br /&gt;
&lt;br /&gt;
run &amp;lt;code&amp;gt; ifconfig &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Make sure that both of the adapter is visible&lt;br /&gt;
&lt;br /&gt;
[[File:Ifconfig-both-adapter.PNG]]&lt;br /&gt;
&lt;br /&gt;
Don&#039;t panic if you cannot see one of the adapter&lt;br /&gt;
&lt;br /&gt;
Now run this command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt; nano /etc/network/interfaces &amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Set static IP on primary network interface and second network interface as DHCP&lt;br /&gt;
&lt;br /&gt;
[[File:Network-interface_in_vm.PNG]]&lt;br /&gt;
&lt;br /&gt;
= Installing Samba4 on Ubuntu server 16.04 =&lt;br /&gt;
&lt;br /&gt;
Now install SAMBA as follows:&lt;br /&gt;
&lt;br /&gt;
[https://www.tecmint.com/install-samba4-active-directory-ubuntu/ Follow the instruction here]&lt;br /&gt;
&lt;br /&gt;
= Installing Windows 10 on Virtual box =&lt;br /&gt;
&lt;br /&gt;
Create another virtual machine with two network adapter.&lt;br /&gt;
&lt;br /&gt;
- Host only and NAT&lt;br /&gt;
&lt;br /&gt;
- Install windows 10 &lt;br /&gt;
&lt;br /&gt;
- Set static IP on first adapter and same DNS server as Ubuntu server 16.04&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[File:Same-dns-server.PNG]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
- Now join the with windows 10 to Samba Domain as follows &lt;br /&gt;
&lt;br /&gt;
[https://www.tecmint.com/manage-samba4-ad-from-windows-via-rsat/  Follow the instructions]&lt;br /&gt;
&lt;br /&gt;
- Restart and login as a domain user &lt;br /&gt;
&lt;br /&gt;
- Now download and install Remote Server Administration Tools for Windows 10 &lt;br /&gt;
&lt;br /&gt;
[https://www.microsoft.com/en-us/download/details.aspx?id=45520 Download RSAT]&lt;br /&gt;
&lt;br /&gt;
- Now open active directory users and computers&lt;br /&gt;
&lt;br /&gt;
- Now you will able to control the Active directory Domain controller from Windows 10 using GUI&lt;br /&gt;
&lt;br /&gt;
= Install CENT OS 7 on virtual box =&lt;br /&gt;
&lt;br /&gt;
Create another virtual machine with two network adapter as like Windows and Ubuntu server&lt;br /&gt;
&lt;br /&gt;
[https://www.tecmint.com/join-centos-7-to-samba4-active-directory/  Follow these instructions to install cent OS 7 and join to Samba domain]&lt;br /&gt;
&lt;br /&gt;
= Install iRedmail on Cent OS=&lt;br /&gt;
&lt;br /&gt;
[https://www.tecmint.com/install-iredmail-on-centos-7-for-samba4-ad-integration/ Follow these instruction to install iRedmail on Cent OS 7]&lt;br /&gt;
&lt;br /&gt;
= Integrate iRedMail Services to Samba4 AD DC =&lt;br /&gt;
&lt;br /&gt;
[https://www.tecmint.com/integrate-iredmail-to-samba4-ad-dc-on-centos-7/ Follow these instructions to integrate iRedmail to Samba4 AD DC]&lt;br /&gt;
&lt;br /&gt;
[https://www.tecmint.com/integrate-iredmail-roundcube-with-samba4-ad-dc/  follow these instructions to Integrate iRedmail Roundcube]&lt;br /&gt;
&lt;br /&gt;
= Conclusion = &lt;br /&gt;
&lt;br /&gt;
Samba AD DC is open source solution to Microsoft Active Directory. iRedmail mail server is great solution for email service.&lt;/div&gt;</summary>
		<author><name>Mdhasan</name></author>
	</entry>
</feed>