Install and Configure Graylog Server to Manage Logs on Linux (2024)

Install and Configure Graylog Server to Manage Logs on Linux (1)

Have you ever wondered about managing big amount of logs? At some point everyone sysadmin has, I believe. The solution is very simple: ‘Configure a Graylog Server.’

In the previous tutorial, I showed how to get started with Buildah to manage your Linux containers. In this tutorial, I’ll show you how to configure a Graylog server to manage a huge amount of log (Big data).

What is Graylog?

Graylog is an Open Source platform for log management. It lets you gather and aggregate the logs from different destinations. It then also enables you to visualize the logs in a web interface.

There are prerequisites to install and configure Graylog server, which are as below:

  1. Installing openJDK
  2. Installing MongoDB
  3. Installing Elasticsearch
Install and Configure Graylog Server to Manage Logs on Linux (2)

The fundamental components of Graylog server are:

MongoDB: A database, which stores configuration and meta information.

Elasticsearch: An engine, which makes searches efficient. Also it stores log messages. It offeres ease for searching. All input/output operations happen in this engine.

GrayLog Server: A parser, which would collect logs from different destinations.

Graylog Web Interface: A dashboard to manage log related configurations using GUI. Web Interface gives more easy and tidy approach to handle the configurations.

Let’s start with the Graylog server installation. We will go through the procedure step by step.

Prerequisite for Graylog server

Let’s first start by installing the required components of Graylog server.

Please note that I am using Red Hat Linux in this tutorial so the installation steps show Yum package manager. If you are using some other distribution, you should use the package manager of your distribution.

Installing openJDK

First we will install openJDK. Why do you need OpenJDK? Because, Elasticsearch is based on Java. You may also use OracleJDK but I prefer the open source version OpenJDK.

# yum install java-1.8.0-openjdk-headless.x86_64 -y# yum install epel-release -y# yum install pwgen -y

Installing Elasticsearch

After installing openJDK, let’s move towards Elasticsearch. This engine plays a fine role inside Graylog server. Elasticsearch engine can store, and search a huge amount of data. This is why it is preferred in handling Big Data.

Elasticsearch fulfills the requirement of applications which need complex searching. Elasticsearch helps to show the message in Graylog Web Interface, whenever user requests a query.

We are going to import the GPG key using the following command:

# rpm --import https://packages.elastic.co/GPG-KEY-elasticsearch

Since default Elasticsearch repository is not available in Centos 7 / Rhel 7, we will need to create repo file manually including below entries in Elasticsearch repo file.

# vi /etc/yum.repos.d/elasticsearch.repo[elasticsearch-2.x]name=Elasticsearch repository for 2.x packagesbaseurl=https://packages.elastic.co/elasticsearch/2.x/centosgpgcheck=1gpgkey=https://packages.elastic.co/GPG-KEY-elasticsearchenabled=1

Now you are ready to install Elasticsearch package.

# yum install elasticsearch -y 

After installing Elasticsearch package, elasticsearch.yml configuration file will be generated, set the cluster name to graylog as below.

# vi /etc/elasticsearch/elasticsearch.ymlcluster.name: graylog

We are all set to start and enable elasticsearch.service

# chkconfig --add elasticsearch# systemctl daemon-reload# systemctl enable elasticsearch.service# systemctl start elasticsearch.service

Once you started and enabled elasticsearch.service ; below curl command should give you output as shown.

curl -XGET 'http://localhost:9200/_cluster/health?pretty=true'{ "cluster_name" : "graylog", "status" : "green", "timed_out" : false, "number_of_nodes" : 1, "number_of_data_nodes" : 1, "active_primary_shards" : 1, "active_shards" : 1, "relocating_shards" : 0, "initializing_shards" : 0, "unassigned_shards" : 0, "delayed_unassigned_shards" : 0, "number_of_pending_tasks" : 0, "number_of_in_flight_fetch" : 0, "task_max_waiting_in_queue_millis" : 0, "active_shards_percent_as_number" : 100.0 } 

Installing MongoDB

We need to add MongoDB repo with below entries in the MongoDB repo file, since it’s not already available by default on Centos 7/ Rhel 7.

 # vi /etc/yum.repos.d/mongodb-org-3.2.repo[mongodb-org-3.2]name=MongoDB Repositorybaseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.2/x86_64/gpgcheck=1enabled=1gpgkey=https://www.mongodb.org/static/pgp/server-3.2.asc

Install MongoDB package.

# yum install mongodb-org -y

Start and enable mongod.service.

# chkconfig --add mongod# systemctl daemon-reload# systemctl enable mongod.service# systemctl start mongod.service

