LoginSignup
8
7

More than 5 years have passed since last update.

カスタムサーチコマンドの作り方(Splunk)

Posted at

1.カスタムサーチコマンドについて

 Splunkではあらかじめ用意されているサーチコマンド以外に、自分で作成したサーチコマンド(カスタムサーチコマンド)を実行することも可能です。これはPythonを使って記述しますから、Splunkのサーチコマンドだけでは難しい処理も比較的簡単に行えたりします。

2.作成方法

 Splunk上で”Hello World"と表示させるサーチコマンドを作成してみます。

①Appの作成

 Splunkにログインし、Appの作成画面で名前を"Hello World"、フォルダ名を"hello_world"として新規作成します。

②実行ファイルの作成

 /Applications/Splunk/etc/apps/hello_world/bin/配下に以下のファイルを配置します。

hello_world.py
print 'title'
print 'Hello World'

③設定ファイルの作成

 /Applications/Splunk/etc/apps/hello_world/local/配下に以下の2ファイル配置します。

commands.conf
[HelloWorld]
filename = hello_world.py
authorize.conf
[capability::run_script_HelloWorld]

[role_admin]
run_script_HelloWorld= enabled

③カスタムサーチコマンドの実行

 Splunkで作成した"Hello World"のAppを開き、以下のサーチコマンドを実行します。

|run HelloWorld

下図のように"Hello World"が表示されました。
スクリーンショット 2017-09-14 7.22.42.png

 なお、Appの権限を変更すればどのサーチ画面でも実行可能なコマンドになります。

8
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
7