【问题标题】:kibana 5 scripted field for regex match用于正则表达式匹配的 kibana 5 脚本字段
【发布时间】:2017-02-08 07:56:55
【问题描述】:

我想在 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 时,里面没有完整的消息。我不明白我在哪里可以了解内部消息的结构以及如何引用它?

【问题讨论】:

  • 我有 script.painless.regex.enabled: true
  • message 的映射看起来如何?当您的脚本中只有以下内容时,您会从脚本字段中得到什么:doc['message.keyword'].value
  • 不确定如何获取消息映射这是我在 Kibana 中看到的 joxi.ru/5mdvBMjSkelGdA 当我有 doc['message.keyword'].value 时,对于我需要的错误类型,我有以下结果结果我只有“ - ”
  • 您是否收到了预期的全部信息?还是缺少什​​么? `需要我只有“ - ”作为结果是什么意思?
  • 对于这种类型的错误,我需要 doc['message.keyword'].value dash 作为结果,并且在“消息”中,屏幕截图中的数据有点像(或在我的示例中)在带有错误文本的问题中)存在一些错误,字段 doc['message.keyword'].value 的结果与字段消息相同。但不幸的是,不适合我需要的人。

标签: regex kibana elasticsearch-painless


【解决方案1】:

我认为这个问题与消息的长度有关。输入“关键字”太长。它应该是无痛不支持的“文本”类型。

https://www.elastic.co/blog/using-painless-kibana-scripted-fields

Painless 和 Lucene 表达式都对存储在 doc_values 中的字段进行操作。因此>对于字符串数据,您需要将字符串存储在数据类型>关键字中。基于 Painless 的脚本字段也不能直接对 >_source 进行操作。

https://www.elastic.co/guide/en/elasticsearch/reference/master/keyword.html_italic_

用于索引结构化内容的字段,例如电子邮件地址、主机名、状态 >代码、邮政编码或标签。 如果您需要索引全文内容(例如电子邮件正文或产品>描述),您可能应该使用文本字段。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-10-17
    • 2017-12-21
    • 2010-10-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-09
    • 2010-10-10
    相关资源
    最近更新 更多