我使用Esper根据激发的esper查询生成警报消息。
我使用Map作为java对象来绑定所有日志消息,这是在外部esper文件中定义的,如下所示。
<?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官方网站,将匹配什么,我正在寻找。
发布于 2013-11-30 16:09:39
实际上,问题在于将值填充到Map中,例如,响应字段在Map中被填充为字符串,但在我的查询中,我将其视为整数字段。仅仅因为我的Map是类型的,它从来没有抛出异常。
发布于 2013-11-29 13:52:57
我想说的是,应用程序没有正确地填充Map事件。Esper将不会检查地图中的每个字段是否正确填充。这取决于你的应用程序正确填充事件。使用@ engine查看引擎从事件对象中提取了什么。
从b2cAccessLogEvent(type="b2c_access“并响应= 302和dc类似于"%s%").win:time(1分钟)移动首选选择*,其计数(请求)> 10。
https://stackoverflow.com/questions/20228413
复制相似问题