我正在使用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.如果type =“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官方网站上找到符合我要求的任何示例。
答案 0 :(得分:0)
我说您的地图事件没有被您的应用程序正确填充。 Esper不会检查地图中的每个字段,以查看其是否正确填充。由您的应用程序来正确填充事件。 使用@Audit查看引擎从事件对象中拉出的内容。
首选移动过滤器是首选 select * from b2cAccessLogEvent(type =“b2c_access”and response = 302 and dc like“%s%”)。win:time(1分钟)有计数(请求)&gt; 10。
答案 1 :(得分:0)
实际上问题是将值填充到我的Map中,例如响应字段在Map中填充为String但在我的查询中我将其视为整数字段。 只是因为我的地图属于类型,它从未抛出异常。