Fix the AFD fields list
With the 'group_by' attribute, the fields list which triggers the alert must contain the field values instead of the field matching pattern. Change-Id: I5c5414dd72de5235ed8c94fa4281e9567bdd499b Implements-blueprint: afd-alarm-fields-matching
This commit is contained in:
parent
f86b49893e
commit
14cd2e1755
@ -179,9 +179,13 @@ function Rule:add_value(ts, value, fields)
|
||||
local uniq_field_id = self:get_datastore_id(fields)
|
||||
if not self.datastore[uniq_field_id] then
|
||||
self.datastore[uniq_field_id] = {
|
||||
fields = fields,
|
||||
fields = self.fields,
|
||||
cbuf = self:get_circular_buffer()
|
||||
}
|
||||
if #self.group_by > 0 then
|
||||
self.datastore[uniq_field_id].fields = fields
|
||||
end
|
||||
|
||||
self:add_datastore(uniq_field_id)
|
||||
end
|
||||
data = self.datastore[uniq_field_id]
|
||||
|
@ -693,7 +693,7 @@ function TestLMAAlarm:test_rules_fields()
|
||||
local state, result = root_fs:evaluate(t)
|
||||
assertEquals(#result, 1)
|
||||
|
||||
assertItemsEquals(result[1].fields, {{name='fs', value='/'}})
|
||||
assertItemsEquals(result[1].fields, {})
|
||||
assertEquals(result[1].value, 8)
|
||||
end
|
||||
|
||||
@ -730,6 +730,7 @@ function TestLMAAlarm:test_rule_with_multivalue()
|
||||
lma_alarm.add_value(next_time(), 'http_response_times', {upper_90 = 4, foo = 1}, {http_method = 'POST'})
|
||||
local state, result = lma_alarm.evaluate(next_time()) -- window 60 second
|
||||
assertEquals(state, consts.WARN)
|
||||
assertItemsEquals(result[1].alert.fields, {{name='http_method', value='POST'}})
|
||||
assertEquals(result[1].alert.value, 6)
|
||||
end
|
||||
|
||||
@ -780,6 +781,7 @@ function TestLMAAlarm:test_complex_field_matching_alarm_trigger()
|
||||
local state, result = lma_alarm.evaluate(next_time()) -- window 60 second
|
||||
assertEquals(state, consts.WARN)
|
||||
assertEquals(result[1].alert.value, 6) -- the max
|
||||
assertItemsEquals(result[1].alert.fields, {{name='http_method', value='POST || GET'}, {name="http_status", value="2xx || ==3xx"}})
|
||||
end
|
||||
|
||||
function TestLMAAlarm:test_complex_field_matching_alarm_ok()
|
||||
|
Loading…
Reference in New Issue
Block a user