0

我正在使用 Esper 根据被触发的 esper 查询生成警报消息。

我使用 Map 作为 java 对象来绑定所有日志消息,并在外部 esper config xml 文件中定义如下。

<?xml version="1.0" encoding="UTF-8"?>
<esper-configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.espertech.com/schema/esper"
xsi:schemaLocation="http://www.espertech.com/schema/esper
http://www.espertech.com/schema/esper/esper-configuration-2.0.xsd">
<!-- <event-type name="StockTick" class="com.espertech.esper.example.stockticker.event.StockTick"/>
<event-type name="PriceLimit" class="com.espertech.esper.example.stockticker.event.PriceLimit"/>
<auto-import import-name="org.mycompany.mypackage.MyUtility"/>
<auto-import import-name="org.mycompany.util.*"/> -->

<event-type name="b2cAccessLogEvent">
 <java-util-map>
  <map-property name="request" class="string"/>
  <map-property name="response" class="int"/>
  <map-property name="type" class="string"/>
  <map-property name="dc" class="int"/>
  <map-property name="message" class="string"/>
  <map-property name="source" class="string"/>
  <map-property name="source_host" class="string"/>
  <map-property name="source_path" class="string"/>
  <map-property name="agent" class="string"/>
  <map-property name="duration" class="string"/>
  <map-property name="@timestamp" class="string"/>    
 </java-util-map>
</event-type>
</esper-configuration>

我正在从队列中读取日志消息。我对事件获取触发器的要求如下 1. 如果类型 = "b2c_access" 的日志消息中的响应字段为 = 302,并且 1 分钟内具有此响应代码的日志消息计数 > 10,则触发事件。

我有以下 EPL

select * from b2cAccessLogEvent(type="b2c_access").win:time(1 minute) having response = 302 and dc like "%s%" and count(request) > 10.

但是,即使日志消息包含超过 10 条消息,时间跨度为 2 分钟,事件也不会被触发,也不会出现任何异常。所以我试图使EPL简单如下。

select * from b2cAccessLogEvent(type="b2c_access").win:time(1 minute) having response = 302

上面的查询仍然没有被解雇。

我无法在 Esper 官方网站上找到任何与我正在寻找的匹配的示例。

4

2 回答 2

0

实际上,问题在于值被填充到我的地图中,例如,响应字段在地图中被填充为字符串,但在我的查询中,我将其视为整数字段。只是因为我的 Map 是类型,所以它从未抛出异常。

于 2013-11-30T16:09:39.733 回答
0

我会说您的地图事件没有被您的应用程序正确填充。Esper 不会检查地图中的每个字段以查看其是否正确填充。正确填充事件取决于您的应用程序。使用@Audit 查看引擎从您的事件对象中提取了什么。

像这样移动过滤器是首选 select * from b2cAccessLogEvent(type="b2c_access" and response = 302 and dc like "%s%").win:time(1 minute) with count(request) > 10.

于 2013-11-29T13:52:57.757 回答