Installing and configuring Grylog server

Install and Configure Graylog Server to Manage Logs on Linux (3)

Once all the prerequisites are done and checked. It’s time to configure and install graylog server. You can download the latest open source version of graylog server from its website.

# rpm -Uvh https://packages.graylog2.org/repo/packages/graylog-2.2-repository_latest.rpm

Install Graylog server:

# yum install graylog-server -y 

Generate a secret key using below command.

# pwgen -N 1 -s 96
D4bqf7doK2zVjFOie043Gk3NgVV1548R7imGV74MHUJa08xvwlNxWvroGjBlQd1mtAYThbym3UNUVFhMY9Wu3CFyKmd35WW

Set a hash password for root user. Note that you will be using this password while signing up at the Graylog Web Interface.

# echo -n YourPassword | sha256sume7cf3ef4f17c3999a94f2c6f612e8a888e5b1026878e4e19398b23bd38ec221a

Now enter the root password and the generated key in the file server.conf. Also add other required parameters.

# vi /etc/graylog/server/server.confpassword_secret = D4bqf7doK2zVjFOie043Gk3NgVV1548R7imGV74MHUJa08xvwlNxWvroGjBlQd1mtAYThbym3UNUVFhMY9Wu3CFyKmd35WWZroot_password_sha2 = e7cf3ef4f17c3999a94f2c6f612e8a888e5b1026878e4e19398b23bd38ec221aroot_email = [emailprotected]root_timezone=UTCelasticsearch_discovery_zen_ping_unicast_hosts = <your-server-ip-address>:9300elasticsearch_shards=1script.inline: falsescript.indexed: falsescript.file: false

Enter these two parameters with specified value in the same file, in order to access Graylog web interface. Graylog web interface will be listening to tcp ports 12900 nd 9000 on web browser.

rest_listen_uri = http://192.168.1.200:12900/web_listen_uri = http://192.168.1.200:9000/
# chkconfig --add graylog-server# systemctl daemon-reload# systemctl enable graylog-server.service# systemctl start graylog-server.service

Configuring firewall ports

We have seen earlier, we mentioned some ports in configuration files for web interface purpose. We are managing those ports with the help of firewall. Below are the steps to add those tcp ports in your firewall settings permanently. Please execute the below commands to manage ports :

# firewall-cmd --permanent --zone=public --add-port=9000/tcp# firewall-cmd --permanent --zone=public --add-port=12900/tcp# firewall-cmd --permanent --zone=public --add-port=1514/tcp

After adding ports in your firewall, do not forget to run below command, in order to reflect the changes you just made.

# firewall-cmd --reload

To manage selinux policy, we are going to install policycoreutils-python packag

# yum install policycoreutils-python -y

Below command makes sure that your web interface has network to be accessed

# setsebool -P httpd_can_network_connect 1

Using semanage command we are going to allow the Graylog REST API and Elasticsearch HTTP API to web interface. If you want to know the semanage command syntax, you can refer to the semanage manpage.

# semanage port -a -t http_port_t -p tcp 9000# semanage port -a -t http_port_t -p tcp 9200

Allowing MongoDB default port.

# semanage port -a -t mongod_port_t -p tcp 27017

Accessing Graylog Web Interface

Open your web browser and type the URL http://your_ip_address:9000. You will be redirected to following page.

Install and Configure Graylog Server to Manage Logs on Linux (4)

To sign in into Graylog web interface, enter the username admin and password – YourPassword (which we have set as mentioned in above command). The default username and password for Graylog web interface is ‘admin’, ‘admin’.

That’s it. Now you can manage your application/server logs in a visual way all thanks to the awesome open source Graylog server.

I hope you find this tutorial helpful. Please leave your suggestions in the comment section.

Written by Servesha Dudhgaonkar

Install and Configure Graylog Server to Manage Logs on Linux (2024)

FAQs

How to send Linux logs to a Graylog server? ›

Configure Graylog to receive logs
  1. Open the Graylog web interface and navigate to System > Inputs.
  2. Choose an input type from the Select input dropdown and click Launch new input. ...
  3. Enter the input parameters in the Launch new input dialog. ...
  4. Click Save, and you will see the new input on the Inputs page shortly after.
Oct 21, 2022

How to install Graylog step by step? ›

How to Install Graylog on Ubuntu 22.04 | Step-by-Step
  1. Step 1: Update the local package index.
  2. Step 2: Install OpenJDK.
  3. Step 3: Install ElasticSearch.
  4. Step 4: Install MongoDB server.
  5. Step 5: Install Graylog server.
  6. Step 5: Configure Nginx as a reverse proxy.
  7. Step 6: Access Graylog web interface.
