-
Log-in into your ElasticSearch sandbox
-
Make sure elastic search is running:
sudo systemctl restart elasticsearch
-
Create a configuration file:
sudo nano /etc/logstash/conf.d/cloud-init.conf
-
Copy-paste settings we have reviewed in the previous slide:
input { file { path => "/var/log/cloud-init.log" start_position => "beginning" type => "logs" } } filter { grok { match=> { "message"=>"%{TIMESTAMP_ISO8601:datetime}%{SPACE}%{SPACE}-%{SPACE} (?<module>(?<= - )(.+)(?=\[))(\[)(?<loglevel>(.+)(?=\]))(\]: )%{GREEDYDATA:message}" } } } output { elasticsearch { hosts => ["http://localhost:9200"] index => "cloud-init" } }
-
Logstash loads all files in the
/etc/logstash/conf.d
directory, store no extra files there -
Restart
logstash
service:sudo systemctl restart logstash
-
Give it a moment
-
Check logstash logs to rule out errors:
sudo tail -f -n 100 /var/log/logstash/logstash-plain.log
-
Verify the data has been populated into elastic search:
curl localhost:9200/cloud-init/_search?pretty=true
-
The expected result is a long list of parsed log events
-
Logstash records position for each file processed, to restart processing locate
sincedb
files:sudo find / -name *.*sincedb*
-
And delete the desired
sincedb
files to restart the ingest process -
In case of troubles, check
/var/log/logstash
log files for errors