メモのページ - チラシの裏メモ 3枚目

通信技術や気になった事を黙々とメモし続ける

Splunk Enterprise 9.0.4をRHEL 8.6にインストール

Cloudflare Zero Trustのログの飛ばし先としてSplunkを導入する事にした。
今回は、MacBook Pro 2020上のVirtualboxのゲストOSのうちの1つであるRHEL(Red Hat Enterprise Linux)8.6に、Splunk Entreprise 9.0.4をインストールした際のメモ。

2023/3/16追記
残念な事にCloudflareのFreeプランはLogpush機能未対応につき、Cloudflaer Zero TrustのログをSplunkに飛ばすという野望は潰えてしまった。別のシステムから飛ばす事を模索中。
https://developers.cloudflare.com/logs/about/ Logpush


Splunkとは
アメリカにあるSplunk Inc.の製品。サーバやネットワーク機器やクラウドシステム等、様々な機器やシステムからログやデータを収集し、リアルタイムに検索や分析等を行う事が可能な統合ログ管理ソフトウェアの製品群である。ログデータを収集、分析、可視化するSplunk Enterpriseや、セキュリティタスクの自動化アプリSplunk SOARや、セキュリティの状況をリアルタイムに可視化し脅威の検出を強化するSplunk Security Essentials等、様々な製品が提供されている。
今回の対象となるSplunk Enterpriseは、全機能の試用が可能な無料トライアル版が用意されており、トライアル期限である60日間を経過すると機能が限定された形で無償版として利用が可能になる。
今回は無料トライアル版を導入し、60日間はいろいろな機能に触れてみる事とした。


RHEL 8.6について
グダグダで尻すぼみとなったCentOSの代替LinuxディストリビューションとしてRocky LinuxやAlma Linux等が挙げられるが、そう言えば、わざわざ新しい物探さなくてもRHELが有ったよなーという事で、Splunkのインストール先としてRHEL 8.6を選択した。


当方の環境
ホスト機:macOS 13.2.1 / MacBook Pro 2020 / RAM: 16GB / CPU: Intel Core i5 2.0GHz
Oracle VirtualBox:7.0.6
ゲストOS:Red Hat Enterprise Linux 8.6
Splunk:Splunk Enterprise 9.0.4
VirtualBoxでは、ゲストOSであるRHEL用に8GBのRAMをアサインしている。


Splunk Enterprise導入の流れ
大まかな流れは以下のとおり。尚、Red Hat Developer Programのユーザー登録やインストーラーのダウンロード及びVirtualboxへのデプロイに関しては、ここでは割愛する。(下記のリンク先「RHELを無償利用する。」を参照)
・Splinkのサイトでユーザーアカウントを作成
・RHELを立ち上げてSplunkの.rpmファイルをダウンロード
・Splunk Enterpriseのインストール
・Splunk Enterpriseの初期設定


1.ユーザーアカウントの作成
下記のURLにアクセスし、ユーザーアカウントの登録を行う。
https://www.splunk.com/ja_jp/sign-up.html?301=/ja_jp/page/sign_up

ユーザーアカウントの登録後、Splunkから件名が「Confirm your email address」のメールを受信する。メール本文内の「Verify Your Email」をクリックし、メールアドレスの認証を済ませる。


2.ダウンロードサイトにアクセス
下記のURLにアクセスし、Splunk Enterpriseの枠の中の「60日間Splunk Enterprise無料トライアル版ダウンロード」をクリック。
https://www.splunk.com/ja_jp/download.html


3.インストーラーのダウンロード
「ダウンロード対象を選択」内にて、インストーラーおよびパッケージのファイルをダウンロードする。
今回は、RHEL 8(Red Hat Enterprise Linux 8.6)にパッケージでインストールする為、「Linux」を選択し.rpm横の「Download Now」をクリック。

続けて、SPLUNK GENERAL TERMS」枠内下部の「I have read, understand and hereby agree to the above Agreement, including sharing my feedback and usage data as specified in the Agreement.」にチェックを入れ「Access program」をクリック。

「Access Program」をクリックすると同時にSplunk Enterpriseの.rpmファイルのダウンロードが開始するが、今回はRHELにてコマンドでダウンロードしたい為、「コマンドライン (wget) 経由でダウンロードをクリックし、表示されるwgetコマンドとオプションをコピーする。

そのページ内にはインストールマニュアルやリファレンスへのリンクや学習用動画へのリンクが記載されている為、必要有ればブックマークしアクセスする。


