{"id":9041,"date":"2022-06-02T20:57:12","date_gmt":"2022-06-03T01:57:12","guid":{"rendered":"https:\/\/www.rushworth.us\/lisa\/?p=9041"},"modified":"2022-06-09T10:38:18","modified_gmt":"2022-06-09T15:38:18","slug":"using-logstash-to-send-data-to-elasticsearch","status":"publish","type":"post","link":"https:\/\/www.rushworth.us\/lisa\/?p=9041","title":{"rendered":"Using Logstash to Send Data to ElasticSearch"},"content":{"rendered":"<p>Create a logstash pipeline<\/p>\n<ol>\n<li>The quickest thing to do is copy the config of a similar use case and adjusted the pipeline port (and adjusted the ES destination index). But, if this is a unique scenario, build a new pipeline configuration. I am creating a TCP listener that receives data from Python using the python-logstash module. In this configuration, logstash will create the index as needed with YYYY-MM-dd appended to the base index name.<br \/>\n<img loading=\"lazy\" decoding=\"async\" width=\"880\" height=\"427\" class=\"wp-image-9042\" src=\"https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2022\/06\/text-description-automatically-generated.png\" alt=\"Text\n\nDescription automatically generated\" srcset=\"https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2022\/06\/text-description-automatically-generated.png 880w, https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2022\/06\/text-description-automatically-generated-300x146.png 300w, https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2022\/06\/text-description-automatically-generated-768x373.png 768w, https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2022\/06\/text-description-automatically-generated-750x364.png 750w\" sizes=\"auto, (max-width: 880px) 100vw, 880px\" \/><\/li>\n<li>Edit the pipelines.yml to register the config you just created<br \/>\n<img loading=\"lazy\" decoding=\"async\" width=\"450\" height=\"60\" class=\"wp-image-9043\" src=\"https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2022\/06\/word-image.png\" srcset=\"https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2022\/06\/word-image.png 450w, https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2022\/06\/word-image-300x40.png 300w\" sizes=\"auto, (max-width: 450px) 100vw, 450px\" \/><\/li>\n<li>Restart logstash to activate the new pipeline<\/li>\n<li>Use netstat -nap | grep `pidof java` to ensure the server is listening on the new port<br \/>\n<img loading=\"lazy\" decoding=\"async\" width=\"775\" height=\"94\" class=\"wp-image-9044\" src=\"https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2022\/06\/word-image-1.png\" srcset=\"https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2022\/06\/word-image-1.png 775w, https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2022\/06\/word-image-1-300x36.png 300w, https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2022\/06\/word-image-1-768x93.png 768w, https:\/\/www.rushworth.us\/lisa\/wp-content\/uploads\/2022\/06\/word-image-1-750x91.png 750w\" sizes=\"auto, (max-width: 775px) 100vw, 775px\" \/><\/li>\n<li>Add the port to the runtime firewalld rules and test that the port is functional (firewall-cmd &#8211;zone=public &#8211;add-port=5055\/tcp)<\/li>\n<li>Assuming the runtime rule has not had any unexpected results, register a permanent firewalld rule (firewall-cmd &#8211;permanent &#8211;zone=public &#8211;add-port=5055\/tcp)<\/li>\n<\/ol>\n<p>We now have a logstash data collector ready. We next need to create the index templates in ES<\/p>\n<ol>\n<li>Log into Kibana<\/li>\n<li>Create an ILM policy \u2013 this policy rolls indices into the warm phase after 2 days and forces merge. It also deletes records after 20 days.<br \/>\n{ &#8220;policy&#8221;: { &#8220;phases&#8221;: { &#8220;hot&#8221;: { &#8220;min_age&#8221;: &#8220;0ms&#8221;, &#8220;actions&#8221;: { &#8220;set_priority&#8221;: { &#8220;priority&#8221;: 100 } } }, &#8220;warm&#8221;: { &#8220;min_age&#8221;: &#8220;2d&#8221;, &#8220;actions&#8221;: { &#8220;forcemerge&#8221;: { &#8220;max_num_segments&#8221;: 1 }, &#8220;set_priority&#8221;: { &#8220;priority&#8221;: 50 } } }, &#8220;delete&#8221;: { &#8220;min_age&#8221;: &#8220;20d&#8221;, &#8220;actions&#8221;: { &#8220;delete&#8221;: {} } } } } }<\/li>\n<li>Create an index template &#8212; define the number of replicas<\/li>\n<li>Send data through the pipeline \u2013 the index will get created per the template definitions and document(s) added to the index<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Create a logstash pipeline The quickest thing to do is copy the config of a similar use case and adjusted the pipeline port (and adjusted the ES destination index). But, if this is a unique scenario, build a new pipeline configuration. I am creating a TCP listener that receives data from Python using the python-logstash &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1588],"tags":[1590,1589,1643],"class_list":["post-9041","post","type-post","status-publish","format-standard","hentry","category-elk","tag-elasticsearch","tag-elk","tag-logstash"],"_links":{"self":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/9041","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=9041"}],"version-history":[{"count":1,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/9041\/revisions"}],"predecessor-version":[{"id":9045,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/9041\/revisions\/9045"}],"wp:attachment":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=9041"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=9041"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=9041"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}