Skip to content

Commit

Permalink
Add timestamp for alarm
Browse files Browse the repository at this point in the history
  • Loading branch information
tigercl authored and turtleDeng committed May 22, 2020
1 parent 077b5f6 commit 4290cdf
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/emqx_alarm_handler.erl
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,12 @@ encode_alarm({AlarmId, #alarm{severity = Severity,
});

encode_alarm({AlarmId, undefined}) ->
emqx_json:safe_encode(#{id => maybe_to_binary(AlarmId)});
emqx_json:safe_encode(#{id => maybe_to_binary(AlarmId),
desc => #{timestamp => erlang:system_time(second)}});
encode_alarm({AlarmId, AlarmDesc}) ->
emqx_json:safe_encode(#{id => maybe_to_binary(AlarmId),
desc => maybe_to_binary(AlarmDesc)
desc => #{summary => maybe_to_binary(AlarmDesc),
timestamp => erlang:system_time(second)}
}).

alarm_msg(Topic, Payload) ->
Expand Down

0 comments on commit 4290cdf

Please sign in to comment.