4.RHELを立ち上げSplunk Enterpriseのインストールの準備
自分の環境ではVirtualBoxのゲストOSとしてRHEL(Red Hat Enterprise Linux 8.6)がデプロイ済みである。
RHELを立ち上げてSplunk Enterpriseのインストールの準備を進める。

上記3にてコピーしたwgetのコマンドを、ターミナルアプリに貼り付ける。
自分の場合、iTerm2を立ち上げてRHELにsshログインし、コピーしたwgetコマンドをiTerm2上に貼り付けた。

$ wget -O splunk-xxxxxxxxxxxx-linux-2.6-x86_64.rpm "https://download.splunk.com/xxxxxxxxxx/splunk-xxxxxxxxxxxx-linux-2.6-x86_64.rpm"
--2023-03-13 15:45:56--  https://download.splunk.com/xxxxxxxxxx/splunk-xxxxxxxxxxxx-linux-2.6-x86_64.rpm 
Resolving download.splunk.com (download.splunk.com)... 2600:9000:2066:6000:1d:f9c1:d100:93a1, 2600:9000:2066:9c00:1d:f9c1:d100:93a1, 2600:9000:2066:ae00:1d:f9c1:d100:93a1, ...
Connecting to download.splunk.com (download.splunk.com)|2600:9000:2066:6000:1d:f9c1:d100:93a1|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 600890866 (573M) [binary/octet-stream]
Saving to: 'splunk-xxxxxxxxxxxx-linux-2.6-x86_64.rpm'

splunk-xxxxxxxxxx 100%[================================>] 573.05M  3.95MB/s    in 2m 29s

2023-03-13 15:48:27 (3.84 MB/s) - 'splunk-xxxxxxxxxxxx-linux-2.6-x86_64.rpm' saved [600890866/600890866]

$

ダウンロードの完了後、Splunk Enterpriseのrpmファイルが保存されている事を確認する。

$ ls -la
total 586832
drwx------. 2 hechtia hechtia       167 Mar 13 15:45 .
drwxr-xr-x. 4 root    root           36 Mar  6 22:08 ..
-rw-------. 1 hechtia hechtia      1894 Mar 13 15:49 .bash_history
-rw-r--r--. 1 hechtia hechtia        18 Jun 20  2022 .bash_logout
-rw-r--r--. 1 hechtia hechtia       566 Mar  6 22:28 .bash_profile
-rw-r--r--. 1 hechtia hechtia       539 Mar  6 22:30 .bashrc
-rw-------. 1 hechtia hechtia      3493 Mar  6 22:30 .viminfo
-rw-rw-r--. 1 hechtia hechtia       128 Mar  6 22:24 .vimrc
-rw-r--r--. 1 hechtia hechtia 600890866 Feb 14 05:53 splunk-xxxxxxxxxxxx-linux-2.6-x86_64.rpm
$


5.Splunk Enterpriseのインストールと初期設定
dnfコマンドやrpmコマンドでSplunk Enterpriseをインストールする。

$ sudo dnf -y install splunk-xxxxxxxxxxxx-linux-2.6-x86_64.rpm
Updating Subscription Management repositories.
Red Hat Enterprise Linux 8 for x86_64 - BaseOS (RPMs)                               13 kB/s | 4.1 kB     00:00
Red Hat Enterprise Linux 8 for x86_64 - AppStream (RPMs)                            16 kB/s | 4.5 kB     00:00
Last metadata expiration check: 0:00:02 ago on Thu 09 Mar 2023 03:41:20 PM JST.
Dependencies resolved.
====================================================================================
 Package           Architecture      Version          Repository         Size
====================================================================================
Installing:
 splunk            x86_64            9.0.4          @commandline        573 M

Transaction Summary
====================================================================================
Install  1 Package

Total size: 573 M
Installed size: 1.4 G
Downloading Packages:
Running transaction check
:
(省略)
:
Complete!
$

Completeが出力され、Splunkのインストールが完了した。
/optディレクトリ配下にsplunkディレクトリが作成されている事を確認する。

$ ls -ld /opt/splunk
drwxr-xr-x. 10 splunk splunk 262 Mar 13 19:51 /opt/splunk
$


6.Splunkの初回起動および初期設定
/opt/splunk/binディレクトリ以下にSplunkの実行ファイルが有る。Splunkの実行ファイルをstartオプション付けて直接叩き、初期設定を実施する。
途中で、Splunk管理者のユーザ名の作成が求められる。ユーザ名を入力。
自分の場合、adminとした。

