Benutzer-Werkzeuge

Webseiten-Werkzeuge


tachtler:graylog_archlinux

graylog ArchLinux

Graylog ist eine vollständig integrierte Open-Source Protokoll-Management-Plattform für die Erfassung, Indizierung und Analyse von strukturierten und unstrukturierten Daten aus nahezu jeder Quelle. Graylog benötigt nachfolgende externe Komponenten:

Beschreibung Externer Link
Homepage https://www.graylog.org/
Dokumentation https://docs.graylog.org/docs
Download https://www.graylog.org/downloads-2

Ab hier werden zur Ausführung nachfolgender Befehle root-Rechte benötigt. Um der Benutzer root zu werden, melden Sie sich bitte als root-Benutzer am System an, oder wechseln mit nachfolgendem Befehl zum Benutzer root:

$ su -
Password:

Voraussetzungen

Nachfolgende Voraussetzungen müssen vor der Installation von Graylog erfüllt sein, damit Graylog betrieben werden kann:

  • Installiertes JAVA z.B. OpenJDK ab der Version 8
  • Lauffähiger Datenbank-Server MongoDB ab der Version 4.0, 4.2 oder 4.4
  • Lauffähiger Such-Server Elasticsearch ab der Version 6.x oder 7.x

Vorbereitung

Zur Installation von Graylog als pacman-Paket, müssen nachfolgende Repositories genutzt bzw. eingebunden werden:

  • Abhängigkeit von OpenJDK und muss nicht explizit installiert werden
    • jdk11-openjdk - ist im extra-Repository von ArchLinux enthalten.
  • Installation eines Passwort-Generators, hier:
    • pwgen - ist im community-Repository von ArchLinux enthalten.
  • Installation von MongoDB
  • Installation von Elasticsearch
    • elasticsearch-xpack - ist im AUR-Repository von ArchLinux - AUR enthalten.
  • Installation von Graylog

Die Einbindung des AUR-Repositories, kann wie in nachfolgenden internen Link beschrieben

durchgeführt werden.

Installation: pwgen

Mit nachfolgendem Befehl, kann das pacman-Paket - pwgen installiert werden:

# pacman --noconfirm -S pwgen

Installationsverlauf

Mit nachfolgendem Befehl kann überprüft werden, welche Inhalte mit den Paket pwgen installiert wurden.

# pacman -Qil pwgen

Installierte Dateien

Installation: MongoDB

Nachdem das AUR-Repository von ArchLinux - AUR

erfolgreich eingebunden wurde, kann mit nachfolgendem Befehl, das AUR-Paket - mongodb44-bin installiert werden:

# pikaur --noconfirm -S mongodb44-bin

Installationsverlauf

Mit nachfolgendem Befehl kann überprüft werden, welche Inhalte mit den Paket mongodb44-bin installiert wurden:

# pacman -Qil mongodb44-bin

Installierte Dateien

Nachdem das AUR-Repository von ArchLinux - AUR

erfolgreich eingebunden wurde, kann mit nachfolgendem Befehl, das AUR-Paket - mongodb-tools ebenfalls installiert werden:

# pikaur --noconfirm -S mongodb-tools

Installationsverlauf

Mit nachfolgendem Befehl kann überprüft werden, welche Inhalte mit den Paket mongodb-tools installiert wurden:

# pacman -Qil mongodb-tools

Installierte Dateien

MongoDB: Dienst/Deamon-Start einrichten

Um das Datenbank-System MongoDB, welches als Dienst/Deamon als Hintergrundprozess läuft, auch nach einem Neustart des Servers zur Verfügung zu haben, soll der Dienst/Daemon mit dem Server mit gestartet werden, was mit nachfolgendem Befehl realisiert werden kann:

# systemctl enable mongodb.service
Created symlink /etc/systemd/system/multi-user.target.wants/mongodb.service → /usr/lib/systemd/system/mongodb.service.

Eine Überprüfung, ob beim Neustart des Server der mongod-Dienst/Deamon wirklich mit gestartet wird, kann mit nachfolgendem Befehl erfolgen und sollte eine Anzeige, wie ebenfalls nachfolgend dargestellt ausgeben:

# systemctl list-unit-files --type=service | grep -e mongodb.service
mongodb.service                            enabled         disabled

bzw.

# systemctl is-enabled mongodb.service
enabled

MongoDB: Erster Start

Danach kann der mongodb-Server mit nachfolgendem Befehle gestartet werden:

# systemctl start mongodb.service

Mit nachfolgendem Befehl kann der Status des MongoDB-Servers abgefragt werden:

# systemctl status mongodb.service
● mongodb.service - MongoDB Database Server
     Loaded: loaded (/usr/lib/systemd/system/mongodb.service; enabled; vendor p>
     Active: active (running) since Sat 2022-01-29 06:43:59 CET; 7s ago
       Docs: https://docs.mongodb.org/manual
   Main PID: 41061 (mongod)
     Memory: 58.9M
        CPU: 577ms
     CGroup: /system.slice/mongodb.service
             └─41061 /usr/bin/mongod --config /etc/mongodb.conf

Jan 29 06:43:59 server systemd[1]: Started MongoDB Database Server.

Konfiguration: MongoDB

Nach der erfolgreichen Installation von MongoDB sollte noch ein Administrator für alle MongoDB-Server-Datenbanken erstellt werden und ein spezieller Benutzer, welcher über Lese- und Schreibrechte für die MongoDB-Datenbank graylog erhalten soll, damit über diesen eine Authentifizierung an der MongoDB erfolgten kann und dies nicht mehr ohne Benutzernamen und Passwort erfolgen kann.

Benutzer: Administrator anlegen

Zuerst muss in die MongoDB-Console mithilfe des nachfolgenden Befehls gewechselt werden, damit Datenbank spezifische Befehle gegen die MongoDB abgesetzt werden können:

# mongo
MongoDB shell version v4.4.12
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("14c2360a-b387-420e-9dba-e11da8ce2479") }
MongoDB server version: 4.4.12
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
	https://docs.mongodb.com/
Questions? Try the MongoDB Developer Community Forums
	https://community.mongodb.com
---
The server generated these startup warnings when booting: 
        2022-01-29T06:44:00.460+01:00: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted
---
---
        Enable MongoDB's free cloud-based monitoring service, which will then receive and display
        metrics about your deployment (disk utilization, CPU, operation statistics, etc).

        The monitoring data will be available on a MongoDB website with a unique URL accessible to you
        and anyone you share the URL with. MongoDB may use this information to make product
        improvements and to suggest MongoDB products and deployment options to you.

        To enable free monitoring, run the following command: db.enableFreeMonitoring()
        To permanently disable this reminder, run the following command: db.disableFreeMonitoring()
---

Anschließend muss die in die interne Verwaltungsdatenbank von MongoDB gewechselt werden, was mit nachfolgendem Befehl durchgeführt werden kann:

> use admin
switched to db admin

Nun soll ein Administrationsbenutzer für die MongoDB-Server angelegt, was mit nachfolgendem Befehl durchgeführt werden kann:

> db.createUser({user:"admin",pwd:"geheim",roles:[{role:"userAdminAnyDatabase",db:"admin"},{role:"readWriteAnyDatabase",db:"admin"}]})
Successfully added user: {
	"user" : "admin",
	"roles" : [
		{
			"role" : "userAdminAnyDatabase",
			"db" : "admin"
		},
		{
			"role" : "readWriteAnyDatabase",
			"db" : "admin"
		}
	]
}

Abschließend wird die MongoDB-Console mithilfe des nachfolgenden Befehls beendet:

> exit
bye

MongoDB: Stopp

Jetzt muss der mongodb-Server mit nachfolgendem Befehle gestoppt werden:

# systemctl stop mongodb.service

Mit nachfolgendem Befehl kann der Status des MongoDB-Servers abgefragt werden:

