\noutput {\n elasticsearch {\n hosts => [\"https:\/\/es-node01.kifarunix-demo.com:9200\"]\n cacert => '\/etc\/logstash\/elasticsearch-ca.crt'\n user => 'elastic'\n password => '<elastic_user_password>'\n }\n}\n<\/code><\/pre>\n\n\n\nThis configuration;<\/p>\n\n\n\n
\n- sends data to Elasticsearch running on host
es-node01.kifarunix-demo.com<\/code><\/strong>. The name should be resolvable.<\/li>\n\n\n\n- Ensure port 9200\/TCP is opened on firewall.<\/li>\n\n\n\n
- uses the superuser Elasticsearch user (
elastic<\/code><\/strong>) which can write to any index. Consider creating a different user and give the specific permissions to write to specific index only<\/strong>. We use the elastic user password from our guide on installing elastic stack 8<\/a>.<\/li>\n\n\n\n- will create and write data to the default Logstash Index,
logstash-*<\/code><\/strong> index on Elasticsearch (since we used the superuser)<\/li>\n<\/ul>\n\n\n\nCheck how to create publishing roles for specific user on a specific index<\/a>.<\/p>\n\n\n\n\n- Download Elasticsearch CA certificate and save it to a file specified by
cacert<\/strong><\/code> parameter above, \/etc\/logstash\/elasticsearch-ca.crt<\/code><\/strong>.<\/li>\n<\/ul>\n\n\n\nopenssl s_client -showcerts -connect es-node01.kifarunix-demo.com:9200 <\/dev\/null 2>\/dev\/null \\\n| openssl x509 > \/etc\/logstash\/elasticsearch-ca.crt<\/code><\/pre>\n\n\n\nPutting togerther the NPUT, FILTER and OUTPUT configs in one file, then create a configuration file as shown below;<\/p>\n\n\n\n
vim \/etc\/logstash\/conf.d\/ssh-authentication.conf<\/pre>\n\n\n\ninput {\n beats {\n port => 5044\n }\n}\nfilter {\n grok {\n match => { \"message\" => \"%{SYSLOGTIMESTAMP:timestamp}\\s+%{IPORHOST:dst_host}\\s+%{WORD:syslog_program}\\[\\d+\\]:\\s+(?<status>\\w+\\s+password)\\s+for\\s+%{USER:auth_user}\\s+from\\s+%{SYSLOGHOST:src_host}.*\" }\n add_field => { \"activity\" => \"SSH Logins\" }\n add_tag => \"linux_auth\"\n }\n if \"_grokparsefailure\" in [tags] { drop {} }\n}\noutput {\n elasticsearch {\n hosts => [\"https:\/\/es-node01.kifarunix-demo.com:9200\"]\n cacert => '\/etc\/logstash\/elasticsearch-ca.crt'\n user => 'elastic'\n password => '<elastic_user_password>'\n }\n}\n<\/code><\/pre>\n\n\n\nYou can also store the password in a keystore instead of placing in the configuration in plaintext<\/a>.<\/p>\n\n\n\nIf you need to sent the event data to standard output for the purposes of debugging plugin configurations, then you would add the line, stdout { codec => rubydebug }<\/strong> to the output configuration section.<\/p>\n\n\n\n\noutput {\n elasticsearch {\n hosts => [\"https:\/\/es-node01.kifarunix-demo.com:9200\"]\n cacert => '\/etc\/logstash\/elasticsearch-ca.crt'\n user => 'elastic'\n password => '<elastic_user_password>'\n }\n}\n stdout { codec => rubydebug }\n}\n<\/code><\/pre>\n\n\n\nYou can also check sample Logstash pipelines here<\/a>.<\/p>\n\n\n\nIf you need to debug Logstash Grok Filters to confirm that they can actually parse your logs into the required fields, see the link below on how to debug Logstash Grok filters.<\/p>\n\n\n\n
How to Debug Logstash Grok Filters<\/a><\/p>\n\n\n\nTest Logstash Configuration<\/h4>\n\n\n\n
Once you are done with configurations, run the command below to verify the Logstash configuration before you can start it.<\/p>\n\n\n\n
sudo -u logstash \/usr\/share\/logstash\/bin\/logstash --path.settings \/etc\/logstash -t<\/code><\/pre>\n\n\n\nConfiguration OK\n<\/strong>[2022-07-16T07:42:10,315][INFO ][logstash.runner ] Using config.test_and_exit mode. Config Validation Result: OK<\/strong>. Exiting Logstash<\/code><\/pre>\n\n\n\nWell, if you get Configuration OK<\/strong> then you are good to go.<\/p>\n\n\n\nTo run Logstash and load a specific configuration file for debugging, you can execute the command below;<\/p>\n\n\n\n
sudo -u logstash \/usr\/share\/logstash\/bin\/logstash -f \/etc\/logstash\/conf.d\/config-file.conf<\/strong><\/code><\/pre>\n\n\n\nRunning Logstash<\/h3>\n\n\n\n
You can now start and enable Logstash to run on system boot.<\/p>\n\n\n\n
systemctl enable --now logstash<\/pre>\n\n\n\nYou can also check the Logstash configuration file for any errors, \/var\/log\/logstash\/logstash-plain.log<\/strong>.<\/p>\n\n\n\ntail -f \/var\/log\/logstash\/logstash-plain.log<\/code><\/pre>\n\n\n\n\n...\n[2022-07-16T10:38:30,215][INFO ][logstash.outputs.elasticsearch][main] Using a default mapping template {:es_version=>8, :ecs_compatibility=>:v8}\n[2022-07-16T10:38:30,450][INFO ][logstash.javapipeline ][main] Starting pipeline {:pipeline_id=>\"main\", \"pipeline.workers\"=>2, \"pipeline.batch.size\"=>125, \"pipeline.batch.delay\"=>50, \"pipeline.max_inflight\"=>250, \"pipeline.sources\"=>[\"\/etc\/logstash\/conf.d\/beats-input.conf\"], :thread=>\"#\"}\n[2022-07-16T10:38:31,130][INFO ][logstash.javapipeline ][main] Pipeline Java execution initialization time {\"seconds\"=>0.68}\n[2022-07-16T10:38:31,157][INFO ][logstash.inputs.beats ][main] Starting input listener {:address=>\"0.0.0.0:5044\"}\n[2022-07-16T10:38:31,197][INFO ][logstash.javapipeline ][main] Pipeline started {\"pipeline.id\"=>\"main\"}\n[2022-07-16T10:38:31,302][INFO ][logstash.agent ] Pipelines running {:count=>1, :running_pipelines=>[:main], :non_running_pipelines=>[]}\n[2022-07-16T10:38:31,495][INFO ][org.logstash.beats.Server][main][a8ac06f266dffa737ca74e142bc94412d96789db1667ea3f32d274fc6578859b] Starting server on port: 5044\n<\/code><\/pre>\n\n\n\nss -altnp<\/code><\/pre>\n\n\n\n\nLISTEN 0 50 [::ffff:127.0.0.1]:9600 *:* users:((\"java\",pid=46795,fd=58)) \nLISTEN 0 4096 *:5044 *:* users:((\"java\",pid=46795,fd=102))\n<\/code><\/pre>\n\n\n\nAnd that is how easy it is to install and run Logstash 8 on Ubuntu\/Debian.<\/p>\n\n\n\n
Other Tutorials<\/h3>\n\n\n\n
Setup Multinode Elasticsearch 8.x Cluster<\/a><\/p>\n\n\n\nConfigure Logstash Elasticsearch Basic Authentication<\/a><\/p>\n\n\n\nLogstash: Write Specific Events to Specific Index<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"This guide is about how to install and configure Logstash 8 on Ubuntu\/Debian as a continuation of our guide on how to setup Elastic Stack<\/p>\n","protected":false},"author":1,"featured_media":8883,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_lock_modified_date":false,"footnotes":""},"categories":[121,72],"tags":[5552,5555,5551,5554,5553],"class_list":["post-13474","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-howtos","category-monitoring","tag-elastic-stack-8-logstash","tag-elk-8","tag-install-logstash-8-on-ubuntu-debian","tag-logstash-8-install","tag-logstash-8-x-install","generate-columns","tablet-grid-50","mobile-grid-100","grid-parent","grid-50","resize-featured-image"],"_links":{"self":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/13474"}],"collection":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/comments?post=13474"}],"version-history":[{"count":6,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/13474\/revisions"}],"predecessor-version":[{"id":20590,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/posts\/13474\/revisions\/20590"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media\/8883"}],"wp:attachment":[{"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/media?parent=13474"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/categories?post=13474"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kifarunix.com\/wp-json\/wp\/v2\/tags?post=13474"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}