$ sudo su -
# /opt/splunk/bin/splunk start --accept-license

SPLUNK GENERAL TERMS

Last Updated: August 12, 2021

These Splunk General Terms ("General Terms") between Splunk Inc., a Delaware
corporation, with its principal place of business at 270 Brannan Street, San
Francisco, California 94107, U.S.A ("Splunk" or "we" or "us" or "our") and you
("Customer" or "you" or "your") apply to the purchase of licenses and
subscriptions for Splunk's Offerings. By clicking on the appropriate button,
or by downloading, installing, accessing or using the Offerings, you agree to
these General Terms. If you are entering into these General Terms on behalf of
Customer, you represent that you have the authority to bind Customer. If you
do not agree to these General Terms, or if you are not authorized to accept
the General Terms on behalf of the Customer, do not download, install, access,
or use any of the Offerings.
:
(省略)
:
This appears to be your first time running this version of Splunk.

Splunk software must create an administrator account during startup. Otherwise, you cannot log in.
Create credentials for the administrator account.
Characters do not appear on the screen when you type in credentials.

Please enter an administrator username: admin

続けて、上記で作成したSplunk管理者ユーザのパスワード作成が求められる為、任意のパスワードを入力する。
パスワードの入力後、RSA Keyの生成やファイルの生成等が実行される。
プロンプトが返ってくるまで気長に待つ。

Password must contain at least:
   * 8 total printable ASCII character(s).
Please enter a new password:
Please confirm new password:
Copying '/opt/splunk/etc/openldap/ldap.conf.default' to '/opt/splunk/etc/openldap/ldap.conf'.
Generating RSA private key, 2048 bit long modulus
................................+++++
.........+++++
e is 65537 (0x10001)
writing RSA key
:
(省略)
:
PYTHONHTTPSVERIFY is set to 0 in splunk-launch.conf disabling certificate validation for the httplib and urllib libraries shipped with the embedded Python interpreter; must be set to "1" for increased security
Done
                                             [  OK  ]

Waiting for web server at http://127.0.0.1:8000 to be available.
...... Done


If you get stuck, we're here to help.
Look for answers here: http://docs.splunk.com

The Splunk web interface is at http://hogehoge:8000

#

Splunkの初回起動および初期設定が完了した。
ここで一旦Splunkを落とし、/opt/splunk/bin/splunk enable boot-startコマンドを打ってRHELの起動の際にSplunkも自動で起動するよう設定する。

# /opt/splunk/bin/splunk stop
Stopping splunkd...
Shutting down.  Please wait, as this may take a few minutes.
...                                          [  OK  ]
Stopping splunk helpers...
                                             [  OK  ]
Done.
#
# /opt/splunk/bin/splunk enable boot-start
Init script installed at /etc/init.d/splunk.
Init script is configured to run at boot.
#


上記が完了したら、/opt/splunk/bin/splunk startコマンドを打ち、再度Splunkを立ち上げる。

# /opt/splunk/bin/splunk start

Splunk> Australian for grep.

Checking prerequisites...
	Checking http port [8000]: open
	Checking mgmt port [8089]: open
	Checking appserver port [127.0.0.1:8065]: open
	Checking kvstore port [8191]: open
	Checking configuration... Done.
	Checking critical directories...	Done
	Checking indexes...
		Validated: _audit _configtracker _internal _introspection _metrics _metrics_rollup _telemetry _thefishbucket history main summary
:
(省略)
:
	Done
All preliminary checks passed.

Starting splunk server daemon (splunkd)...
PYTHONHTTPSVERIFY is set to 0 in splunk-launch.conf disabling certificate validation for the httplib and urllib libraries shipped with the embedded Python interpreter; must be set to "1" for increased security
Done
                                               [  OK  ]

Waiting for web server at http://127.0.0.1:8000 to be available...... Done


If you get stuck, we're here to help.
Look for answers here: http://docs.splunk.com

The Splunk web interface is at http://hogehoge:8000

#

ここでSplunkのステータスを確認。
splunkd is running と返ってきた為Splunkは起動している事が分かる。

#  /opt/splunk/bin/splunk status
splunkd is running (PID: 5096).
splunk helpers are running (PIDs: 5100 5211 5305 5397).
#

RHELのSplunkサービスの状態を確認。
Active: active (exited) が見える。Splunkサービスは動いているけど待機中の状態。

