2013-11-26 33 views
0

我使用Esper來生成基於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. 

但eventhough日誌消息包含10倍以上的消息是時間跨度的事件不會被解僱,也沒有任何異常的2分鐘。所以我試圖讓EPL簡單如下。

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

上面這個查詢仍然沒有被解僱。

我無法在Esper官方網站上找到任何與我所尋找的相匹配的例子。

有人可以幫我解決這個問題。

感謝 Shantanooķ

回答

0

實際上,問題出在填充到我的Map中的值中,例如響應字段在Map中被填充爲String,但在我的查詢中,我將它視爲整數字段。 只是因爲我的地圖是類型的,它從來沒有拋出異常。

0

我說你的地圖事件沒有得到您的應用程序無誤。 Esper不會檢查地圖中的每個字段以查看它是否正確填充。它直到您的應用程序正確填充事件。 使用@Audit來查看引擎拉出事件對象的內容。

像這樣移動過濾器是首選 select * from b2cAccessLogEvent(type =「b2c_access」and response = 302 and dc like「%s%」)。win:time(1 minute)count(request)> 10