Kibana 5 に scritpted フィールドを追加して、メッセージからストアド プロシージャ名を取得したいと考えています。各 SP ごとのエラー数を視覚化できるようにするため。エラーテキストが表示される「メッセージ」フィールドがあります。
"[2017-02-03 05:04:51,087] @ MyApp.Common.Server.Logging.ExceptionLogger [ERROR]: XmlWebServices Exception
User:
Name: XXXXXXXXXXXXXXXXXXXXXXX
Email: 926715@test.com
User ID: 926715 (PAID)
Web Server: PERFTESTSRV
Exception:
Type: MyApp.Common.Server.DatabaseException
Message: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
Source: MyApp.Common.Server
Database: MyDB
Cmd Type: StoredProcedure
Cmd Text: spGetData
Trans: YES
Trans Lvl: Unspecified"
ガイド: https://www.elastic.co/blog/using-painless-kibana-scripted-fields
私の計画は、痛みのないスクリプトのようなものを追加することです:
def m = /(?:Cmd\sText:\s*)[a-zA-Z]{1,}/.matcher(doc['message'].value);
if ( m.matches() ) {
return m.group(1)
} else {
return "no match"
}
また、私は試しました
def tst = doc['message'].value;
if (tst != null)
{
def m = /(?:User\sID:\s*)[0-9]{1,}/.matcher(tst);
if ( m.matches() ) {
return m.group(1)
}
} else {
return "no match"
}
doc['message'].value に対処するにはどうすればよいですか? そうしようとすると、「Courier Fetch: 5 of 5 shards failed.」というエラーが表示されました。doc['message.keyword'].value を試してみると、完全なメッセージが含まれていません。内部にあるメッセージの構造をどこで学び、どのように参照すればよいかわかりません。