Graylog & ElasticSearch

Graylog is an open-source log management system that collects, indexes, and analyzes log data from various sources, providing real-time monitoring and alerting. Elasticsearch is a distributed search and analytics engine that efficiently indexes and queries large volumes of structured and unstructured data. Graylog often uses Elasticsearch as its storage and indexing backend for fast log searching and analysis. We will be installing the Graylog & Elastic Search on the Ubuntu 24.04LTS


Installing MongoDB Database (Community Edition)

Mongodb is the database system service which can be integrated by the graylog and which can be installed from the below given URL

Installation Steps :

  1. Importing the key pairs :

sudo apt-get install gnupg curl
curl -fsSL https://www.mongodb.org/static/pgp/server-8.0.asc | \
   sudo gpg -o /usr/share/keyrings/mongodb-server-8.0.gpg \
   --dearmor
  1. Creating the list file

echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-8.0.gpg ] https://repo.mongodb.org/apt/ubuntu noble/mongodb-org/8.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-8.0.list
  1. Reloading the packages database & installing mongodb

sudo apt-get update
sudo apt-get install -y mongodb-org
  1. Registering services & enabling on startup

Here we have installed the mongoDB database and now we will be installing elastic search.


  1. Installing necessary packages

  1. Installing the elastic search GPG Key

  1. Add the Elasticsearch repository to your sources list:

  1. Updating the packages & installing Elastic search

Now the elastic search is installed and now we will configure the elastic search to enable the nodes & clusters to integrate with the graylog server

The configuration file of elasticsearch is located at /etc/elasticsearch/elasticsearch.yml we will add the following lines at the end of config file to enable the cluster :

We will also set the value of parameter xpack.security.enabled: false to disable security pack feature as it might not give outputs as expected.

Now we will restart the service of elastic search

Now we will be creating the new password for the user elastic so that we can manage it using the default credentials.

This will ask the option to display the password as plain text in the console then press y and note the password displayed at the terminal. Now we will check wheather our elastic node is working perfect or not :

The output should look like :

Now we have successfully configured the elastic search node and now we will start configuring the graylog datanode & the graylog server.


Installing Graylog-datanode & Graylog Server

Firstly we will fetch the local repositories file from the graylog repo server

Now we will install the .deb package which was downloaded above using

Once installed the debian package we will now update the repositories & install the necessary packages

Once installed we will start configuring graylog server and integrate with the elastic search datanode which was deployed above.

To run Graylog Data Node, the value of the "vm.max_map_count" sysctl setting needs to be at least 262144 or more. Run the following commands to set and persist the value.

If the value is not the same we can do this by this command :


Configuring Graylog-server

The config file is located on /etc/graylog/server/server.conf , Firstly we will generate the 96 characters long random key and the encrypted password string to feed as input in the config file and then edit certian parameters to run the graylog server.

Generate a secret key for password hashing:

Generate an admin password hash:

We will enter this vaules in the config files where the parameters are password_secret & root_password_sha2

Set Bind Address:

Connect Graylog with Elasticsearch

Start & Enable services:


Configuring datanode

Create your password_secret with the following command:

Edit the config file:

Enter the key just generated in the password_secret to enable the datanode otherwise the datanode might not initialize

Ensure the following parameters are configured properly :

Save and restart:


Accessing the Greylog UI


Troubleshooting

Elastic search version 8.x not supported , Downgrade to 7.10.2

Step 1: Uninstall Elasticsearch 8.x

Step 2: Install Elasticsearch 7.10.2

Step 3: Configure Elasticsearch

Edit the config file:

Modify:

Save and restart:

Step 4: Verify Elasticsearch

Now restart Graylog:


Last updated