Setup a Logstash server on Ubuntu
Pretty self explanatory and mainly for my own benefit, but easier to follow than the Elastic documentation.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is needed because the Azure Ubuntu build doesn't include the machine name in its hosts file | |
# This causes a delay every time you run sudo as it can't resolve the host name | |
# Once you're in the file, add the machine name to the end of the line "127.0.0.1 localhost" | |
$ sudo nano /etc/hosts | |
# Add the Elastic repository | |
$ wget -qO - https://artifacts.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add - | |
$ echo "deb https://artifacts.elastic.co/packages/6.x/apt stable main" | sudo tee -a /etc/apt/sources.list.d/elastic-6.x.list | |
# Update package list to include Elastic packages | |
$ sudo apt-get update | |
# Install apt-transport-https. Likely already installed so just for safety really | |
$ sudo apt-get install apt-transport-https | |
#Install Java | |
$ sudo apt-get install default-jre | |
#Install logstash | |
$ sudo apt-get install logstash | |
# Update packages and install upgrades one more time for good luck | |
$ sudo apt-get update && apt-get upgrade | |
# Test Logstash | |
# See section below | |
$ sudo -Hu logstash /usr/share/logstash/bin/logstash -e 'input { stdin { } } output { stdout {} }' | |
# Start Logstash service | |
$ sudo systemctl start logstash.service | |
# Check it's running, albeit with errors | |
$ service logstash status | |
#Stop Logstash service and clear the log | |
$ sudo systemctl stop logstash.service | |
$ sudo rm /var/log/logstash/logstash-plain.log | |
#Copy config files from source control to your home folder on the logstash server using WinSCP as per section below on config files | |
#Once that's done proceed as follows with your username | |
$ sudo mv /home/<username>/pipelines.yml /etc/logstash/pipelines.yml | |
$ sudo mv /home/<username>/logstash.yml /etc/logstash/logstash.yml | |
$ sudo mv /home/<username>/app_logs.conf /etc/logstash/conf.d/app_logs.conf | |
# Start Logstash service | |
$ sudo systemctl start logstash.service | |
# Enable Logstash service to run at startup | |
$ sudo systemctl enable logstash.service | |
# Check it's running | |
# You want to see: | |
# Restored connection to ElasticSearch | |
# Pipelines running | |
# Starting server on port: <portnumber from pipelines.yml> | |
# Successfully started Logstash API endpoint | |
$ service logstash status | |
# Now start sending it some logs! |
Comments
Post a Comment