Splunk Dev

サーバサイドでのPythonスクリプト実行

ts_splunk
Path Finder

Web Frameworkを使用して独自Appを作成していますが
App内のページにおいて、ボタンをクリックしたタイミング等で別のデータベースシステムにアクセスして、SQLクエリを実行する必要があります。

JavaScriptでデータベースアクセス処理を記述すると、DBへの接続情報が参照できてしまい、セキュリティ的にはよろしくありません。
サーバサイドでPythonスクリプトを実行させることを考えているのですが、Splunkにおいてスマートなやりかたはどのような方法がありますでしょうか?

App内のページからサーバ上のPythonスクリプトがキックできれば問題ありません。
ページ内で実行したJavaScriptからパラメータを渡す必要があります。

また、スマートではない(簡単ではない)方法も含めて、サーバサイドで処理をさせる方法はどのようなものがありますか?

0 Karma
1 Solution

aljohnson_splun
Splunk Employee
Splunk Employee

まだ日本語を勉強しています、でも、問題を分かるとおもいますが、間違ったら、失礼します。翻訳をしようとしたけど下書きしました。

自分のコマンドを書けます。Python スクリプトはサーチコマンドになれば、Splunkのサーチ言葉をつかえます。

例えば、splunk enable boot-start コマンドを書きたいです。

スクリプトは bootstart.py:

import os
os.system('$SPLUNK_HOME/bin/splunk enable boot-start')

書いた後で、$SPLUNK_HOME/etc/apps/search/bin/ で置きます。

そのあとで、$SPLUNK_HOME/etc/apps/search/local/commands.conf をエディットします

[bootstart]
filename=bootstart.py

最後、Splunk をリスタートをします。

| bootstart を 使えます。

今、そのAppのページのボタンをクリックと、新しいサーチコマンドを使ったら、スクリプトはセキュアです。

文献集:
1。)http://docs.splunk.com/Documentation/Splunk/6.2.1/AdvancedDev/Searchscripts
2。)http://docs.splunk.com/Documentation/Splunk/latest/Search/Writeasearchcommand

View solution in original post

aljohnson_splun
Splunk Employee
Splunk Employee

まだ日本語を勉強しています、でも、問題を分かるとおもいますが、間違ったら、失礼します。翻訳をしようとしたけど下書きしました。

自分のコマンドを書けます。Python スクリプトはサーチコマンドになれば、Splunkのサーチ言葉をつかえます。

例えば、splunk enable boot-start コマンドを書きたいです。

スクリプトは bootstart.py:

import os
os.system('$SPLUNK_HOME/bin/splunk enable boot-start')

書いた後で、$SPLUNK_HOME/etc/apps/search/bin/ で置きます。

そのあとで、$SPLUNK_HOME/etc/apps/search/local/commands.conf をエディットします

[bootstart]
filename=bootstart.py

最後、Splunk をリスタートをします。

| bootstart を 使えます。

今、そのAppのページのボタンをクリックと、新しいサーチコマンドを使ったら、スクリプトはセキュアです。

文献集:
1。)http://docs.splunk.com/Documentation/Splunk/6.2.1/AdvancedDev/Searchscripts
2。)http://docs.splunk.com/Documentation/Splunk/latest/Search/Writeasearchcommand

aljohnson_splun
Splunk Employee
Splunk Employee

DB Connect を使っていますか?

0 Karma

ts_splunk
Path Finder

ご回答ありがとうございます。

今回検討しているシステムではDB Connectを使っています。
しかし、DB Connectを使用しないケースも考慮しておきたいので、カスタムサーチコマンドを使用した方法で検討してみます。

0 Karma

aljohnson_splun
Splunk Employee
Splunk Employee

here is an attempt at translation (its just a rough translation, I'm still learning Japanese):

When using the web framework to build an app,
inside a page on the app, say you click a button or something, you need to run an SQL query.

If you're accessing the database with Javascript, the connection information to the data base would be visible, which is not good from a security standpoint.

I'm thinking about the practice of using server side python scripts, however, what would you say is the smart way of going about doing this?

There isn't a problem in kicking off a python script from the server.

Still, the method I can see isn't smart (it's not simple), so how would one go about using server side scripting ?

0 Karma
Get Updates on the Splunk Community!

.conf24 | Registration Open!

Hello, hello! I come bearing good news: Registration for .conf24 is now open!   conf is Splunk’s rad annual ...

ICYMI - Check out the latest releases of Splunk Edge Processor

Splunk is pleased to announce the latest enhancements to Splunk Edge Processor.  HEC Receiver authorization ...

Introducing the 2024 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...