{"id":2928,"date":"2022-05-28T00:08:28","date_gmt":"2022-05-28T00:08:28","guid":{"rendered":"https:\/\/dft.wiki\/?p=2928"},"modified":"2026-04-21T13:32:16","modified_gmt":"2026-04-21T17:32:16","slug":"setting-up-a-centralized-los-server-with-graylog-on-ubuntu","status":"publish","type":"post","link":"https:\/\/dft.wiki\/?p=2928","title":{"rendered":"Setting Up a Centralized Log Server with GrayLog on Ubuntu"},"content":{"rendered":"<p>GrayLog is a powerful free open source centralized log management solution for capturing, storing, and enabling real-time analysis.<\/p>\n<p>It is requires at least 4 GB of RAM on the server because it works with a NoSQL database program (MongoDB) plus a search and analytics solution (ElasticSearch) running all side-by-side.<\/p>\n<hr \/>\n<p><strong>SERVER-SIDE UBUNTU 20.04<\/strong><\/p>\n<p>Preparing the system:<\/p>\n<pre>sudo apt update &amp;&amp; sudo apt upgrade -y\r\nsudo apt install bash-completion apt-transport-https uuid-runtime pwgen openjdk-11-jre-headless nano net-tools pwgen -y<\/pre>\n<p>Installing <strong>MongoDB<\/strong>:<\/p>\n<pre>sudo apt install mongodb-server -y\r\nsudo systemctl enable mongodb &amp;&amp; sudo systemctl start mongodb\r\nsudo systemctl --type=service --state=active | grep mongod\r\nsudo netstat -tulpn | grep 27017<\/pre>\n<p>Installing <strong>ElasticSearch<\/strong>:<\/p>\n<pre>wget -qO - https:\/\/artifacts.elastic.co\/GPG-KEY-elasticsearch | sudo apt-key add -\r\necho \"deb https:\/\/artifacts.elastic.co\/packages\/oss-7.x\/apt stable main\" | sudo tee -a \/etc\/apt\/sources.list.d\/elastic-7.x.list\r\nsudo apt update &amp;&amp; sudo apt install elasticsearch-oss -y<\/pre>\n<p>Configuring:<\/p>\n<pre>sudo tee -a \/etc\/elasticsearch\/elasticsearch.yml &gt; \/dev\/null &lt;&lt;EOT\r\ncluster.name: graylog\r\naction.auto_create_index: false\r\nEOT<\/pre>\n<p>Applying and testing:<\/p>\n<pre>sudo systemctl enable elasticsearch &amp;&amp; sudo systemctl restart elasticsearch\r\nsudo systemctl --type=service --state=active | grep elasticsearch\r\nsudo netstat -tulpn | grep 9200<\/pre>\n<p>Installing <strong>GrayLog<\/strong>:<\/p>\n<pre>wget https:\/\/packages.graylog2.org\/repo\/packages\/graylog-4.2-repository_latest.deb\r\nsudo dpkg -i graylog-4.2-repository_latest.deb\r\nsudo apt update &amp;&amp; sudo apt install graylog-server graylog-enterprise-plugins graylog-integrations-plugins graylog-enterprise-integrations-plugins -y<\/pre>\n<p>Generate a hash for the Password Secret:<\/p>\n<pre>pwgen -N 1 -s 96<\/pre>\n<p>Generate the hash for the Admin Password:<\/p>\n<pre>echo -n \"Enter a STRONG Password: \" &amp;&amp; head -1 &lt;\/dev\/stdin | tr -d '\\n' | sha256sum | cut -d\" \" -f1<\/pre>\n<p>Then edit the configuration file:<\/p>\n<pre>sudo nano \/etc\/graylog\/server\/server.conf<\/pre>\n<p>Find the following variables and apply the hashed that you created:<\/p>\n<pre>password_secret = <strong>7Eh8mSFuIA2BWtjBdX6Jkh8m6fVSAhRbz0ONB8rAOVQH281wXuvNeBZBBjPQtU2I3qNuH2ALPK0kFat7djAUYGq6mYfXHIHv<\/strong>\r\nroot_password_sha2 = <strong>2a5d3f2d632a9969faab939ef7889efd7afd4c193c49d40b9f9f7152faec75d3<\/strong>\r\nhttp_bind_address = <strong>0.0.0.0<\/strong>:9000<\/pre>\n<pre>sudo systemctl enable graylog-server &amp;&amp; sudo systemctl start graylog-server\r\nsudo tail -f \/var\/log\/graylog-server\/server.log | grep \"Graylog server up and running\"\r\nsudo systemctl --type=service --state=active | grep graylog\r\nsudo netstat -tulpn | grep 9000\r\ncurl http:\/\/127.0.0.1:9000<\/pre>\n<hr \/>\n<p>Use the browser to navigate to the IP address of the server on port 9000 (e.g. <strong>https:\/\/10.10.10.10:9000<\/strong>) and enter the password you created previously:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-2932 size-full\" src=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2022\/05\/Screenshot_2022-05-27_19-03-37.png\" alt=\"\" width=\"711\" height=\"294\" srcset=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2022\/05\/Screenshot_2022-05-27_19-03-37.png 711w, https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2022\/05\/Screenshot_2022-05-27_19-03-37-300x124.png 300w\" sizes=\"auto, (max-width: 711px) 100vw, 711px\" \/><\/p>\n<p>Navigate to <strong>System<\/strong> &gt; <strong>Inputs<\/strong> &gt; select <strong>Syslog UDP<\/strong> &gt; click on <strong>Lunch New Input<\/strong>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-2934 size-full\" src=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2022\/05\/Screenshot_2022-05-27_19-09-12.png\" alt=\"\" width=\"743\" height=\"572\" srcset=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2022\/05\/Screenshot_2022-05-27_19-09-12.png 743w, https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2022\/05\/Screenshot_2022-05-27_19-09-12-300x231.png 300w\" sizes=\"auto, (max-width: 743px) 100vw, 743px\" \/><\/p>\n<p>Gibe this Local Input a meaningful name and enter the port you want it to listen on:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-2933 size-full\" src=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2022\/05\/Screenshot_2022-05-27_19-11-45.png\" alt=\"\" width=\"606\" height=\"567\" srcset=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2022\/05\/Screenshot_2022-05-27_19-11-45.png 606w, https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2022\/05\/Screenshot_2022-05-27_19-11-45-300x281.png 300w\" sizes=\"auto, (max-width: 606px) 100vw, 606px\" \/><\/p>\n<p>Wait few seconds until it shows the green alert saying it is <strong>Running<\/strong>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-2935 size-full\" src=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2022\/05\/Screenshot_2022-05-27_19-14-29.png\" alt=\"\" width=\"386\" height=\"369\" srcset=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2022\/05\/Screenshot_2022-05-27_19-14-29.png 386w, https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2022\/05\/Screenshot_2022-05-27_19-14-29-300x287.png 300w\" sizes=\"auto, (max-width: 386px) 100vw, 386px\" \/><\/p>\n<p>Now your log server is ready to receive log messages.<\/p>\n<p>Create as many inputs as needed to cover all the needs of your infrastructure.<\/p>\n<p>Consider using Log Relay Server depending on the topology of the network or other constrains.<\/p>\n<hr \/>\n<p><strong>CLIENT-SITE ANY LINUX HOST<\/strong><\/p>\n<p>Configure rsyslog to send the logs to the newly created Log Server (or to the closest Log Relay Server):<\/p>\n<pre>sudo nano \/etc\/rsyslog.conf<\/pre>\n<p>Append this line to the configuration:<\/p>\n<pre>*.* <strong>@10.10.10.10<\/strong>:1514;RSYSLOG_SyslogProtocol23Format<\/pre>\n<p><strong>Note:<\/strong> use <strong>@ for UDP<\/strong> and <strong>@@ for TCP<\/strong>. Replace <strong>10.10.10.10<\/strong> with the IP address of the destination server.<\/p>\n<p>Applying the changes and creating a test entry to the log:<\/p>\n<pre>sudo systemctl restart rsyslog\r\necho \"Log Event Test\" | logger<\/pre>\n<hr \/>\n<p><strong>NAVIGATING THROUGH THE LOG ENTRIES<\/strong><\/p>\n<p>Navigate to <strong>Search<\/strong> &gt; click on the green <strong>Search Button<\/strong>.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-2936 size-full\" src=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2022\/05\/Screenshot_2022-05-27_19-25-05.png\" alt=\"\" width=\"1025\" height=\"653\" srcset=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2022\/05\/Screenshot_2022-05-27_19-25-05.png 1025w, https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2022\/05\/Screenshot_2022-05-27_19-25-05-300x191.png 300w, https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2022\/05\/Screenshot_2022-05-27_19-25-05-768x489.png 768w\" sizes=\"auto, (max-width: 1025px) 100vw, 1025px\" \/><\/p>\n<p>You might be able to see the test log entries forwarded by rsyslog right away.<\/p>\n<p>Select a frequency for auto refresh the search, if you want to see the incoming traffic.<\/p>\n<p>GrayLog&#8217;s search works with Wildcards and RegEx. See emaples:<\/p>\n<ul>\n<li><strong>T??t<\/strong>\n<ul>\n<li>The question mark matches to any character.<\/li>\n<\/ul>\n<\/li>\n<li><strong>T*t<\/strong>\n<ul>\n<li>Asterisk matches with multiple characteres.<\/li>\n<\/ul>\n<\/li>\n<li><strong>\/[3-4]\/<\/strong>\n<ul>\n<li>Looks for a any file in the range using<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<hr \/>\n<p><strong>BONUS<\/strong><\/p>\n<p>Read the post <strong>RegEx CheatSheet<\/strong> at [<a href=\"https:\/\/dft.wiki\/?p=1519\">Link<\/a>].<\/p>\n<p>Read the post <strong>Linux Log Management and Audit<\/strong> [<a href=\"https:\/\/dft.wiki\/?p=2880\">Link<\/a>].<\/p>\n","protected":false},"excerpt":{"rendered":"<p>GrayLog is a powerful free open source centralized log management solution for capturing, storing, and [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-2928","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts\/2928","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2928"}],"version-history":[{"count":10,"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts\/2928\/revisions"}],"predecessor-version":[{"id":5477,"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts\/2928\/revisions\/5477"}],"wp:attachment":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2928"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2928"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2928"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}