{"id":9014,"date":"2022-05-23T17:29:39","date_gmt":"2022-05-23T22:29:39","guid":{"rendered":"https:\/\/www.rushworth.us\/lisa\/?p=9014"},"modified":"2022-05-23T17:30:20","modified_gmt":"2022-05-23T22:30:20","slug":"python-logging-to-logstash-server","status":"publish","type":"post","link":"https:\/\/www.rushworth.us\/lisa\/?p=9014","title":{"rendered":"Python Logging to Logstash Server"},"content":{"rendered":"\n<p>Since we are having a problem with some of our filebeat servers actually delivering data over to logstash, I put together a really quick python script that connects to the logstash server and sends a log record. I can then <a href=\"https:\/\/www.rushworth.us\/lisa\/?p=9011\" data-type=\"post\" data-id=\"9011\">run tcpdump<\/a> on the logstash server and hopefully see what is going wrong. <\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nimport logging\nimport logstash\nimport sys\n\nstrHost = &#039;logstash.example.com&#039;\niPort = 5048\n\ntest_logger = logging.getLogger(&#039;python-logstash-logger&#039;)\ntest_logger.setLevel(logging.INFO)\ntest_logger.addHandler(logstash.TCPLogstashHandler(host=strHost,port=iPort))\n\ntest_logger.info(&#039;May 22 23:34:13 ABCDOHEFG66SC03 sipd&#x5B;3863cc60] CRITICAL One or more Dns Servers are currently unreachable!&#039;)\ntest_logger.warning(&#039;May 22 23:34:13 ABCDOHEFG66SC03 sipd&#x5B;3863cc60] CRITICAL One or more Dns Servers are currently unreachable!&#039;)\ntest_logger.error(&#039;May 22 23:34:13 ABCDOHEFG66SC03 sipd&#x5B;3863cc60] CRITICAL One or more Dns Servers are currently unreachable!&#039;)\n\n<\/pre><\/div>","protected":false},"excerpt":{"rendered":"<p>Since we are having a problem with some of our filebeat servers actually delivering data over to logstash, I put together a really quick python script that connects to the logstash server and sends a log record. I can then run tcpdump on the logstash server and hopefully see what is going wrong.<\/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,1642,1643],"class_list":["post-9014","post","type-post","status-publish","format-standard","hentry","category-elk","tag-elasticsearch","tag-elk","tag-filebeat","tag-logstash"],"_links":{"self":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/9014","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=9014"}],"version-history":[{"count":2,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/9014\/revisions"}],"predecessor-version":[{"id":9016,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=\/wp\/v2\/posts\/9014\/revisions\/9016"}],"wp:attachment":[{"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=9014"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=9014"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rushworth.us\/lisa\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=9014"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}