# systemctl status mongodb.service
○ mongodb.service - MongoDB Database Server
     Loaded: loaded (/usr/lib/systemd/system/mongodb.service; enabled; vendor p>
     Active: inactive (dead) since Fri 2022-01-29 07:18:15 CET; 4s ago
       Docs: https://docs.mongodb.org/manual
    Process: 5957 ExecStart=/usr/bin/mongod --config /etc/mongodb.conf (code=ex>
   Main PID: 5957 (code=exited, status=0/SUCCESS)
        CPU: 3.169s

Jan 29 07:18:00 server systemd[1]: Started MongoDB Database Server.
Jan 29 07:18:15 server systemd[1]: Stopping MongoDB Database Server...
Jan 29 07:18:15 server systemd[1]: mongodb.service: Deactivated successfully.
Jan 29 07:18:15 server systemd[1]: Stopped MongoDB Database Server.
Jan 29 07:18:15 server systemd[1]: mongodb.service: Consumed 3.169s CPU time.

/etc/mongodb.conf - IPv6 aktivieren

Nachfolgende Änderung ermöglicht, dass die MongoDB auch via IPv6 erreichbar ist. Dies ist erforderlich, wenn keine Anpassungen am Startverhalten von Graylog durchgeführt werden sollen!

Nachfolgende Änderungen müssen dafür in der Konfigurationsdatei

  • /etc/mongodb.conf

durchgeführt werden:

(Nur relevanter Ausschnitt):

# network interfaces
net:
  # Tachtler - NEW -
  ipv6: true
  port: 27017
  # Tachtler
  # default: bindIp: 127.0.0.1
  bindIp: 127.0.0.1,::1

Siehe auch nachfolgenden externen Link:

/etc/mongodb.conf - Authentifizierung erzwingen

Nachfolgende Konfiguration erzwingt die Authentifizieren gegen die MongoDB.

:!: HINWEIS - Ein Zugriff auf die MongoDB ohne Benutzername und dazugehörigen Passwort, sollten danach nicht mehr möglich sein!

Nachfolgende Änderungen müssen dafür in der Konfigurationsdatei

  • /etc/mongodb.conf

durchgeführt werden:

(Nur relevanter Ausschnitt):

# Tachtler
# default: #security:
security:
  authorization: enabled

MongoDB: Start

Danach kann der mongodb-Server mit nachfolgendem Befehle wieder gestartet werden:

# systemctl start mongodb.service

Mit nachfolgendem Befehl kann der Status des MongoDB-Servers abgefragt werden:

# systemctl status mongodb.service 
● mongodb.service - MongoDB Database Server
     Loaded: loaded (/usr/lib/systemd/system/mongodb.service; enabled; vendor p>
     Active: active (running) since Sat 2022-01-29 07:25:40 CET; 7s ago
       Docs: https://docs.mongodb.org/manual
   Main PID: 41255 (mongod)
     Memory: 156.6M
        CPU: 647ms
     CGroup: /system.slice/mongodb.service
             └─41255 /usr/bin/mongod --config /etc/mongodb.conf

Jan 29 07:25:40 server systemd[1]: Started MongoDB Database Server.

Benutzer: "grayloguser" anlegen

Zuerst muss wieder in die MongoDB-Console mithilfe des nachfolgenden Befehls gewechselt werden, damit Datenbank spezifische Befehle gegen die MongoDB abgesetzt werden können:

# mongo --authenticationDatabase admin -u admin -p
MongoDB shell version v4.4.12
Enter password: 
connecting to: mongodb://127.0.0.1:27017/?authSource=admin&compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("4447a6f0-86d3-4a8c-8b56-2b887f862fc8") }
MongoDB server version: 4.4.12

Anschließend muss die Datenbank von MongoDB gewechselt werden, für die eine Benutzer mit Passwort angelegt werden soll, was mit nachfolgendem Befehl durchgeführt werden kann:

> use graylog
switched to db graylog

Nun soll ein „grayloguser“-Benutzer für die MongoDB-Server angelegt, was mit nachfolgendem Befehl durchgeführt werden kann:

> db.createUser({user:"grayloguser",pwd:"geheim",roles:[{role:"readWrite",db:"graylog"}]})
Successfully added user: {
	"user" : "grayloguser",
	"roles" : [
		{
			"role" : "readWrite",
			"db" : "graylog"
		}
	]
}

Abschließend wird die MongoDB-Console mithilfe des nachfolgenden Befehls beendet:

> exit
bye

MongoDB: Test

Ein Verbindungstest kann durchgeführt werden, indem die MongoDB-shell aufgerufen wird, was mit nachfolgendem Befehl durchgeführt werden kann:

# mongo --authenticationDatabase graylog -u grayloguser -p
MongoDB shell version v4.4.12
Enter password: 
connecting to: mongodb://127.0.0.1:27017/?authSource=graylog&compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("78a7ef24-7420-41b0-ab18-dafb745887a5") }
MongoDB server version: 4.4.12

Abschließend wird die MongoDB-Console mithilfe des nachfolgenden Befehls beendet:

> exit
bye

Installation: Elasticsearch

Nachdem das AUR-Repository von ArchLinux - AUR

erfolgreich eingebunden wurde, kann mit nachfolgendem Befehl, das AUR-Paket - elasticsearch-xpack installiert werden:

:!: HINWEIS - Aufgrund aktueller Probleme bei der Installation via pikaur wird hier eine manuelle Installation des AUR-Repository-Paket elasticsearch-xpack durchgeführt!
Gitgub | actionless/pikaur The installation of a package does not work, because there may be a problem with systemd DynamicUsers. #621

Mit nachfolgendem Befehl wird ein Verzeichnis erstellt, in dem das AUR-Paket - elasticsearch-xpack installiert werden kann

# mkdir /var/cache/makepkg

Anschliessend sollen die Besitzrechte an dem Verzeichnis einem unprivilegiertem Benutzer - hier: klaus übertragen werden, da die spätere Ausführung des Befehls makepg nur durch einen unprivilegierten Benutzer erfolgen kann:

# chown klaus:klaus /var/cache/makepkg

Anschliessend soll wieder zum Benutzer, hier: klaus gewechselt werden, was mit nachfolgendem Befehl durchführt werden kann:

# exit
logout

Als Benutzer, hier: klaus kann nun in das Verzeichnis /var/cache/makepkg gewechselt werden:

$ cd /var/cache/makepkg

Mit nachfolgendem Befehl kann nun das AUR-Repository-Paket elasticsearch-xpack heruntergeladen werden:

$ git clone https://aur.archlinux.org/elasticsearch-xpack.git
Cloning into 'elasticsearch-xpack'...
remote: Enumerating objects: 215, done.
remote: Counting objects: 100% (215/215), done.
remote: Compressing objects: 100% (83/83), done.
remote: Total 215 (delta 133), reused 207 (delta 129), pack-reused 0
Receiving objects: 100% (215/215), 56.05 KiB | 883.00 KiB/s, done.
Resolving deltas: 100% (133/133), done.

Anschliessend muss in das so neu entstandene Verzeichnis /var/cache/makepkg/elasticsearch-xpack mit nachfolgendem Befehl gewechselt werden:

$ cd /var/cache/makepkg/elasticsearch-xpack 

Der nachfolgende Befehl listet den Inhalt des Verzeichnisses /var/cache/makepkg/elasticsearch-xpack auf:

$ ls -l
total 44
-rw-r--r-- 1 klaus klaus  218 Jan 29 08:17 elasticsearch.default
-rw-r--r-- 1 klaus klaus 1668 Jan 29 08:17 elasticsearch-env
-rw-r--r-- 1 klaus klaus  261 Jan 29 08:17 elasticsearch-keystore.service
-rw-r--r-- 1 klaus klaus  311 Jan 29 08:17 elasticsearch-keystore@.service
-rw-r--r-- 1 klaus klaus 1844 Jan 29 08:17 elasticsearch.service
-rw-r--r-- 1 klaus klaus 1879 Jan 29 08:17 elasticsearch@.service
-rw-r--r-- 1 klaus klaus   23 Jan 29 08:17 elasticsearch-sysctl.conf
-rw-r--r-- 1 klaus klaus  345 Jan 29 08:17 elasticsearch-tmpfile.conf
-rw-r--r-- 1 klaus klaus   39 Jan 29 08:17 elasticsearch-user.conf
-rw-r--r-- 1 klaus klaus 4949 Jan 29 08:17 PKGBUILD

Als letzten vorbereitenden Schritt, soll nur noch der GPG-Schlüssel von Elasticsearch (Elasticsearch Signing Key) dev_ops@elasticsearch.org mit nachfolgendem Befehl importiert werden, um die Authentizität des Paketes zu bestätigen:

$ curl -sS https://artifacts.elastic.co/GPG-KEY-elasticsearch | gpg --import -
gpg: directory '/home/klaus/.gnupg' created
gpg: keybox '/home/klaus/.gnupg/pubring.kbx' created
gpg: /home/klaus/.gnupg/trustdb.gpg: trustdb created
gpg: key D27D666CD88E42B4: public key "Elasticsearch (Elasticsearch Signing Key) <dev_ops@elasticsearch.org>" imported
gpg: Total number processed: 1
gpg:               imported: 1

Nachfolgender Befehl erzeugt nun das pacman-Paket, welches später, bewusst mit einem zweiten Befehl installiert werden soll:

:!: WICHTIG - Der verwendete Benutzer, hier: klaus muss das sudo-Recht besitzen!

$ makepkg -cCfs

Kompilierungsverlauf

Das erneute Auflisten des Inhalts des Verzeichnisses /var/cache/makepkg/elasticsearch-xpack, sollte nun die erstellten pacman-Pakete entahlten, was mit nachfolgendem Befehl überprüft werden kann:

$ ls -l
total 465540
-rw-r--r-- 1 klaus klaus 311430167 Jan 29 08:28 elasticsearch-7.16.3-x86_64.rpm
-rw-r--r-- 1 klaus klaus       488 Jan 29 08:28 elasticsearch-7.16.3-x86_64.rpm.asc
-rw-r--r-- 1 klaus klaus       218 Jan 29 08:17 elasticsearch.default
-rw-r--r-- 1 klaus klaus      1668 Jan 29 08:17 elasticsearch-env
-rw-r--r-- 1 klaus klaus       261 Jan 29 08:17 elasticsearch-keystore.service
-rw-r--r-- 1 klaus klaus       311 Jan 29 08:17 elasticsearch-keystore@.service
-rw-r--r-- 1 klaus klaus      1844 Jan 29 08:17 elasticsearch.service
-rw-r--r-- 1 klaus klaus      1879 Jan 29 08:17 elasticsearch@.service
-rw-r--r-- 1 klaus klaus        23 Jan 29 08:17 elasticsearch-sysctl.conf
-rw-r--r-- 1 klaus klaus       345 Jan 29 08:17 elasticsearch-tmpfile.conf
-rw-r--r-- 1 klaus klaus        39 Jan 29 08:17 elasticsearch-user.conf
-rw-r--r-- 1 klaus klaus 165231016 Jan 29 08:28 elasticsearch-xpack-7.16.3-1-x86_64.pkg.tar.zst
-rw-r--r-- 1 klaus klaus      4949 Jan 29 08:17 PKGBUILD

Ab hier werden zur Ausführung nachfolgender Befehle root-Rechte benötigt. Um der Benutzer root zu werden, melden Sie sich bitte als root-Benutzer am System an, oder wechseln mit nachfolgendem Befehl zum Benutzer root:

$ su -
Password:

Nachfolgemder Befehl führt nun die Installation des soeben erstellten pacman-Pakets durch:

# pacman -U /var/cache/makepkg/elasticsearch-xpack/elasticsearch-xpack-7.16.3-1-x86_64.pkg.tar.zst

Installationsverlauf

Mit nachfolgendem Befehl kann überprüft werden, welche Inhalte mit den Paket elasticsearch-xpack installiert wurden:

# pacman -Qil elasticsearch-xpack

Installierte Dateien

Elasticsearch: Dienst/Deamon-Start einrichten

Um das Suchdienst-System Elasticsearch, welches als Dienst/Deamon als Hintergrundprozess läuft, auch nach einem Neustart des Servers zur Verfügung zu haben, soll der Dienst/Daemon mit dem Server mit gestartet werden, was mit nachfolgendem Befehl realisiert werden kann:

# systemctl enable elasticsearch.service 
Created symlink /etc/systemd/system/multi-user.target.wants/elasticsearch.service → /usr/lib/systemd/system/elasticsearch.service.

Eine Überprüfung, ob beim Neustart des Server der elasticsearch-Dienst/Deamon wirklich mit gestartet wird, kann mit nachfolgendem Befehl erfolgen und sollte eine Anzeige, wie ebenfalls nachfolgend dargestellt ausgeben:

# systemctl list-unit-files --type=service | grep -e elasticsearch.service
elasticsearch.service                      enabled         disabled

bzw.

# systemctl is-enabled elasticsearch.service
enabled

Konfiguration: Elasticsearch

/etc/elasticsearch/elasticsearch.yml

Bevor der Dienst/Daemon von Elasticsearch gestartet werden kann, ist nachfolgende Konfiguration in der Konfigurationsdatei

  • /etc/elasticsearch/elasticsearch.yml

durchzuführen:

(Komplette Konfigurationsdatei):

# ======================== Elasticsearch Configuration =========================
#
# NOTE: Elasticsearch comes with reasonable defaults for most settings.
#       Before you set out to tweak and tune the configuration, make sure you
#       understand what are you trying to accomplish and the consequences.
#
# The primary way of configuring a node is via this file. This template lists
# the most important settings you may want to configure for a production cluster.
#
# Please consult the documentation for further information on configuration options:
# https://www.elastic.co/guide/en/elasticsearch/reference/index.html
#
# ---------------------------------- Cluster -----------------------------------
#
# Use a descriptive name for your cluster:
#
# Tachtler
# default: #cluster.name: my-application
cluster.name: graylog
#
# ------------------------------------ Node ------------------------------------
#
# Use a descriptive name for the node:
#
#node.name: node-1
#
# Add custom attributes to the node:
#
#node.attr.rack: r1
#
# ----------------------------------- Paths ------------------------------------
#
# Path to directory where to store the data (separate multiple locations by comma):
#
path.data: /var/lib/elasticsearch
#
# Path to log files:
#
path.logs: /var/log/elasticsearch
#
# ----------------------------------- Memory -----------------------------------
#
# Lock the memory on startup:
#
#bootstrap.memory_lock: true
#
# Make sure that the heap size is set to about half the memory available
# on the system and that the owner of the process is allowed to use this
# limit.
#
# Elasticsearch performs poorly when the system is swapping the memory.
#
# ---------------------------------- Network -----------------------------------
#
# By default Elasticsearch is only accessible on localhost. Set a different
# address here to expose this node on the network:
#
#network.host: 192.168.0.1
#
# By default Elasticsearch listens for HTTP traffic on the first free port it
# finds starting at 9200. Set a specific HTTP port here:
#
#http.port: 9200
#
# For more information, consult the network module documentation.
#
# --------------------------------- Discovery ----------------------------------
#
# Pass an initial list of hosts to perform discovery when this node is started:
# The default list of hosts is ["127.0.0.1", "[::1]"]
#
#discovery.seed_hosts: ["host1", "host2"]
#
# Bootstrap the cluster using an initial set of master-eligible nodes:
#
#cluster.initial_master_nodes: ["node-1", "node-2"]
#
# For more information, consult the discovery and cluster formation module documentation.
#
# ---------------------------------- Various -----------------------------------
#
# Require explicit names when deleting indices:
#
#action.destructive_requires_name: true
#
# ---------------------------------- Security ----------------------------------
#
#                                 *** WARNING ***
#
# Elasticsearch security features are not enabled by default.
# These features are free, but require configuration changes to enable them.
# This means that users don’t have to provide credentials and can get full access
# to the cluster. Network connections are also not encrypted.
#
# To protect your data, we strongly encourage you to enable the Elasticsearch security features. 
# Refer to the following documentation for instructions.
#
# https://www.elastic.co/guide/en/elasticsearch/reference/7.16/configuring-stack-security.html
 
# Tachtler
xpack.security.enabled: true
discovery.type: single-node

Nachfolgende Änderungen wurden durchgeführt:

  • cluster.name: graylog

Setzen des cluster-Namen für den Zugriff durch Graylog.

:!: HINWEIS - Dies ist grundsätzlich die einzige relevante Änderung

  • xpack.security.enabled: true

Aktivieren der Sicherheitsmechanismen, welche mit dem X-Pack mitgeliefert werden.

  • discovery.type: single-node

Setzen des Typs, um welche Art von Installation und um welchen Betrieb es sich handelt.

Elasticsearch: Erster Start

Danach kann der elasticsearch-Server mit nachfolgendem Befehle gestartet werden:

# systemctl start elasticsearch.service

* Dies kann ein wenig dauern!

Mit nachfolgendem Befehl kann der Status des Elasticsearch-Servers abgefragt werden:

# systemctl status elasticsearch.service 
● elasticsearch.service - Elasticsearch
     Loaded: loaded (/usr/lib/systemd/system/elasticsearch.service; enabled; ve>
     Active: active (running) since Sat 2022-01-29 08:55:27 CET; 40s ago
       Docs: http://www.elastic.co
    Process: 67812 ExecStartPre=/usr/share/elasticsearch/bin/elasticsearch-keys>
   Main PID: 67884 (java)
      Tasks: 68 (limit: 2341)
     Memory: 1.4G
        CPU: 34.122s
     CGroup: /system.slice/elasticsearch.service
             ├─67884 /usr/lib/jvm/default-runtime/bin/java -Xshare:auto -Des.ne>
             └─68058 /usr/share/elasticsearch/modules/x-pack-ml/platform/linux->

Jan 29 08:55:37 server elasticsearch[67884]: [2022-01-29T08:55:37,566][INFO ][o>
Jan 29 08:55:37 server elasticsearch[67884]: [2022-01-29T08:55:37,567][INFO ][o>
Jan 29 08:55:37 server elasticsearch[67884]: [2022-01-29T08:55:37,738][INFO ][o>
Jan 29 08:55:37 server elasticsearch[67884]: [2022-01-29T08:55:37,745][INFO ][o>
Jan 29 08:55:38 server elasticsearch[67884]: [2022-01-29T08:55:38,086][INFO ][o>
Jan 29 08:55:38 server elasticsearch[67884]: [2022-01-29T08:55:38,282][INFO ][o>
Jan 29 08:55:38 server elasticsearch[67884]: [2022-01-29T08:55:38,474][INFO ][o>
Jan 29 08:55:38 server elasticsearch[67884]: [2022-01-29T08:55:38,643][INFO ][o>
Jan 29 08:55:38 server elasticsearch[67884]: [2022-01-29T08:55:38,696][INFO ][o>
Jan 29 08:55:38 server elasticsearch[67884]: [2022-01-29T08:55:38,737][INFO ][o>

Elasticsearch: Test

Ein Verbindungstest kann durchgeführt werden, in dem Elasticsearch über den Kommunikation-URL und -Port http://localhost:9200 entsprechend aufgerufen wird, was mit nachfolgendem Befehl durchgeführt werden kann:

# curl -X GET http://localhost:9200
{
  "name" : "server",
  "cluster_name" : "graylog",
  "cluster_uuid" : "JUqE2lPJQRGPhwGTRBvDfA",
  "version" : {
    "number" : "7.16.3",
    "build_flavor" : "default",
    "build_type" : "rpm",
    "build_hash" : "4e6e4eab2297e949ec994e688dad46290d018022",
    "build_date" : "2022-01-06T23:43:02.825887787Z",
    "build_snapshot" : false,
    "lucene_version" : "8.10.1",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}

bzw.

# curl -X GET '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" : 3,
  "active_shards" : 3,
  "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
}

Elasticsearch: Passwortabsicherung

Nachfolgender Befehl führt eine interaktive Passwortabfrage für die Benutzer:

  • elastic
  • apm_system
  • kibana_system
  • logstash_system
  • beats_system
  • remote_monitoring_user

durch:

# elasticsearch-setup-passwords interactive
Initiating the setup of passwords for reserved users
elastic,apm_system,kibana,kibana_system,logstash_system,beats_system,remote_monitoring_user.
You will be prompted to enter passwords as the process progresses.
Please confirm that you would like to continue [y/N]y


Enter password for [elastic]: 
Reenter password for [elastic]: 
Enter password for [apm_system]: 
Reenter password for [apm_system]: 
Enter password for [kibana_system]: 
Reenter password for [kibana_system]: 
Enter password for [logstash_system]: 
Reenter password for [logstash_system]: 
Enter password for [beats_system]: 
Reenter password for [beats_system]: 
Enter password for [remote_monitoring_user]: 
Reenter password for [remote_monitoring_user]: 
Changed password for user [apm_system]
Changed password for user [kibana_system]
Changed password for user [kibana]
Changed password for user [logstash_system]
Changed password for user [beats_system]
Changed password for user [remote_monitoring_user]
Changed password for user [elastic]

:!: HINWEIS - Ein Zugriff auf Elasticsearch ohne Benutzername und dazugehörigen Passwort, sollten danach nicht mehr möglich sein!

Ein Verbindungstest kann jetzt nur noch in Verbindung mit einem Benutzernamen und dem dazugehörigen Passwort durchgeführt werden, in dem Elasticsearch über den Kommunikation-URL und -Port http://localhost:9200 entsprechend aufgerufen wird, was mit nachfolgendem Befehl durchgeführt werden kann:

# curl -X GET http://localhost:9200 -u elastic -p
Enter host password for user 'elastic':
{
  "name" : "server",
  "cluster_name" : "graylog",
  "cluster_uuid" : "JUqE2lPJQRGPhwGTRBvDfA",
  "version" : {
    "number" : "7.16.3",
    "build_flavor" : "default",
    "build_type" : "rpm",
    "build_hash" : "4e6e4eab2297e949ec994e688dad46290d018022",
    "build_date" : "2022-01-06T23:43:02.825887787Z",
    "build_snapshot" : false,
    "lucene_version" : "8.10.1",
    "minimum_wire_compatibility_version" : "6.8.0",
    "minimum_index_compatibility_version" : "6.0.0-beta1"
  },
  "tagline" : "You Know, for Search"
}

bzw.

# curl -X GET 'http://localhost:9200/_cluster/health?pretty=true' -u elastic -p
Enter host password for user 'elastic':
{
  "cluster_name" : "graylog",
  "status" : "green",
  "timed_out" : false,
  "number_of_nodes" : 1,
  "number_of_data_nodes" : 1,
  "active_primary_shards" : 4,
  "active_shards" : 4,
  "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
}

Installation: Graylog

Nachdem das AUR-Repository von ArchLinux - AUR

erfolgreich eingebunden wurde, kann mit nachfolgendem Befehl, das AUR-Paket - graylog installiert werden:

# pikaur --noconfirm -S graylog

Installationsverlauf

:!: HINWEIS - Der Fehler

error: command failed to execute correctly

kann hier ignoriert werden, da dies nur die Überprüfung der Abhängigkeiten betrifft.

Mit nachfolgendem Befehl kann überprüft werden, welche Inhalte mit den Paket graylog installiert wurden.

# pacman -Qil graylog

Installierte Dateien

Graylog: Dienst/Deamon-Start einrichten

Um Graylog, welches als Dienst/Deamon als Hintergrundprozess läuft, auch nach einem Neustart des Servers zur Verfügung zu haben, soll der Dienst/Daemon mit dem Server mit gestartet werden, was mit nachfolgendem Befehl realisiert werden kann:

# systemctl enable graylog.service
Created symlink /etc/systemd/system/multi-user.target.wants/graylog.service → /usr/lib/systemd/system/graylog.service.

Eine Überprüfung, ob beim Neustart des Server der graylog-Dienst/Deamon wirklich mit gestartet wird, kann mit nachfolgendem Befehl erfolgen und sollte eine Anzeige, wie ebenfalls nachfolgend dargestellt ausgeben:

# systemctl list-unit-files --type=service | grep -e graylog.service
graylog.service                            enabled         disabled

bzw.

# systemctl is-enabled graylog.service
enabled

Konfiguration: Graylog

/etc/graylog/server/server.conf

Nachfolgende Konfigurationsdatei ist die Hauptkonfigurationsdatei des Graylog-Servers:

  • /etc/graylog/server/server.conf

Nachfolgende Anpassungen sind erforderlich, damit der Graylog-Server lauffähig ist:

(Komplette Konfigurationsdatei):

############################
# GRAYLOG CONFIGURATION FILE
############################
#
# This is the Graylog configuration file. The file has to use ISO 8859-1/Latin-1 character encoding.
# Characters that cannot be directly represented in this encoding can be written using Unicode escapes
# as defined in https://docs.oracle.com/javase/specs/jls/se8/html/jls-3.html#jls-3.3, using the \u prefix.
# For example, \u002c.
#
# * Entries are generally expected to be a single line of the form, one of the following:
#
# propertyName=propertyValue
# propertyName:propertyValue
#
# * White space that appears between the property name and property value is ignored,
#   so the following are equivalent:
#
# name=Stephen
# name = Stephen
#
# * White space at the beginning of the line is also ignored.
#
# * Lines that start with the comment characters ! or # are ignored. Blank lines are also ignored.
#
# * The property value is generally terminated by the end of the line. White space following the
#   property value is not ignored, and is treated as part of the property value.
#
# * A property value can span several lines if each line is terminated by a backslash (‘\’) character.
#   For example:
#
# targetCities=\
#         Detroit,\
#         Chicago,\
#         Los Angeles
#
#   This is equivalent to targetCities=Detroit,Chicago,Los Angeles (white space at the beginning of lines is ignored).
#
# * The characters newline, carriage return, and tab can be inserted with characters \n, \r, and \t, respectively.
#
# * The backslash character must be escaped as a double backslash. For example:
#
# path=c:\\docs\\doc1
#
 
# If you are running more than one instances of Graylog server you have to select one of these
# instances as master. The master will perform some periodical tasks that non-masters won't perform.
is_master = true
 
# The auto-generated node ID will be stored in this file and read after restarts. It is a good idea
# to use an absolute file path here if you are starting Graylog server from init scripts or similar.
node_id_file = /etc/graylog/server/node-id
 
# You MUST set a secret to secure/pepper the stored user passwords here. Use at least 64 characters.
# Generate one by using for example: pwgen -N 1 -s 96
# ATTENTION: This value must be the same on all Graylog nodes in the cluster.
# Changing this value after installation will render all user sessions and encrypted values in the database invalid. (e.g. encrypted access tokens)
# Tachtler
# default: password_secret =
password_secret = ndyRpQps9TVbramSXqVTZp42lzS9OUvy2Fn5lVxTmrxnwTR2OR1j94SYoIT2OMNxksq4OJO7hasBqFVU5U9TpkrEgccxoeWc
 
# The default root user is named 'admin'
# Tachtler
# default: #root_username = admin
root_username = administrator
 
# You MUST specify a hash password for the root user (which you only need to initially set up the
# system and in case you lose connectivity to your authentication backend)
# This password cannot be changed using the API or via the web interface. If you need to change it,
# modify it in this file.
# Create one by using for example: echo -n yourpassword | shasum -a 256
# and put the resulting hash value into the following line
# Tachtler
# default: root_password_sha2 =
root_password_sha2 = addb0f5e7826c857d7376d1bd9bc33c0c544790a2eac96144a8af22b1298c940
 
# The email address of the root user.
# Default is empty
# Tachtler
# default: #root_email = ""
root_email = "administrator@tachtler.net"
 
# The time zone setting of the root user. See http://www.joda.org/joda-time/timezones.html for a list of valid time zones.
# Default is UTC
# Tachtler
# default: #root_timezone = UTC
root_timezone = Europe/Berlin
 
# Set the bin directory here (relative or absolute)
# This directory contains binaries that are used by the Graylog server.
# Default: bin
bin_dir = bin
 
# Set the data directory here (relative or absolute)
# This directory is used to store Graylog server state.
# Default: data
data_dir = data
 
# Set plugin directory here (relative or absolute)
plugin_dir = /usr/lib/graylog/plugin
 
###############
# HTTP settings
###############
 
#### HTTP bind address
#
# The network interface used by the Graylog HTTP interface.
#
# This network interface must be accessible by all Graylog nodes in the cluster and by all clients
# using the Graylog web interface.
#
# If the port is omitted, Graylog will use port 9000 by default.
#
# Default: 127.0.0.1:9000
#http_bind_address = 127.0.0.1:9000
#http_bind_address = [2001:db8::1]:9000
 
#### HTTP publish URI
#
# The HTTP URI of this Graylog node which is used to communicate with the other Graylog nodes in the cluster and by all
# clients using the Graylog web interface.
#
# The URI will be published in the cluster discovery APIs, so that other Graylog nodes will be able to find and connect to this Graylog node.
#
# This configuration setting has to be used if this Graylog node is available on another network interface than $http_bind_address,
# for example if the machine has multiple network interfaces or is behind a NAT gateway.
#
# If $http_bind_address contains a wildcard IPv4 address (0.0.0.0), the first non-loopback IPv4 address of this machine will be used.
# This configuration setting *must not* contain a wildcard address!
#
# Default: http://$http_bind_address/
#http_publish_uri = http://192.168.1.1:9000/
 
#### External Graylog URI
#
# The public URI of Graylog which will be used by the Graylog web interface to communicate with the Graylog REST API.
#
# The external Graylog URI usually has to be specified, if Graylog is running behind a reverse proxy or load-balancer
# and it will be used to generate URLs addressing entities in the Graylog REST API (see $http_bind_address).
#
# When using Graylog Collector, this URI will be used to receive heartbeat messages and must be accessible for all collectors.
#
# This setting can be overriden on a per-request basis with the "X-Graylog-Server-URL" HTTP request header.
#
# Default: $http_publish_uri
#http_external_uri =
 
#### Enable CORS headers for HTTP interface
#
# This allows browsers to make Cross-Origin requests from any origin.
# This is disabled for security reasons and typically only needed if running graylog
# with a separate server for frontend development.
#
# Default: false
#http_enable_cors = false
 
#### Enable GZIP support for HTTP interface
#
# This compresses API responses and therefore helps to reduce
# overall round trip times. This is enabled by default. Uncomment the next line to disable it.
#http_enable_gzip = false
 
# The maximum size of the HTTP request headers in bytes.
#http_max_header_size = 8192
 
# The size of the thread pool used exclusively for serving the HTTP interface.
#http_thread_pool_size = 16
 
################
# HTTPS settings
################
 
#### Enable HTTPS support for the HTTP interface
#
# This secures the communication with the HTTP interface with TLS to prevent request forgery and eavesdropping.
#
# Default: false
#http_enable_tls = true
 
# The X.509 certificate chain file in PEM format to use for securing the HTTP interface.
#http_tls_cert_file = /path/to/graylog.crt
 
# The PKCS#8 private key file in PEM format to use for securing the HTTP interface.
#http_tls_key_file = /path/to/graylog.key
 
# The password to unlock the private key used for securing the HTTP interface.
#http_tls_key_password = secret
 
 
# Comma separated list of trusted proxies that are allowed to set the client address with X-Forwarded-For
# header. May be subnets, or hosts.
#trusted_proxies = 127.0.0.1/32, 0:0:0:0:0:0:0:1/128
 
# List of Elasticsearch hosts Graylog should connect to.
# Need to be specified as a comma-separated list of valid URIs for the http ports of your elasticsearch nodes.
# If one or more of your elasticsearch hosts require authentication, include the credentials in each node URI that
# requires authentication.
#
# Default: http://127.0.0.1:9200
# Tachtler
# default: #elasticsearch_hosts = http://node1:9200,http://user:password@node2:19200
elasticsearch_hosts = http://elastic:geheim@127.0.0.1:9200
 
# Maximum number of retries to connect to elasticsearch on boot for the version probe.
#
# Default: 0, retry indefinitely with the given delay until a connection could be established
#elasticsearch_version_probe_attempts = 5
 
# Waiting time in between connection attempts for elasticsearch_version_probe_attempts
#
# Default: 5s
#elasticsearch_version_probe_delay = 5s
 
# Maximum amount of time to wait for successful connection to Elasticsearch HTTP port.
#
# Default: 10 Seconds
#elasticsearch_connect_timeout = 10s
 
# Maximum amount of time to wait for reading back a response from an Elasticsearch server.
# (e. g. during search, index creation, or index time-range calculations)
#
# Default: 60 seconds
#elasticsearch_socket_timeout = 60s
 
# Maximum idle time for an Elasticsearch connection. If this is exceeded, this connection will
# be tore down.
#
# Default: inf
#elasticsearch_idle_timeout = -1s
 
# Maximum number of total connections to Elasticsearch.
#
# Default: 200
#elasticsearch_max_total_connections = 200
 
# Maximum number of total connections per Elasticsearch route (normally this means per
# elasticsearch server).
#
# Default: 20
#elasticsearch_max_total_connections_per_route = 20
 
# Maximum number of times Graylog will retry failed requests to Elasticsearch.
#
# Default: 2
#elasticsearch_max_retries = 2
 
# Enable automatic Elasticsearch node discovery through Nodes Info,
# see https://www.elastic.co/guide/en/elasticsearch/reference/5.4/cluster-nodes-info.html
#
# WARNING: Automatic node discovery does not work if Elasticsearch requires authentication, e. g. with Shield.
#
# Default: false
#elasticsearch_discovery_enabled = true
 
# Filter for including/excluding Elasticsearch nodes in discovery according to their custom attributes,
# see https://www.elastic.co/guide/en/elasticsearch/reference/5.4/cluster.html#cluster-nodes
#
# Default: empty
#elasticsearch_discovery_filter = rack:42
 
# Frequency of the Elasticsearch node discovery.
#
# Default: 30s
# elasticsearch_discovery_frequency = 30s
 
# Set the default scheme when connecting to Elasticsearch discovered nodes
#
# Default: http (available options: http, https)
#elasticsearch_discovery_default_scheme = http
 
# Enable payload compression for Elasticsearch requests.
#
# Default: false
#elasticsearch_compression_enabled = true
 
# Enable use of "Expect: 100-continue" Header for Elasticsearch index requests.
# If this is disabled, Graylog cannot properly handle HTTP 413 Request Entity Too Large errors.
#
# Default: true
#elasticsearch_use_expect_continue = true
 
# Graylog will use multiple indices to store documents in. You can configure the strategy it uses to determine
# when to rotate the currently active write index.
# It supports multiple rotation strategies, the default being "count":
#   - "count" of messages per index, use elasticsearch_max_docs_per_index below to configure
#   - "size" per index, use elasticsearch_max_size_per_index below to configure
#   - "time" interval between index rotations, use elasticsearch_max_time_per_index to configure
# A strategy may be disabled by specifying the optional enabled_index_rotation_strategies list and excluding that strategy.
#enabled_index_rotation_strategies = count,size,time
 
#
# ATTENTION: These settings have been moved to the database in 2.0. When you upgrade, make sure to set these
#            to your previous 1.x settings so they will be migrated to the database!
#            This configuration setting is only used on the first start of Graylog. After that,
#            index related settings can be changed in the Graylog web interface on the 'System / Indices' page.
#            Also see https://docs.graylog.org/docs/index-model#index-set-configuration
# Tachtler
# default: rotation_strategy = count
rotation_strategy = time
 
# (Approximate) maximum number of documents in an Elasticsearch index before a new index
# is being created, also see no_retention and elasticsearch_max_number_of_indices.
# Configure this if you used 'rotation_strategy = count' above.
#
# ATTENTION: These settings have been moved to the database in 2.0. When you upgrade, make sure to set these
#            to your previous 1.x settings so they will be migrated to the database!
#            This configuration setting is only used on the first start of Graylog. After that,
#            index related settings can be changed in the Graylog web interface on the 'System / Indices' page.
#            Also see https://docs.graylog.org/docs/index-model#index-set-configuration
# Tachtler
# default: elasticsearch_max_docs_per_index = 20000000
#elasticsearch_max_docs_per_index = 20000000
 
# (Approximate) maximum size in bytes per Elasticsearch index on disk before a new index is being created, also see
# no_retention and elasticsearch_max_number_of_indices. Default is 1GB.
# Configure this if you used 'rotation_strategy = size' above.
#
# ATTENTION: These settings have been moved to the database in 2.0. When you upgrade, make sure to set these
#            to your previous 1.x settings so they will be migrated to the database!
#            This configuration setting is only used on the first start of Graylog. After that,
#            index related settings can be changed in the Graylog web interface on the 'System / Indices' page.
#            Also see https://docs.graylog.org/docs/index-model#index-set-configuration
#elasticsearch_max_size_per_index = 1073741824
 
# (Approximate) maximum time before a new Elasticsearch index is being created, also see
# no_retention and elasticsearch_max_number_of_indices. Default is 1 day.
# Configure this if you used 'rotation_strategy = time' above.
# Please note that this rotation period does not look at the time specified in the received messages, but is
# using the real clock value to decide when to rotate the index!
# Specify the time using a duration and a suffix indicating which unit you want:
#  1w  = 1 week
#  1d  = 1 day
#  12h = 12 hours
# Permitted suffixes are: d for day, h for hour, m for minute, s for second.
#
# ATTENTION: These settings have been moved to the database in 2.0. When you upgrade, make sure to set these
#            to your previous 1.x settings so they will be migrated to the database!
#            This configuration setting is only used on the first start of Graylog. After that,
#            index related settings can be changed in the Graylog web interface on the 'System / Indices' page.
#            Also see https://docs.graylog.org/docs/index-model#index-set-configuration
# Tachtler
# default: #elasticsearch_max_time_per_index = 1d
elasticsearch_max_time_per_index = 1d
 
# Optional upper bound on elasticsearch_max_time_per_index
# elasticsearch_max_write_index_age = 1d
 
# Disable checking the version of Elasticsearch for being compatible with this Graylog release.
# WARNING: Using Graylog with unsupported and untested versions of Elasticsearch may lead to data loss!
#elasticsearch_disable_version_check = true
 
# Disable message retention on this node, i. e. disable Elasticsearch index rotation.
#no_retention = false
 
# How many indices do you want to keep?
#
# ATTENTION: These settings have been moved to the database in 2.0. When you upgrade, make sure to set these
#            to your previous 1.x settings so they will be migrated to the database!
#            This configuration setting is only used on the first start of Graylog. After that,
#            index related settings can be changed in the Graylog web interface on the 'System / Indices' page.
#            Also see https://docs.graylog.org/docs/index-model#index-set-configuration
# Tachtler
# default: elasticsearch_max_number_of_indices = 20
elasticsearch_max_number_of_indices = 31
 
# Decide what happens with the oldest indices when the maximum number of indices is reached.
# The following strategies are availble:
#   - delete # Deletes the index completely (Default)
#   - close # Closes the index and hides it from the system. Can be re-opened later.
#
# ATTENTION: These settings have been moved to the database in 2.0. When you upgrade, make sure to set these
#            to your previous 1.x settings so they will be migrated to the database!
#            This configuration setting is only used on the first start of Graylog. After that,
#            index related settings can be changed in the Graylog web interface on the 'System / Indices' page.
#            Also see https://docs.graylog.org/docs/index-model#index-set-configuration
retention_strategy = delete
 
# How many Elasticsearch shards and replicas should be used per index? Note that this only applies to newly created indices.
# ATTENTION: These settings have been moved to the database in Graylog 2.2.0. When you upgrade, make sure to set these
#            to your previous settings so they will be migrated to the database!
#            This configuration setting is only used on the first start of Graylog. After that,
#            index related settings can be changed in the Graylog web interface on the 'System / Indices' page.
#            Also see https://docs.graylog.org/docs/index-model#index-set-configuration
# Tachtler
# default: elasticsearch_shards = 4
elasticsearch_shards = 1
elasticsearch_replicas = 0
 
# Prefix for all Elasticsearch indices and index aliases managed by Graylog.
#
# ATTENTION: These settings have been moved to the database in Graylog 2.2.0. When you upgrade, make sure to set these
#            to your previous settings so they will be migrated to the database!
#            This configuration setting is only used on the first start of Graylog. After that,
#            index related settings can be changed in the Graylog web interface on the 'System / Indices' page.
#            Also see https://docs.graylog.org/docs/index-model#index-set-configuration
elasticsearch_index_prefix = graylog
 
# Name of the Elasticsearch index template used by Graylog to apply the mandatory index mapping.
# Default: graylog-internal
#
# ATTENTION: These settings have been moved to the database in Graylog 2.2.0. When you upgrade, make sure to set these
#            to your previous settings so they will be migrated to the database!
#            This configuration setting is only used on the first start of Graylog. After that,
#            index related settings can be changed in the Graylog web interface on the 'System / Indices' page.
#            Also see https://docs.graylog.org/docs/index-model#index-set-configuration
#elasticsearch_template_name = graylog-internal
 
# Do you want to allow searches with leading wildcards? This can be extremely resource hungry and should only
# be enabled with care. See also: https://docs.graylog.org/docs/query-language
allow_leading_wildcard_searches = false
 
# Do you want to allow searches to be highlighted? Depending on the size of your messages this can be memory hungry and
# should only be enabled after making sure your Elasticsearch cluster has enough memory.
allow_highlighting = false
 
# Analyzer (tokenizer) to use for message and full_message field. The "standard" filter usually is a good idea.
# All supported analyzers are: standard, simple, whitespace, stop, keyword, pattern, language, snowball, custom
# Elasticsearch documentation: https://www.elastic.co/guide/en/elasticsearch/reference/2.3/analysis.html
# Note that this setting only takes effect on newly created indices.
#
# ATTENTION: These settings have been moved to the database in Graylog 2.2.0. When you upgrade, make sure to set these
#            to your previous settings so they will be migrated to the database!
#            This configuration setting is only used on the first start of Graylog. After that,
#            index related settings can be changed in the Graylog web interface on the 'System / Indices' page.
#            Also see https://docs.graylog.org/docs/index-model#index-set-configuration
elasticsearch_analyzer = standard
 
# Global timeout for index optimization (force merge) requests.
# Default: 1h
#elasticsearch_index_optimization_timeout = 1h
 
# Maximum number of concurrently running index optimization (force merge) jobs.
# If you are using lots of different index sets, you might want to increase that number.
# Default: 20
#elasticsearch_index_optimization_jobs = 20
 
# Mute the logging-output of ES deprecation warnings during REST calls in the ES RestClient
#elasticsearch_mute_deprecation_warnings = true
 
# Time interval for index range information cleanups. This setting defines how often stale index range information
# is being purged from the database.
# Default: 1h
#index_ranges_cleanup_interval = 1h
 
# Time interval for the job that runs index field type maintenance tasks like cleaning up stale entries. This doesn't
# need to run very often.
# Default: 1h
#index_field_type_periodical_interval = 1h
 
# Batch size for the Elasticsearch output. This is the maximum (!) number of messages the Elasticsearch output
# module will get at once and write to Elasticsearch in a batch call. If the configured batch size has not been
# reached within output_flush_interval seconds, everything that is available will be flushed at once. Remember
# that every outputbuffer processor manages its own batch and performs its own batch write calls.
# ("outputbuffer_processors" variable)
output_batch_size = 500
 
# Flush interval (in seconds) for the Elasticsearch output. This is the maximum amount of time between two
# batches of messages written to Elasticsearch. It is only effective at all if your minimum number of messages
# for this time period is less than output_batch_size * outputbuffer_processors.
output_flush_interval = 1
 
# As stream outputs are loaded only on demand, an output which is failing to initialize will be tried over and
# over again. To prevent this, the following configuration options define after how many faults an output will
# not be tried again for an also configurable amount of seconds.
output_fault_count_threshold = 5
output_fault_penalty_seconds = 30
 
# The number of parallel running processors.
# Raise this number if your buffers are filling up.
processbuffer_processors = 5
outputbuffer_processors = 3
 
# The following settings (outputbuffer_processor_*) configure the thread pools backing each output buffer processor.
# See https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/ThreadPoolExecutor.html for technical details
 
# When the number of threads is greater than the core (see outputbuffer_processor_threads_core_pool_size),
# this is the maximum time in milliseconds that excess idle threads will wait for new tasks before terminating.
# Default: 5000
#outputbuffer_processor_keep_alive_time = 5000
 
# The number of threads to keep in the pool, even if they are idle, unless allowCoreThreadTimeOut is set
# Default: 3
#outputbuffer_processor_threads_core_pool_size = 3
 
# The maximum number of threads to allow in the pool
# Default: 30
#outputbuffer_processor_threads_max_pool_size = 30
 
# UDP receive buffer size for all message inputs (e. g. SyslogUDPInput).
#udp_recvbuffer_sizes = 1048576
 
# Wait strategy describing how buffer processors wait on a cursor sequence. (default: sleeping)
# Possible types:
#  - yielding
#     Compromise between performance and CPU usage.
#  - sleeping
#     Compromise between performance and CPU usage. Latency spikes can occur after quiet periods.
#  - blocking
#     High throughput, low latency, higher CPU usage.
#  - busy_spinning
#     Avoids syscalls which could introduce latency jitter. Best when threads can be bound to specific CPU cores.
processor_wait_strategy = blocking
 
# Size of internal ring buffers. Raise this if raising outputbuffer_processors does not help anymore.
# For optimum performance your LogMessage objects in the ring buffer should fit in your CPU L3 cache.
# Must be a power of 2. (512, 1024, 2048, ...)
ring_size = 65536
 
inputbuffer_ring_size = 65536
inputbuffer_processors = 2
inputbuffer_wait_strategy = blocking
 
# Enable the message journal.
message_journal_enabled = true
 
# The directory which will be used to store the message journal. The directory must be exclusively used by Graylog and
# must not contain any other files than the ones created by Graylog itself.
#
# ATTENTION:
#   If you create a seperate partition for the journal files and use a file system creating directories like 'lost+found'
#   in the root directory, you need to create a sub directory for your journal.
#   Otherwise Graylog will log an error message that the journal is corrupt and Graylog will not start.
message_journal_dir = /var/lib/graylog/data/journal
 
# Journal hold messages before they could be written to Elasticsearch.
# For a maximum of 12 hours or 5 GB whichever happens first.
# During normal operation the journal will be smaller.
#message_journal_max_age = 12h
#message_journal_max_size = 5gb
 
#message_journal_flush_age = 1m
#message_journal_flush_interval = 1000000
#message_journal_segment_age = 1h
#message_journal_segment_size = 100mb
 
# Number of threads used exclusively for dispatching internal events. Default is 2.
#async_eventbus_processors = 2
 
# How many seconds to wait between marking node as DEAD for possible load balancers and starting the actual
# shutdown process. Set to 0 if you have no status checking load balancers in front.
lb_recognition_period_seconds = 3
 
# Journal usage percentage that triggers requesting throttling for this server node from load balancers. The feature is
# disabled if not set.
#lb_throttle_threshold_percentage = 95
 
# Every message is matched against the configured streams and it can happen that a stream contains rules which
# take an unusual amount of time to run, for example if its using regular expressions that perform excessive backtracking.
# This will impact the processing of the entire server. To keep such misbehaving stream rules from impacting other
# streams, Graylog limits the execution time for each stream.
# The default values are noted below, the timeout is in milliseconds.
# If the stream matching for one stream took longer than the timeout value, and this happened more than "max_faults" times
# that stream is disabled and a notification is shown in the web interface.
#stream_processing_timeout = 2000
#stream_processing_max_faults = 3
 
# Since 0.21 the Graylog server supports pluggable output modules. This means a single message can be written to multiple
# outputs. The next setting defines the timeout for a single output module, including the default output module where all
# messages end up.
#
# Time in milliseconds to wait for all message outputs to finish writing a single message.
#output_module_timeout = 10000
 
# Time in milliseconds after which a detected stale master node is being rechecked on startup.
#stale_master_timeout = 2000
 
# Time in milliseconds which Graylog is waiting for all threads to stop on shutdown.
#shutdown_timeout = 30000
 
# MongoDB connection string
# See https://docs.mongodb.com/manual/reference/connection-string/ for details
# Tachtler
# default: mongodb_uri = mongodb://localhost/graylog
#mongodb_uri = mongodb://localhost/graylog
 
# Authenticate against the MongoDB server
# '+'-signs in the username or password need to be replaced by '%2B'
# Tachtler
# default: #mongodb_uri = mongodb://grayloguser:secret@localhost:27017/graylog
mongodb_uri = mongodb://grayloguser:geheim@127.0.0.1:27017/graylog
 
# Use a replica set instead of a single host
#mongodb_uri = mongodb://grayloguser:secret@localhost:27017,localhost:27018,localhost:27019/graylog?replicaSet=rs01
 
# DNS Seedlist https://docs.mongodb.com/manual/reference/connection-string/#dns-seedlist-connection-format
#mongodb_uri = mongodb+srv://server.example.org/graylog
 
# Increase this value according to the maximum connections your MongoDB server can handle from a single client
# if you encounter MongoDB connection problems.
mongodb_max_connections = 1000
 
# Number of threads allowed to be blocked by MongoDB connections multiplier. Default: 5
# If mongodb_max_connections is 100, and mongodb_threads_allowed_to_block_multiplier is 5,
# then 500 threads can block. More than that and an exception will be thrown.
# http://api.mongodb.com/java/current/com/mongodb/MongoOptions.html#threadsAllowedToBlockForConnectionMultiplier
mongodb_threads_allowed_to_block_multiplier = 5
 
 
# Email transport
#transport_email_enabled = false
#transport_email_hostname = mail.example.com
#transport_email_port = 587
#transport_email_use_auth = true
#transport_email_auth_username = you@example.com
#transport_email_auth_password = secret
#transport_email_subject_prefix = [graylog]
#transport_email_from_email = graylog@example.com
 
# Encryption settings
#
# ATTENTION:
#    Using SMTP with STARTTLS *and* SMTPS at the same time is *not* possible.
 
# Use SMTP with STARTTLS, see https://en.wikipedia.org/wiki/Opportunistic_TLS
#transport_email_use_tls = true
 
# Use SMTP over SSL (SMTPS), see https://en.wikipedia.org/wiki/SMTPS
# This is deprecated on most SMTP services!
#transport_email_use_ssl = false
 
 
# Specify and uncomment this if you want to include links to the stream in your stream alert mails.
# This should define the fully qualified base url to your web interface exactly the same way as it is accessed by your users.
# Tachtler
# default: #transport_email_web_interface_url = https://graylog.example.com
transport_email_web_interface_url = http://graylog.tachtler.net
 
# The default connect timeout for outgoing HTTP connections.
# Values must be a positive duration (and between 1 and 2147483647 when converted to milliseconds).
# Default: 5s
#http_connect_timeout = 5s
 
# The default read timeout for outgoing HTTP connections.
# Values must be a positive duration (and between 1 and 2147483647 when converted to milliseconds).
# Default: 10s
#http_read_timeout = 10s
 
# The default write timeout for outgoing HTTP connections.
# Values must be a positive duration (and between 1 and 2147483647 when converted to milliseconds).
# Default: 10s
#http_write_timeout = 10s
 
# HTTP proxy for outgoing HTTP connections
# ATTENTION: If you configure a proxy, make sure to also configure the "http_non_proxy_hosts" option so internal
#            HTTP connections with other nodes does not go through the proxy.
# Examples:
#   - http://proxy.example.com:8123
#   - http://username:password@proxy.example.com:8123
#http_proxy_uri =
 
# A list of hosts that should be reached directly, bypassing the configured proxy server.
# This is a list of patterns separated by ",". The patterns may start or end with a "*" for wildcards.
# Any host matching one of these patterns will be reached through a direct connection instead of through a proxy.
# Examples:
#   - localhost,127.0.0.1
#   - 10.0.*,*.example.com
#http_non_proxy_hosts =
 
# Disable the optimization of Elasticsearch indices after index cycling. This may take some load from Elasticsearch
# on heavily used systems with large indices, but it will decrease search performance. The default is to optimize
# cycled indices.
#
# ATTENTION: These settings have been moved to the database in Graylog 2.2.0. When you upgrade, make sure to set these
#            to your previous settings so they will be migrated to the database!
#            This configuration setting is only used on the first start of Graylog. After that,
#            index related settings can be changed in the Graylog web interface on the 'System / Indices' page.
#            Also see https://docs.graylog.org/docs/index-model#index-set-configuration
#disable_index_optimization = true
 
# Optimize the index down to <= index_optimization_max_num_segments. A higher number may take some load from Elasticsearch
# on heavily used systems with large indices, but it will decrease search performance. The default is 1.
#
# ATTENTION: These settings have been moved to the database in Graylog 2.2.0. When you upgrade, make sure to set these
#            to your previous settings so they will be migrated to the database!
#            This configuration setting is only used on the first start of Graylog. After that,
#            index related settings can be changed in the Graylog web interface on the 'System / Indices' page.
#            Also see https://docs.graylog.org/docs/index-model#index-set-configuration
#index_optimization_max_num_segments = 1
 
# The threshold of the garbage collection runs. If GC runs take longer than this threshold, a system notification
# will be generated to warn the administrator about possible problems with the system. Default is 1 second.
#gc_warning_threshold = 1s
 
# Connection timeout for a configured LDAP server (e. g. ActiveDirectory) in milliseconds.
#ldap_connection_timeout = 2000
 
# Disable the use of a native system stats collector (currently OSHI)
#disable_native_system_stats_collector = false
 
# The default cache time for dashboard widgets. (Default: 10 seconds, minimum: 1 second)
#dashboard_widget_default_cache_time = 10s
 
# For some cluster-related REST requests, the node must query all other nodes in the cluster. This is the maximum number
# of threads available for this. Increase it, if '/cluster/*' requests take long to complete.
# Should be http_thread_pool_size * average_cluster_size if you have a high number of concurrent users.
proxied_requests_thread_pool_size = 32
 
# The server is writing processing status information to the database on a regular basis. This setting controls how
# often the data is written to the database.
# Default: 1s (cannot be less than 1s)
#processing_status_persist_interval = 1s
 
# Configures the threshold for detecting outdated processing status records. Any records that haven't been updated
# in the configured threshold will be ignored.
# Default: 1m (one minute)
#processing_status_update_threshold = 1m
 
# Configures the journal write rate threshold for selecting processing status records. Any records that have a lower
# one minute rate than the configured value might be ignored. (dependent on number of messages in the journal)
# Default: 1
#processing_status_journal_write_rate_threshold = 1
 
# Configures the prefix used for graylog event indices
# Default: gl-events
#default_events_index_prefix = gl-events
 
# Configures the prefix used for graylog system event indices
# Default: gl-system-events
#default_system_events_index_prefix = gl-system-events
 
# Automatically load content packs in "content_packs_dir" on the first start of Graylog.
#content_packs_loader_enabled = false
 
# The directory which contains content packs which should be loaded on the first start of Graylog.
#content_packs_dir = data/contentpacks
 
# A comma-separated list of content packs (files in "content_packs_dir") which should be applied on
# the first start of Graylog.
# Default: empty
#content_packs_auto_install = grok-patterns.json
 
# The allowed TLS protocols for system wide TLS enabled servers. (e.g. message inputs, http interface)
# Setting this to an empty value, leaves it up to system libraries and the used JDK to chose a default.
# Default: TLSv1.2,TLSv1.3  (might be automatically adjusted to protocols supported by the JDK)
#enabled_tls_protocols= TLSv1.2,TLSv1.3
 
# Enable Prometheus exporter HTTP server.
# Default: false
#prometheus_exporter_enabled = false
 
# IP address and port for the Prometheus exporter HTTP server.
# Default: 127.0.0.1:9833
#prometheus_exporter_bind_address = 127.0.0.1:9833
 
# Path to the Prometheus exporter core mapping file. If this option is enabled, the full built-in core mapping is
# replaced with the mappings in this file.
# This file is monitored for changes and updates will be applied at runtime.
# Default: none
#prometheus_exporter_mapping_file_path_core = prometheus-exporter-mapping-core.yml
 
# Path to the Prometheus exporter custom mapping file. If this option is enabled, the mappings in this file are
# configured in addition to the built-in core mappings. The mappings in this file cannot overwrite any core mappings.
# This file is monitored for changes and updates will be applied at runtime.
# Default: none
#prometheus_exporter_mapping_file_path_custom = prometheus-exporter-mapping-custom.yml
 
# Configures the refresh interval for the monitored Prometheus exporter mapping files.
# Default: 60s
#prometheus_exporter_mapping_file_refresh_interval = 60s
 
# Optional allowed paths for Graylog data files. If provided, certain operations in Graylog will only be permitted
# if the data file(s) are located in the specified paths (for example, with the CSV File lookup adapter).
# All subdirectories of indicated paths are allowed by default. This Provides an additional layer of security,
# and allows administrators to control where in the file system Graylog users can select files from.
#allowed_auxiliary_paths = /etc/graylog/data-files,/etc/custom-allowed-path

Nachfolgende Einstellungen wurden durchgeführt:

  • password_secret = ndyRpQps9TVbramSXqVTZp42lzS9OUvy2Fn5lVxTmrxnwTR2OR1j94SYoIT2OMNxksq4OJO7hasBqFVU5U9TpkrEgccxoeWc

Der Passwort-Hash dient als Referenz zur Verschlüsselung von Passwörtern der Benutzer. Der Passwort-Hash wurde mit Hilfe des nachfolgenden Befehls erstellt:

# pwgen -N 1 -s 96
ndyRpQps9TVbramSXqVTZp42lzS9OUvy2Fn5lVxTmrxnwTR2OR1j94SYoIT2OMNxksq4OJO7hasBqFVU5U9TpkrEgccxoeWc
  • root_username = administrator

Setzen des Benutzernamens für den Benutzer mit Administratoren Rechten.

  • root_password_sha2 = addb0f5e7826c857d7376d1bd9bc33c0c544790a2eac96144a8af22b1298c940

Der Passwort-Hash ist das Passwort für den Benutzer mit Administratoren Rechten. Der Passwort-Hash wurde mit Hilfe des nachfolgenden Befehls erstellt:

# echo -n "Enter Password: " && head -1 < /dev/stdin | tr -d '\n' | sha256sum | cut -d " " -f1
Enter Password: geheim
addb0f5e7826c857d7376d1bd9bc33c0c544790a2eac96144a8af22b1298c940
  • root_email = "administrator@tachtler.net"

E-Mail-Adresse des Benutzers mit den Administratoren Rechten.

  • root_timezone = Europe/Berlin

Anpassen der Zeitzone für den Benutzer mit Administratoren Rechten. Eine Liste möglicher Einstellungen kann unter nachfolgendem externen Link eingesehen werden:

  • elasticsearch_hosts = http://elastic:geheim@127.0.0.1:9200

Verbindungs-URI zum Elasticsearch Such-Server, welche einen Benutzernamen und ein Passwort benötigt - AKTIVIEREN

  • rotation_strategy = time

Änderung der Rotations-Strategie des Such-Servers Elasticsearch vom Standard count (Anzahl der Einträge) auf time (zeitliche Abgrenzung der Index-Datei).

  • # elasticsearch_max_docs_per_index = 20000000

Deaktivieren der maximalen Anzahl an Dokumenten pro Index-Datei des Such-Servers Elasticsearch, da hier die Rotations-Strategie von Standard count (Anzahl der Einträge) auf time (zeitliche Abgrenzung der Index-Datei) abgeändert wurde!

  • elasticsearch_max_time_per_index = 1d

Aktivieren des maximalen Zeitintervalls der Index-Datei des Such-Servers Elasticsearch (hier 1 Tag), da hier die Rotations-Strategie von Standard count (Anzahl der Einträge) auf time (zeitliche Abgrenzung der Index-Datei) abgeändert wurde!

  • elasticsearch_max_number_of_indices = 31

Maximale Anzahl der Index-Dateien des Such-Servers Elasticsearch (hier 31 Tage pro Index-Datei = 31 Index-Dateien). Da hier die Rotations-Strategie von Standard count (Anzahl der Einträge) auf time (zeitliche Abgrenzung der Index-Datei) abgeändert wurde!

  • elasticsearch_shards = 1

Anzahl der shards, welchen der Anzahl der Elasticsearch Such-Server entsprechen sollte.

  • # mongodb_uri = mongodb://localhost/graylog

Verbindungs-URI zum MongoDB Datenbank-Server, welche keinen Benutzernamen und kein Passwort benötigt - DEAKTIVIEREN!

  • mongodb_uri = mongodb://grayloguser:geheim@127.0.0.1:27017/graylog

Verbindungs-URI zum MongoDB Datenbank-Server, welche einen Benutzernamen und ein Passwort benötigt - AKTIVIEREN.

  • transport_email_web_interface_url = http://graylog.tachtler.net

Definition einer URL, welche in e-Mails zur Generierung von URI's zur Verlinkung auf Inhalte herangezogen werden soll.

Graylog: Gruppe und Benutzer anlegen

:!: HINWEIS - Ab Version 5.1.0-2 NICHT mehr erforderlich!

Mit nachfolgendem Befehl, soll eine Gruppe mit dem Namen graylog erstellt werden:

# groupadd -g 971 graylog

Mit nachfolgendem Befehl kann überprüft werden, ob eine Gruppe mit dem Namen graylog erstellt wurde:

# cat /etc/group | grep graylog
graylog:x:971:

Mit nachfolgendem Befehl, soll ein Benutzer mit dem Namen graylog erstellt werden:

# useradd -c 'Graylog user' -d /usr/lib/graylog -g 971 -M -N -s /usr/bin/nologin -u 971 graylog

Mit nachfolgendem Befehl kann überprüft werden, ob ein Benutzer mit dem Namen graylog erstellt wurde:

# cat /etc/passwd | grep graylog
graylog:x:971:971:Graylog user:/usr/lib/graylog:/usr/bin/nologin

/etc/graylog/server/node.id

Damit beim ersten Start des Graylog-Servers die Konfigurationsdatei /etc/graylog/server/node.id erstellt werden kann, muss der Benutzer mit dem Graylog gestartet wird, Besitzer des Verzeichnisses /etc/graylog/server sein, was mit nachfolgendem Befehl durchgeführt werden kann:

# chown graylog:graylog /etc/graylog/server

Graylog: Erster Start

Danach kann der graylog-Server mit nachfolgendem Befehle gestartet werden:

# systemctl start graylog.service

Mit nachfolgendem Befehl kann der Status des Graylog-Servers abgefragt werden:

# systemctl status graylog.service
● graylog.service - Graylog management server
     Loaded: loaded (/usr/lib/systemd/system/graylog.service; enabled; vendor p>
     Active: active (running) since Sat 2022-01-29 10:59:44 CET; 304ms ago
   Main PID: 75499 (java)
      Tasks: 18 (limit: 2341)
     Memory: 39.7M
        CPU: 424ms
     CGroup: /system.slice/graylog.service
             └─75499 /usr/bin/java -Djava.net.preferIPv6Addresses=true -Djava.l>

Jan 29 10:59:44 server systemd[1]: Started Graylog management server.

Graylog: Erster Aufruf

Durch Aufruf der URL des Graylog-Servers

sollte nachfolgende Ausgabe im Browser erscheinen:

Graylog Server - Sign in

Durch Eingabe der in der Konfigurationsdatei

  • /etc/graylog/server/server.conf

festgelegten Zugangsdaten, kann nun die Anmeldung erfolgen:

Benutzername: administrator
Passwort: geheim

Nach einer erfolgreichen Anmeldung, sollte in etwa ein Bildschirminhalt wie nachfolgend dargestellt, zu sehen sein:

Graylog Server - Signed in

Graylog TLS-Zertifikat erstellen

Um entsprechenden Inputs des Graylog-Server nicht nur unverschlüsselte, sondern auch via TLS/StartTLS-Verschlüsselung ansprechen zu können, muss zuerst ein Zertifikat erzeugt werden. Dies kann durch eine offizielle Zertifizierungsstelle durchgeführt werden, was jedoch natürlich mit Kosten verbunden ist, oder es kommt ein sogenanntes Self-Signed-Certificate (Selbst erstelltes/unterschriebenes) Zertifikat zum Einsatz.

Um die Verschlüsselung einsetzen zu können, sind folgende Komponenten erforderlich:

  • eine eigen Certificate Authority (CA), welche Self-Signed-Certificate (Selbst erstelltes/unterschriebenes) Zertifikat esrtellen kann
  • einen CSR (Certificate Request), welcher von einer Certificate Authority (CA) signiert wird
  • einem private key (privaten Schlüssel), welcher zum CRT (Certificate) gehört und zum Einsatz eines CRT (Certificate) benötigt wird
  • das CRT (Certificate) selbst, welcher von der Certificate Authority (CA) ausgestellt wird

Zur Erstellung eines Self-Signed-Certificate und zur Erstellung der oben genannten Komponenten, wird das Paket

  • openssl

benötigt, welches i.d.R. bereits installiert sein sollte.

Abschliessend soll mit nachfolgendem Befehl in das Verzeichnis /etc/ssl gewechselt werden:

# cd /etc/ssl

/etc/ssl/openssl.cnf

Nachfolgende Anpassungen müssen mindestens in der Konfigurationsdatei /etc/ssl/openssl.cnf durchgeführt werden, um SAN (Subject Alternative Names) in das Zertifikat mit aufnehmen zu können:

(Nur relevanter Ausschnitt):

[ v3_req ]
 
# Extensions to add to a certificate request
 
basicConstraints = CA:FALSE
keyUsage = nonRepudiation, digitalSignature, keyEncipherment
# Tachtler - NEW -
subjectAltName = @alt_names
 
# Tachtler - NEW -
[ alt_names ]
DNS.1 = localhost
DNS.2 = 127.0.0.1
DNS.3 = ::1

* Danke an Stefan Mayr für den Hinweis das Zertifikat mit Subject Alternative Names auszustatten → Hintergrund: Representation and Verification of Domain-Based Application Service Identity within Internet Public Key Infrastructure Using X.509 (PKIX) Certificates in the Context of Transport Layer Security (TLS) - Section 6.4.4

Erstellen CA (Certificate Authority)

Zur Erstellung einer eigene Certificate Authority (CA) kann ein Script, welches bei der Installation von openssl mitgeliefert wird und sich im Verzeichnis /etc/ssl/misc/ befindet, genutzt werden. Der Name des Scripts lautet

  • /etc/ssl/misc/CA.pl.

:!: HINWEIS - Um Subject Alternative Names hinzufügen zu können, muss nachfolgende zweite Ergänzung abgeändert werden, das sonst die -extensions v3_req NICHT angezogen wird!

:!: HINWEIS - Die zu erstellende Certificate Authority (CA) hat standardmässig eine Laufzeit von 3 Jahren !!!

Falls eine längere Laufzeit als drei Jahre gewünscht sein soll, kann nachfolgender Parameter im Skript, in nachfolgendem Verzeichnis, mit nachfolgendem Namen

  • /etc/ssl/misc/CA.pl

angepasst werden:

(Nur relevanter Ausschnitt)

...
# Tachtler
# default: my $DAYS = "-days 365";
my $DAYS = "-days 28023"; # 10.04.2023 - 30.12.2099
# Tachtler
# default: my $CADAYS = "-days 1095";   # 3 years
my $CADAYS = "-days 28024"; # 10.04.2023 - 31.12.2099
...
...
...
} elsif ($WHAT eq '-sign' ) {
    $RET = run("$CA -policy policy_anything -out $NEWCERT"
            # Tachtler
            # default: . " -infiles $NEWREQ $EXTRA{ca}");
            . " -extensions v3_req -infiles $NEWREQ $EXTRA{ca}");
    print "Signed certificate is in $NEWCERT\n" if $RET == 0;
... 

:!: WICHTIG - Die Laufzeit der Certificate Authority (CA) muss länger als die Laufzeit des Zertifikates sein !!!

Folgender Aufruf erstellt eine eigene Certificate Authority (CA):

:!: HINWEIS - Nicht benötigte Angaben werden mit Eingabe eines Punktes [.] übersprungen!

# /etc/ssl/misc/CA.pl -newca
# /etc/ssl/misc/CA.pl -newca
CA certificate filename (or enter to create)
 
Making CA certificate ...
====
openssl req  -new -keyout /etc/ssl/private/cakey.pem -out /etc/ssl/careq.pem 
Generating a RSA private key
.............................+++++
......+++++
writing new private key to '/etc/ssl/private/cakey.pem'
Enter PEM pass phrase:
Verifying - Enter PEM pass phrase:
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:DE
State or Province Name (full name) [Some-State]:Bavaria (Bayern)
Locality Name (eg, city) []:Munich (Muenchen)
Organization Name (eg, company) [Internet Widgits Pty Ltd]:tachtler.net
Organizational Unit Name (eg, section) []:.
Common Name (e.g. server FQDN or YOUR name) []:www.tachtler.net
Email Address []:hostmaster@tachtler.net
 
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:.
==> 0
====
====
openssl ca  -create_serial -out /etc/ssl/cacert.pem -days 28024 -batch -keyfile /etc/ssl/private/cakey.pem -selfsign -extensions v3_ca  -infiles /etc/ssl/careq.pem
Using configuration from /etc/ssl/openssl.cnf
Enter pass phrase for /etc/ssl/private/cakey.pem:
Check that the request matches the signature
Signature ok
Certificate Details:
        Serial Number:
            58:b7:f2:c0:f9:30:8d:48:4f:77:d3:56:3d:9d:a9:98:19:e6:a2:49
        Validity
            Not Before: Apr 10 10:48:57 2023 GMT
            Not After : Dec 31 10:48:57 2099 GMT
        Subject:
            countryName               = DE
            stateOrProvinceName       = Bavaria (Bayern)
            organizationName          = tachtler.net
            commonName                = www.tachtler.net
            emailAddress              = hostmaster@tachtler.net
        X509v3 extensions:
            X509v3 Subject Key Identifier: 
                07:39:3F:8F:38:B5:EA:69:3E:FA:BC:C4:AB:7C:30:18:93:26:B8:77
            X509v3 Authority Key Identifier: 
                keyid:07:39:3F:8F:38:B5:EA:69:3E:FA:BC:C4:AB:7C:30:18:93:26:B8:77
 
            X509v3 Basic Constraints: critical
                CA:TRUE
Certificate is to be certified until Dec 31 10:48:57 2099 GMT (28403 days)
 
Write out database with 1 new entries
Data Base Updated
==> 0
====
CA certificate is in /etc/ssl/cacert.pem

Durch ausführen des Skriptes mit nachfolgendem Aufrufparameter /etc/ssl/misc/CA.pl -newca ist eine neue Verzeichnisstruktur und neue Dateien unter

  • /etc/ssl

entstanden, deren Inhalt mit nachfolgendem Befehl bequem aufgelistet werden kann:

# ls -l /etc/ssl
total 64
-rw-r--r-- 1 root root  4611 Apr 10 12:48 cacert.pem
-rw-r--r-- 1 root root  1078 Apr 10 12:48 careq.pem
lrwxrwxrwx 1 root root    46 Jun  3  2021 cert.pem -> ../ca-certificates/extracted/tls-ca-bundle.pem
drwxr-xr-x 1 root root 13526 Apr 16 09:30 certs
drwxr-xr-x 1 root root     0 Apr 10 12:47 crl
-rw-r--r-- 1 root root     3 Apr 10 12:47 crlnumber
-rw-r--r-- 1 root root   412 Dec 18 11:31 ct_log_list.cnf
-rw-r--r-- 1 root root   412 Dec 18 11:31 ct_log_list.cnf.dist
-rw-r--r-- 1 root root   166 Apr 10 12:48 index.txt
-rw-r--r-- 1 root root    21 Apr 10 12:48 index.txt.attr
-rw-r--r-- 1 root root     0 Apr 10 12:47 index.txt.old
drwxr-xr-x 1 root root    36 Apr 10 12:47 misc
drwxr-xr-x 1 root root    88 Apr 10 12:48 newcerts
-rw-r--r-- 1 root root 11160 Apr 10 12:46 openssl.cnf
-rw-r--r-- 1 root root 10909 Dec 18 11:31 openssl.cnf.dist
drwxr-xr-x 1 root root    18 Apr 10 12:47 private
-rw-r--r-- 1 root root    41 Apr 10 12:48 serial
# ls -l /etc/ssl/newcerts
total 8
-rw-r--r-- 1 root root 4611 Apr 10 12:48 58B7F2C0F9308D484F77D3563D9DA99819E6A249.pem
# ls -l /etc/ssl/private
total 4
-rw------- 1 root root 1854 Apr 10 12:48 cakey.pem

Erstellen CSR (Certificate Request)

Ebenfalls mit dem Script, welches schon bei der Erstellung einer eigene Certificate Authority (CA) genutzt wurde und sich unter /etc/ssl/misc befindet und den Namen CA trägt, kann nun dieses auch zur Erstellung von

  • einem CSR (Certificate Request)
  • einem private key (privaten Schlüssel)

genutzt werden.

:!: HINWEIS - Das zu erstellende Zertifikat hat standardmässig eine Laufzeit von 1 Jahr !!!

Falls eine längere Laufzeit als ein Jahr gewünscht sein soll, kann nachfolgender Parameter im Skript, in nachfolgendem Verzeichnis, mit nachfolgendem Namen

  • /etc/ssl/openssl.cnf

angepasst werden:

(Nur relevanter Ausschnitt)

...
# Tachtler
# default: default_days = 365           # how long to certify for
default_days    = 28023         # how long to certify for 10.04.2023 - 30.12.2099
...

:!: HINWEIS - Nicht benötigte Angaben werden mit Eingabe eines Punktes [.] übersprungen!

# /etc/ssl/misc/CA.pl -newreq -extra-req -extensions=v3_req
# /etc/ssl/misc/CA.pl -newreq -extra-req -extensions=v3_req
Use of uninitialized value $1 in concatenation (.) or string at /etc/ssl/misc/CA.pl line 137.
====
openssl req  -new  -keyout newkey.pem -out newreq.pem -days 28023 -extensions=v3_req
Ignoring -days; not generating a certificate
Generating a RSA private key
...+++++
....................................+++++
writing new private key to 'newkey.pem'
Enter PEM pass phrase:
Verifying - Enter PEM pass phrase:
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:DE
State or Province Name (full name) [Some-State]:Bavaria (Bayern)
Locality Name (eg, city) []:Munich (Muenchen)
Organization Name (eg, company) [Internet Widgits Pty Ltd]:tachtler.net
Organizational Unit Name (eg, section) []:.
Common Name (e.g. server FQDN or YOUR name) []:graylog.idmz.tachtler.net
Email Address []:hostmaster@tachtler.net
 
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []: 
An optional company name []:.
==> 0
====
Request is in newreq.pem, private key is in newkey.pem

Durch ausführen des Scripts mit nachfolgendem Aufrufparameter /etc/ssl/misc/CA.pl -newreq -extra-req -extensions=v3_req sind zwei neue Dateien unter

  • /etc/ssl

entstanden, welche mit nachfolgendem Befehl aufgelistet werden können:

# ls -l /etc/ssl/new*.pem
-rw------- 1 root root 1854 Apr 10 14:01 /etc/ssl/newkey.pem
-rw-r--r-- 1 root root 1086 Apr 10 14:03 /etc/ssl/newreq.pem

:!: WICHTIG - Die so entstandene Datei /etc/ssl/newreq.pem enthält den CSR (Certificate Request).

Signieren CSR (Certificate Request)

Um den in obigen Beispiel entstandenen CSR (Certificate Request) nun mit der Certificate Authority (CA) zu unterschreiben und somit ein signiertes CRT (Certificate) zu erzeugen, kann wieder das Script, welches schon bei der Erstellung der Certificate Authority (CA) genutzt wurde und sich unter /etc/ssl/misc befindet und den Namen CA.pl trägt, mit nachfolgendem Befehl genutzt werden:

:!: WICHTIG - Das Passwort, ist das Passwort, welches im Schritt graylog ArchLinux - Erstellen CA (Certificate Authority) verwendet wurde!

# /etc/ssl/misc/CA.pl -sign -extra-ca
# /etc/ssl/misc/CA.pl -sign -extra-ca
====
openssl ca  -policy policy_anything -out newcert.pem -extensions=v3_req -infiles newreq.pem
Using configuration from /etc/ssl/openssl.cnf
Enter pass phrase for /etc/ssl/private/cakey.pem:
Check that the request matches the signature
Signature ok
Certificate Details:
        Serial Number:
            58:b7:f2:c0:f9:30:8d:48:4f:77:d3:56:3d:9d:a9:98:19:e6:a2:4a
        Validity
            Not Before: Apr 10 12:04:22 2023 GMT
            Not After : Dec 30 12:04:22 2099 GMT
        Subject:
            countryName               = DE
            stateOrProvinceName       = Bavaria (Bayern)
            localityName              = Munich (Muenchen)
            organizationName          = tachtler.net
            commonName                = graylog.idmz.tachtler.net
            emailAddress              = hostmaster@tachtler.net
        X509v3 extensions:
            X509v3 Basic Constraints: 
                CA:FALSE
            X509v3 Key Usage: 
                Digital Signature, Non Repudiation, Key Encipherment
            X509v3 Subject Alternative Name: 
                DNS:localhost, DNS:127.0.0.1, DNS:::1
Certificate is to be certified until Dec 30 12:04:22 2099 GMT (28402 days)
Sign the certificate? [y/n]:y
 
 
1 out of 1 certificate requests certified, commit? [y/n]y
Write out database with 1 new entries
Data Base Updated
==> 0
====
Signed certificate is in newcert.pem

Durch ausführen des Skriptes mit nachfolgendem Aufrufparameter /etc/ssl/misc/CA.pl -sign -extra-ca ist eine weitere neue Dateien unter

  • /etc/ssl

entstanden, welche mit nachfolgendem Befehl aufgelistet werden kann:

# ls -l /etc/ssl/new*.pem
-rw-r--r-- 1 root root 4639 Apr 10 14:04 /etc/ssl/newcert.pem
-rw------- 1 root root 1854 Apr 10 14:01 /etc/ssl/newkey.pem
-rw-r--r-- 1 root root 1086 Apr 10 14:03 /etc/ssl/newreq.pem

:!: WICHTIG - Die so entstandene Datei /etc/ssl/newcert.pem enthält das neue signierte CRT (Certificate)!

Entfernen des Passwortes vom private key

Ein Problem ist durch die Erstellung der einzelnen Komponenten, wie in den drei vorhergehenden Schritten beschrieben worden noch offen.

:!: WICHTIG - Der private key (privaten Schlüssel) ist mit einer Passphrase gesichert !

Um dieses Problem zu lösen und das Passwort aus dem private key (privaten Schlüssel) zu entfernen, kann folgender Aufruf von openssl genutzt werden:

:!: WICHTIG - Das Passwort, ist das Passwort, welches im Schritt graylog ArchLinux - Erstellen CA (Certificate Authority) verwendet wurde!

# openssl rsa < /etc/ssl/newkey.pem > /etc/ssl/key.pem
Enter pass phrase: 
writing RSA key

Durch ausführen des oben genannten Befehls ist eine weitere neue Dateien unter

  • /etc/ssl

entstanden, welche mit nachfolgendem Befehl aufgelistet werden kann:

# ls -l /etc/ssl/*key*
-rw-r--r-- 1 root root 1679 Apr 10 13:16 /etc/ssl/key.pem
-rw------- 1 root root 1854 Apr 10 13:12 /etc/ssl/newkey.pem

:!: WICHTIG - Die so entstandene Datei /etc/ssl/key.pem enthält den private key (privaten Schlüssel) OHNE Passphrase!

Installation Zertifikat

Nach dem ein Zertifikat wie hier: Graylog ArchLinux - TLS-Zertifikat erstellen beschrieben erstellt wurde, müssen die benötigen Komponenten noch an die entsprechenden Stellen im Betriebssystem kopiert werden. Dazu sind nachfolgende Befehle notwendig.

Bevor mit der abschliessenden Konfiguration von Graylog zur Nutzung von HTTPS begonnen werden kann, sind die in den vorhergehenden Schritten erstellten Dateien:

  • /etc/ssl/key.pem
  • /etc/ssl/newcert.pem
  • /etc/ssl/cacert.pem

noch zu kopieren und ggf. umzubenennen und die Besitz- und Dateirechte der entsprechend Dateien noch anzupassen!

Als erstes werden mit den nachfolgenden Befehlen zwei neue Verzeichnisse im bestehen Verzeichnis /etc/kea angelegt:

# mkdir -p /etc/graylog/server/ssl/{certs,private}

Anschliessend werden mit den nachfolgenden Befehlen die entsprechenden Dateien an den jeweiligen Bestimmungsort kopiert und ggf. umbenannt:

# cp -a /etc/ssl/key.pem /etc/graylog/server/ssl/private/graylog.idmz.tachtler.net.key
# cp -a /etc/ssl/newcert.pem /etc/graylog/server/ssl/certs/graylog.idmz.tachtler.net.pem
# cp -a /etc/ssl/cacert.pem /etc/graylog/server/ssl/certs/CAcert.pem

Die Besitz- und Dateirechte der soeben kopieren und ggf. umbenannten Dateien

  • /etc/graylog/server/ssl/private/graylog.idmz.tachtler.net.key
  • /etc/graylog/server/ssl/certs/graylog.idmz.tachtler.net.pem
  • /etc/graylog/server/ssl/certs/CAcert.pem

können mit folgenden Befehlen die Besitzrechte wie folgt korrigiert werden:

# chown root:root /etc/graylog/server/ssl/private/graylog.idmz.tachtler.net.key
# chown root:root /etc/graylog/server/ssl/certs/graylog.idmz.tachtler.net.pem
# chown root:root /etc/graylog/server/ssl/certs/CAcert.pem

und mit folgenden Befehlen die Dateirechte:

# chmod 400 /etc/graylog/server/ssl/private/graylog.idmz.tachtler.net.key
# chmod 444 /etc/graylog/server/ssl/certs/graylog.idmz.tachtler.net.pem
# chmod 444 /etc/graylog/server/ssl/certs/CAcert.pem

Durch Ausführen der oben genannten Befehle sieht der Inhalt des Verzeichnisses

  • /etc/kea/ssl

wie folgt aus, welches mit nachfolgendem Befehl aufgelistet werden kann:

# ls -l /etc/kea/ssl/*
/etc/kea/ssl/certs:
total 16
-r--r--r-- 1 root root 4611 Apr 10 14:59 CAcert.pem
-r--r--r-- 1 root root 4810 Apr 10 14:59 graylog.idmz.tachtler.net.pem

/etc/kea/ssl/private:
total 4
-r-------- 1 root root 1675 Apr 10 14:59 graylog.idmz.tachtler.net.key

systemd-journald -> graylog

Zum Transport der in systemd-journald aufgelaufenen LOG-Meldungen nach Graylog sollen die LOG-Daten

  • verschlüsselt
  • abgesichert durch Zertifikate
  • direkt zu Graylog

via transportiert werden.

Elastic - beats - filebeat

Die nachfolgende Methode unter Zuhilfenahme des Elastic - Beats - filebeat soll hier zum Einsatz kommen.

Siehe auch nachfolgenden internen Link

Diese Website verwendet Cookies. Durch die Nutzung der Website stimmen Sie dem Speichern von Cookies auf Ihrem Computer zu. Außerdem bestätigen Sie, dass Sie unsere Datenschutzbestimmungen gelesen und verstanden haben. Wenn Sie nicht einverstanden sind, verlassen Sie die Website.Weitere Information
tachtler/graylog_archlinux.txt · Zuletzt geändert: 2023/05/21 09:54 von klaus