Feb 29, 2024

How to setup Graylog as Syslog server? ›

HOW TO SETUP GRAYLOG AS A SYSLOG SERVER. After you have Graylog installed, you need to set it up to collect the logs. Go under System -> Inputs menu, and then Launch a new input. Under the Select Input drop-down, pick Syslog UDP, and then pick the Launch new input button.

Where is the Graylog server config? ›

The file server. conf is the Graylog configuration file. The default location for server. conf is: /etc/graylog/server/server.

How to configure logs in Linux? ›

To create your loge file, follow the path below:
  1. Add a log file specification in /etc/rsyslog. conf file.
  2. Restart the rsyslog daemon.
  3. Test the configuration using the logger utility.
Jan 22, 2023

How do I get the logs of my Linux server? ›

How to View Linux Logs? Like any other OS, you can use certain commands to see Linux log files. First, let's switch to the directory where you can find Linux system logs with the command cd /var/log. Then, you can type ls to see the logs stored under this directory.

How do I access my Graylog server? ›

Access the Web Interface

Open a browser and navigate to the URL https://xxx.xxx.xxx.xxx:9000 . Substitute the IP of your Graylog server. If using a VM appliance, log in using admin for both the username and password.

Where are Graylog logs? ›

All log messages ingested by Graylog are indexed (and thus stored) in Elasticsearch. Elasticsearch is a database, and in default it compress the logs, and may be store it in shards.

What is the difference between Graylog and syslog? ›

In the Log Management market, GrayLog has a 1.62% market share in comparison to syslog-ng's 1.05%. Since it has a better market share coverage, GrayLog holds the 8th spot in 6sense's Market Share Ranking Index for the Log Management category, while syslog-ng holds the 11th spot.

How to configure Linux as syslog server? ›

Configuring syslog on Linux OS
  1. Log in to your Linux OS device, as a root user.
  2. Open the /etc/syslog.conf file and add the following facility information: authpriv.*@ <ip_address> Where: ...
  3. Save the file.
  4. Restart syslog by typing the following command: service syslog restart.
  5. Log in to the QRadar product.

How do I add a server to Graylog? ›

You need to have sidecar token, so click on System - Sidecars - click on link Do you need an API token for a sidecar? Create or reuse a token for the graylog-sidecar user.

What is Graylog server? ›

Graylog is a fully integrated open source log management platform for collecting, indexing, and analyzing both structured and unstructured data from almost any source.

What is the default login for Graylog server? ›

If using the VM appliance, log in using admin for both the username and password. If using either container or OS versions of Graylog, log in as admin and use the password from which you derived the password secret when installing Graylog.

Where is the Graylog install location? ›

Graylog
File System Path
Configuration/etc/graylog/server/server.conf
Logging configuration/etc/graylog/server/log4j2.xml
Plugins/usr/share/graylog-server/plugin
Binaries/usr/share/graylog-server/bin
4 more rows

How to send Apache logs to Graylog? ›

As an alternative to rsyslog, you could install Graylog's sidecar on that machine and use filebeats or nxlog to push just the apache logs the to Graylog. I would suggest going through both Graylog documentation and searching this forum for more detail if you go the sidecar route.

How do I export logs from Linux server? ›

Exporting a Log File for a Specific Process
  1. Execute the build using the -d1 command, as follows: ...
  2. In the Build History screen, double-click the required build.
  3. In the Graphical View tab, click the process you want to export.
  4. Click Export Log.
Mar 8, 2023

How do I forward Linux logs to syslog server? ›

Get Logs via Syslog Forwarder from any Log Source
  1. Select the host type as UNIX. ...
  2. Enter the host name(s). ...
  3. Select the host group. ...
  4. Enter the Syslog Listener Port through which the UNIX host(s) will be sending the syslog.
  5. Click Save button to add the host(s).
  6. Use Save & Add More button to add more hosts.

Top Articles
Latest Posts
Article information

Author: Carlyn Walter

Last Updated:

Views: 5921

Rating: 5 / 5 (50 voted)

Reviews: 89% of readers found this page helpful

Author information

Name: Carlyn Walter

Birthday: 1996-01-03

Address: Suite 452 40815 Denyse Extensions, Sengermouth, OR 42374

Phone: +8501809515404

Job: Manufacturing Technician

Hobby: Table tennis, Archery, Vacation, Metal detecting, Yo-yoing, Crocheting, Creative writing

Introduction: My name is Carlyn Walter, I am a lively, glamorous, healthy, clean, powerful, calm, combative person who loves writing and wants to share my knowledge and understanding with you.