2015年4月23日木曜日

Splunkの無償ライセンスでREST APIを使う方法

Splunkの無償ライセンスでは外部からのリモートアクセスでの認証機能が抑止されているため、REST APIが使えません。
REST APIを使用しているSDKでも同じです。

Java SDKで実行したらこんなかんじでエラーが出ます。

[Fatal Error] :1:1: 途中でファイルの末尾に達しました。
Exception in thread "main" com.splunk.HttpException: HTTP 401 -- 

  
    Remote login disabled because you are using a free license which does not provide authentication. To resolve either switch to the forwarder-only license or the enterprise trial license included with the product. To override this and enable unauthenticated remote management, edit the 'allowRemoteLogin' setting in your server.conf file.
  


 at com.splunk.HttpException.create(HttpException.java:84)
 at com.splunk.HttpService.send(HttpService.java:411)
 at com.splunk.Service.send(Service.java:1280)
 at com.splunk.HttpService.post(HttpService.java:272)
 at com.splunk.Service.login(Service.java:1111)
 at com.splunk.Service.login(Service.java:1091)
 at com.splunk.Service.connect(Service.java:185)
 at splunk.sample.OneShotSearch.main(OneShotSearch.java:18)


リモートアクセスでの認証機能を無効にすることで、アクセス可能になります。
※セキュリティは低下します。

# vi /usr/local/splunk/etc/system/default/server.conf
 :
allowRemoteLogin=requireSetPassword
 ↓
allowRemoteLogin=
 :


あとは、再起動で反映されます。

0 件のコメント:

コメントを投稿