Kibana 仪表板:部分消息匹配的聚合

Kibana Dashboard: Aggregation on Partial Message Match

我正在开发一项允许用户完成并提交多个表单的服务。提交每个表单后,将记录一条消息,如:

Form submitted Form-001 with draftId (unique Id) and submissionRef (unique ref)

我想汇总(和计数)并可视化每个表单(基于表单名称 Form-xxx)的提交数量。

我对 kibana 仪表板还很陌生。因此,欢迎所有建议。

我终于想出了如何实现这一点。我将它张贴在这里是为了结束和未来的参考:

方法是在 Kibana 中使用 脚本字段 。脚本字段可以读取消息并根据需要聚合它们。 Kibana 接受 2 种不同语言的脚本字段:Lucene 表达式Painless.

我的解决方案写在painless:

def msg = doc['message.raw'].value;
if(msg != null){ 
    int flagIndex = msg.indexOf('Form submitted');
    if(flagIndex>0){ 
        int toIndex = msg.indexOf(' with draftId');
        return msg.substring(flagIndex+14,toIndex);
    }
}
return "";