本文整理汇总了Python中alerta.models.alert.Alert.get_counts_by_severity方法的典型用法代码示例。如果您正苦于以下问题:Python Alert.get_counts_by_severity方法的具体用法?Python Alert.get_counts_by_severity怎么用?Python Alert.get_counts_by_severity使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类alerta.models.alert.Alert
的用法示例。
在下文中一共展示了Alert.get_counts_by_severity方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_counts
# 需要导入模块: from alerta.models.alert import Alert [as 别名]
# 或者: from alerta.models.alert.Alert import get_counts_by_severity [as 别名]
def get_counts():
query = qb.from_params(request.args)
severity_count = Alert.get_counts_by_severity(query)
status_count = Alert.get_counts_by_status(query)
return jsonify(
status="ok",
total=sum(severity_count.values()),
severityCounts=severity_count,
statusCounts=status_count
)
示例2: search_alerts
# 需要导入模块: from alerta.models.alert import Alert [as 别名]
# 或者: from alerta.models.alert.Alert import get_counts_by_severity [as 别名]
def search_alerts():
query_time = datetime.utcnow()
query = qb.from_params(request.args, query_time)
severity_count = Alert.get_counts_by_severity(query)
status_count = Alert.get_counts_by_status(query)
total = sum(severity_count.values())
paging = Page.from_params(request.args, total)
alerts = Alert.find_all(query, paging.page, paging.page_size)
if alerts:
return jsonify(
status="ok",
page=paging.page,
pageSize=paging.page_size,
pages=paging.pages,
more=paging.has_more,
alerts=[alert.serialize for alert in alerts],
total=total,
statusCounts=status_count,
severityCounts=severity_count,
lastTime=max([alert.last_receive_time for alert in alerts]),
autoRefresh=Switch.find_by_name('auto-refresh-allow').is_on
)
else:
return jsonify(
status="ok",
message="not found",
page=paging.page,
pageSize=paging.page_size,
pages=0,
more=False,
alerts=[],
total=0,
severityCounts=severity_count,
statusCounts=status_count,
lastTime=query_time,
autoRefresh=Switch.find_by_name('auto-refresh-allow').is_on
)