Skip to content
Snippets Groups Projects
Commit 6d1dd00d authored by Nikolay Stanchev's avatar Nikolay Stanchev
Browse files

Updates alerts specificaiton documentation

parent 1f080c9d
No related branches found
No related tags found
No related merge requests found
......@@ -235,8 +235,10 @@ format `<measurement>`.`<field>`. The only exception is when a **deadman** event
the event_type is set to **threshold**.
* **resource_type** - provides context for the given event - key-value pairs for the global tags of the CLMC Information Model.
This includes any of the following: `"sfc", "sfci", "sf_package", "sf", "sf_endpoint", "host", "location"`. Keep in mind that
filtering for **sfc** and **sfci** is automatically generated by extracting the metadata values from the alerts specification.
* **comparison_operator** - the logical operator to use for comparison - lt (less than), gt ()greater than), lte (less than or equal to), etc.
* **comparison_operator** - the logical operator to use for comparison - lt (less than), gt (greater than), lte (less than or equal to), etc.
* **implementation** - a list of the URLs of alert handlers to which alert data is sent when the event condition is true.
......
......@@ -108,8 +108,6 @@ class TICKScriptTemplateFiller:
fill_function_name = "_fill_{0}_template_vars".format(template_type)
fill_function = getattr(TICKScriptTemplateFiller, fill_function_name) # python functions are first-class objects !
# TODO is this the best way to avoid long if-else chains ?
return fill_function(**kwargs)
@staticmethod
......
......@@ -96,9 +96,11 @@ class AlertsConfigurationAPI(object):
sfc, sfc_instance = tosca_tpl.tpl["metadata"]["sfc"], tosca_tpl.tpl["metadata"]["sfci"]
db = sfc # ASSUMPTION: database per service function chain, named after the service function chain ID
# two lists to keep track of any errors while interacting with the Kapacitor HTTP API
alert_tasks_errors = []
alert_handlers_errors = []
# iterate through every policy and extract all triggers of the given policy
for policy in tosca_tpl.policies:
for trigger in policy.triggers:
event_id = trigger.name
......@@ -115,6 +117,9 @@ class AlertsConfigurationAPI(object):
where_clause = None
if "resource_type" in trigger.trigger_tpl["condition"]:
tags = condition["resource_type"]
# make sure alert tasks are executing with queries for the given sfc and sfc instance
# tags["sfc"] = sfc TODO uncomment this line when we updated telegraf to name db after sfc
# tags["sfci"] = sfc_instance TODO uncomment this line when telegraf global tags are updated, currently we have sfc_i instead of sfci
# NOTE: if the template has its where clause defined as lambda (stream templates), then use "==" as comparison operator,
# else if the template's where clause is defined as a string (batch templates), then use "=" as comparison operator
......@@ -130,7 +135,7 @@ class AlertsConfigurationAPI(object):
alert_id = "{0}.{1}.{2}.{3}".format(sfc, sfc_instance, policy.name, event_id)
# built up the template vars dictionary depending on the event type (threshold, relative, etc.)
# all extracted properties from the trigger are passed, the TICKScriptTemplateFiller entry point then forwards those to the appropriate function
# all extracted properties from the trigger are passed, the TICKScriptTemplateFiller entry point then forwards those to the appropriate function for template filling
template_vars = TICKScriptTemplateFiller.fill_template_vars(event_type, db=db, measurement=measurement, field=field, influx_function=influx_function,
critical_value=critical_value, comparison_operator=comparison_operator, alert_period=alert_period,
topic_id=topic_id, where_clause=where_clause)
......@@ -159,7 +164,7 @@ class AlertsConfigurationAPI(object):
"error": response_content.get("error")
})
# exttranc http handlers
# extract http handlers
http_handlers = trigger.trigger_tpl["action"]["implementation"]
# subscribe all http handlers to the created topic
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment