我想在 Kibana 5 中添加脚本字段以从消息中获取存储的过程名称。能够可视化每个 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
我的计划是添加类似 Painless 脚本的内容:
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 时,里面没有完整的消息。我不明白我在哪里可以了解内部消息的结构以及如何引用它?