我正在使用 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 官方网站上找到任何与我正在寻找的匹配的示例。