# systemctl status splunk
[root@jpmtkvmsv99 ~]# systemctl status splunk
● splunk.service - SYSV: Splunk indexer service
   Loaded: loaded (/etc/rc.d/init.d/splunk; generated)
   Active: active (exited) since Mon 2023-03-13 20:14:48 JST; 39s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 6515 ExecStart=/etc/rc.d/init.d/splunk start (code=exited, status=0/SUCCESS)

Mar 13 20:14:46 hogehoge systemd[1]: Starting SYSV: Splunk indexer service...
Mar 13 20:14:46 hogehoge splunk[6515]: Starting Splunk...
Mar 13 20:14:48 hogehoge splunk[6548]: The splunk daemon (splunkd) is already running. [FAILED]
Mar 13 20:14:48 hogehoge splunk[6520]: If you get stuck, we're here to help.
Mar 13 20:14:48 hogehoge splunk[6520]: Look for answers here: http://docs.splunk.com
Mar 13 20:14:48 hogehoge splunk[6520]: The Splunk web interface is at http://hogehoge:8000
Mar 13 20:14:48 hogehoge systemd[1]: Started SYSV: Splunk indexer service.
#

ここでWebブラウザを立ち上げてSplunkにアクセスするが、「正常に接続できませんでした。192.168.3.20:8000のサーバーへの接続を確立できませんでした」が表示される。
RHELを再起動させて、再度Webブラウザからのアクセスを試みる。
しかし、事象は変わらずSplunkにアクセス出来ない。

ここでRHELのfirewalldサービスを落とし、Splunkにアクセスしてみた結果...

# systemctl stop firewalld
#
# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
   Active: inactive (dead) since Mon 2023-03-13 20:20:24 JST; 2min ago
     Docs: man:firewalld(1)
  Process: 892 ExecStart=/usr/sbin/firewalld --nofork --nopid $FIREWALLD_ARGS (code=exited, status=0/SUCCESS)
 Main PID: 892 (code=exited, status=0/SUCCESS)

Mar 13 20:20:49 hogehoge systemd[1]: Starting firewalld - dynamic firewall daemon...
Mar 13 20:20:50 hogehoge systemd[1]: Started firewalld - dynamic firewall daemon.
Mar 13 20:20:51 hogehoge firewalld[892]: WARNING: AllowZoneDrifting is enabled. This is considered an insecure confi>
Mar 13 20:20:24 hogehoge systemd[1]: Stopping firewalld - dynamic firewall daemon...
Mar 13 20:20:24 hogehoge systemd[1]: firewalld.service: Succeeded.
Mar 13 20:20:24 hogehoge systemd[1]: Stopped firewalld - dynamic firewall daemon.
#


今度はSplunkのログイン画面にアクセス出来た!!


今回はここまで。
インストール直後につきRHELのfirewalldサービスは落としてSplunkにアクセスしたものの、本来であればfirewalldを無効にする事は望ましくない。運用フェーズにおいては、Splunk管理画面用のポートやSplunk管理通信用のポート等RHELのFirewallの穴あけが必要だろう。
(Splunkが使うポート番号に関しては、下記リンク先「簡単だけど注意しておきたいSplunkインストール前の考慮点」を参照)


参照サイトや資料
Splunk
https://www.splunk.com/ja_jp?301=/ja_jp.html Splunk
https://www.splunk.com/ja_jp/download.html Splunk Enterprise無料トライアル版
https://qiita.com/kzyomr/items/b6c0ddd8cf9b64de099c Splunkをインストールしてみる!
https://qiita.com/bashi100kmrun/items/3fe3e0f30bfa0b696c6c 簡単だけど注意しておきたいSplunkインストール前の考慮点
https://qiita.com/maroon/items/86412cbeee156899a5a7 Splunkの学習コンテンツをまとめてみました
https://dev.classmethod.jp/articles/about-splunk/ 統合ログ分析ソリューションSplunkの凄さを公式チュートリアルで体感する

Red Hat Enterprise Linuxの無償利用
https://developers.redhat.com/ Red Hat Developer
https://qiita.com/sakai00kou/items/bc7499e9c9464e513846 RHELを無償利用する。

Cloudflare Zero Trust
https://www.cloudflare.com/ja-jp/products/zero-trust/ Cloudflare Zero Trust
https://developers.cloudflare.com/logs/get-started/enable-destinations/splunk/ Enable Logpush to Splunk
https://debslink.hatenadiary.jp/entry/20221103/1667482863 Cloudflare Zero Trustを導入してみた - POC環境構築編