[Day 11] 2. LAB Logstash and Kibana
1. Install the File
Install the required package for Logstash or Kibana using the package file provided.
-
Download the file from the server using
.wget -
Install the package:
bashsudo dpkg -i <package_name>
2. Enable Logstash
Ensure Logstash is enabled and running on system boot.
-
Start and enable Logstash:
bashsudo systemctl enable --now logstash sudo systemctl status logstash
3. Edit the Configuration File
Create or modify a Logstash configuration file to specify input and output behavior.
-
Open or create the configuration file:
bashvim pipe1.conf- You can name the file anything, but it must have the extension.
.conf
- You can name the file anything, but it must have the
-
Add the following configuration:
plaintextinput { stdin {} } output { stdout { codec => rubydebug } } -
Test the configuration:
bashecho "Hello World" | sudo /usr/share/logstash/bin/logstash -f /home/shuhari/pipe1.conf
4. Writing the Transform Section
Modify the Logstash configuration file to transform input data.
-
Open the configuration file again:
bashvim pipe1.conf -
Add a filter block to modify the input:
plaintextinput { stdin {} } filter { mutate { uppercase => ["message"] } } output { stdout { codec => rubydebug } } -
Run the command again to verify the transformed output:
bashecho "Hello World" | sudo /usr/share/logstash/bin/logstash -f /home/shuhari/pipe1.conf
5. Checking the Logs of apt
aptView the history of package downloads using
apt-
Run the following command to check the logs:
bashsudo tail /var/log/apt/history.log
6. Processing apt
Logs with Logstash
aptConfigure Logstash to process
apt-
Navigate to the Logstash configuration directory and create a new file:
bashcd /etc/logstash/conf.d/ sudo vim one.conf -
Add the following configuration:
plaintextinput { file { path => "/var/log/apt/history.log" start_position => "end" sincedb_path => "/var/lib/logstash/apt.sincedb" } } filter { if [message] =~ /Commandline:/ { mutate { add_field => { "installation status" => "installed" } } } else { drop { } } } output { elasticsearch { hosts => ["http://localhost:9200"] index => "apt_logs" } stdout { codec => rubydebug } } -
Restart Logstash to apply the configuration:
bashsudo systemctl restart logstash -
Monitor Logstash in a separate terminal:
bashsudo journalctl -f -n 0 -u logstash -
Install a package to see output in the terminal.
-
Verify the Elasticsearch index:
bashcurl -X GET "localhost:9200/_aliases?pretty=true"
7. Installing Kibana
Kibana is a visualization tool designed for Elasticsearch. It helps you create interactive and dynamic dashboards to visually represent data stored in Elasticsearch. With Kibana, you can create various charts, graphs, maps, and other visualizations that make it easier to understand and analyze your data. It's widely used for monitoring and data exploration. In short, Kibana turns your raw data into visual insights!
Install and configure Kibana to visualize data.
-
Download the Kibana installation file (provided by the instructor).
-
Install Kibana:
bashsudo dpkg -i <package_name> -
Check the Kibana status:
bashsudo systemctl status kibana -
If Kibana is not running, edit the configuration file:
bashsudo chmod 755 /etc/kibana sudo vim /etc/kibana/kibana.ymlAdd or modify the following lines:
plaintextserver.port: 5601 server.host: "0.0.0.0" -
Enable and start Kibana:
bashsudo systemctl enable --now kibana sudo systemctl status kibana -
Access Kibana on your browser:
plaintexthttp://<ip>:5601
8. Kibana on Browser
Explore Kibana features to analyze your data visually.
- Open the Kibana dashboard in your browser.
- Navigate through the interface and explore its tools for data visualization.
Read Next
[Day 11] 3. IPSec
### **IPSec (Internet Protocol Security)** **IPSec** is a protocol suite for securing Internet Protocol (IP) communications by authenticating and e...
[Day 11] 4. Nagios Lab with Email Alert
### **Objective** Ensure an email is sent whenever the server fails, or an alert is generated for power consumption or CPU utilization. --- #...