本文整理汇总了Python中alerta.models.alert.Alert.is_duplicate方法的典型用法代码示例。如果您正苦于以下问题:Python Alert.is_duplicate方法的具体用法?Python Alert.is_duplicate怎么用?Python Alert.is_duplicate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类alerta.models.alert.Alert
的用法示例。
在下文中一共展示了Alert.is_duplicate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: process_alert
# 需要导入模块: from alerta.models.alert import Alert [as 别名]
# 或者: from alerta.models.alert.Alert import is_duplicate [as 别名]
def process_alert(alert: Alert) -> Alert:
wanted_plugins, wanted_config = plugins.routing(alert)
skip_plugins = False
for plugin in wanted_plugins:
if alert.is_suppressed:
skip_plugins = True
break
try:
alert = plugin.pre_receive(alert, config=wanted_config)
except TypeError:
alert = plugin.pre_receive(alert) # for backward compatibility
except (RejectException, HeartbeatReceived, BlackoutPeriod, RateLimit):
raise
except Exception as e:
if current_app.config['PLUGINS_RAISE_ON_ERROR']:
raise RuntimeError("Error while running pre-receive plugin '{}': {}".format(plugin.name, str(e)))
else:
logging.error("Error while running pre-receive plugin '{}': {}".format(plugin.name, str(e)))
if not alert:
raise SyntaxError("Plugin '%s' pre-receive hook did not return modified alert" % plugin.name)
try:
is_duplicate = alert.is_duplicate()
if is_duplicate:
alert = alert.deduplicate(is_duplicate)
else:
is_correlated = alert.is_correlated()
if is_correlated:
alert = alert.update(is_correlated)
else:
alert = alert.create()
except Exception as e:
raise ApiError(str(e))
updated = None
for plugin in wanted_plugins:
if skip_plugins:
break
try:
updated = plugin.post_receive(alert, config=wanted_config)
except TypeError:
updated = plugin.post_receive(alert) # for backward compatibility
except Exception as e:
if current_app.config['PLUGINS_RAISE_ON_ERROR']:
raise ApiError("Error while running post-receive plugin '{}': {}".format(plugin.name, str(e)))
else:
logging.error("Error while running post-receive plugin '{}': {}".format(plugin.name, str(e)))
if updated:
alert = updated
if updated:
alert.tag(alert.tags)
alert.update_attributes(alert.attributes)
return alert