def _get_alerts(self, q: str, q_args: Iterable[Any]) -> List[Dict[str, Any]]:
rows = await self.request.app['dbcon'].fetch_all(q, q_args)
ret = []
for id, monitor_id, start_ts, end_ts, alert_msg in rows:
alert = {
'id': id,
'monitor_id': monitor_id,
'start_ts': start_ts,
'end_ts': end_ts,
'alert_msg': alert_msg,
'monitor_description': '',
}
monitor = self.request.app['active_monitor_manager'].monitors.get(monitor_id, None) # type: ActiveMonitor
if monitor:
alert['monitor_description'] = monitor.get_description()
ret.append(alert)
return ret
评论列表
文章目录