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

Initial implementation of the alerts API - WIP, to be tested

parent f8a9167d
No related branches found
No related tags found
No related merge requests found
Showing
with 1014 additions and 9 deletions
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
*egg-info* *egg-info*
*git-commit-ref* *git-commit-ref*
*_version.py* *_version.py*
ubuntu-xenial-16.04-cloudimg-console.log ubuntu-bionic-18.04-cloudimg-console.log
.idea/ .idea/
*.egg *.egg
*.pyc *.pyc
......
include MANIFEST.in include clmcservice/resources/tosca/flame_clmc_alerts_definitions.yaml
recursive-include clmcservice include clmcservice/VERSION
\ No newline at end of file recursive-include clmcservice/resources/TICKscript *_template.tick
\ No newline at end of file
__version__ = "1.2.0"
\ No newline at end of file
...@@ -22,12 +22,21 @@ ...@@ -22,12 +22,21 @@
// Created for Project : FLAME // Created for Project : FLAME
""" """
from os import path
# Python standard libs
from json import load from json import load
from os.path import dirname, abspath
# PIP installed libs
from pyramid.config import Configurator from pyramid.config import Configurator
from sqlalchemy import engine_from_config from sqlalchemy import engine_from_config
# CLMC-service imports
from clmcservice.models.meta import DBSession, Base from clmcservice.models.meta import DBSession, Base
from clmcservice.aggregationapi.utilities import validate_conf_file, RUNNING_FLAG, MALFORMED_FLAG, CONF_FILE_ATTRIBUTE, CONF_OBJECT, AGGREGATOR_CONFIG_SECTION from clmcservice.aggregationapi.utilities import validate_conf_file, MALFORMED_FLAG, CONF_FILE_ATTRIBUTE, CONF_OBJECT
ROOT_DIR = dirname(abspath(__file__)) # get the path of the root package (clmcservice) as a global variable
def main(global_config, **settings): def main(global_config, **settings):
...@@ -62,14 +71,13 @@ def main(global_config, **settings): ...@@ -62,14 +71,13 @@ def main(global_config, **settings):
config.add_route('whoami_endpoints', '/whoami/endpoints') config.add_route('whoami_endpoints', '/whoami/endpoints')
config.add_route('whoami_endpoints_instance', 'whoami/endpoints/instance') config.add_route('whoami_endpoints_instance', 'whoami/endpoints/instance')
# add routes of the CONFIG API
config.add_route('config_sfc', '/config/sf-chains')
config.add_route('config_sfc_instance', '/config/sf-chains/instance')
# add routes of the GRAPH API # add routes of the GRAPH API
config.add_route('graph_build', '/graph/temporal') config.add_route('graph_build', '/graph/temporal')
config.add_route('graph_manage', '/graph/temporal/{graph_id}') config.add_route('graph_manage', '/graph/temporal/{graph_id}')
config.add_route('graph_algorithms_rtt', '/graph/temporal/{graph_id}/round-trip-time') config.add_route('graph_algorithms_rtt', '/graph/temporal/{graph_id}/round-trip-time')
# add routes of the Alerts Configuration API
config.add_route('alerts_configuration', '/alerts')
config.scan() # This method scans the packages and finds any views related to the routes added in the app configuration config.scan() # This method scans the packages and finds any views related to the routes added in the app configuration
return config.make_wsgi_app() return config.make_wsgi_app()
#!/usr/bin/python3
"""
// © University of Southampton IT Innovation Centre, 2018
//
// Copyright in this software belongs to University of Southampton
// IT Innovation Centre of Gamma House, Enterprise Road,
// Chilworth Science Park, Southampton, SO16 7NS, UK.
//
// This software may not be used, sold, licensed, transferred, copied
// or reproduced in whole or in part in any manner or form or in or
// on any media by any person other than in accordance with the terms
// of the Licence Agreement supplied with the software, or otherwise
// without the prior written consent of the copyright owners.
//
// This software is distributed WITHOUT ANY WARRANTY, without even the
// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE, except where stated in the Licence Agreement supplied with
// the software.
//
// Created By : Nikolay Stanchev
// Created Date : 16-08-2018
// Created for Project : FLAME
"""
# Python standard libs
from re import compile, IGNORECASE
# PIP installed libs
from schema import Schema, And, Or, Optional
"""
This module defines the schema objects for the TOSCA Alert Specification:
* flame_clmc_alerts_definitions.yaml must be the only import
* metadata section must be present (with key-value pairs for sfc and sfci)
* policies section must be present (under the topology_template node)
* each policy must be associated with a triggers node (containing at least 1 trigger)
* each policy is of type eu.ict-flame.policies.StateChange or eu.ict-flame.policies.Alert
* each trigger must specify event_type, metric, condition, and at least one handler in action/implementation
* the condition section must specify threshold, granularity, aggregation_method, comparison_operator
"""
# Influx QL functions defined in the documentation https://docs.influxdata.com/influxdb/v1.6/query_language/functions/
INFLUX_QL_FUNCTIONS = (
"count", "mean", "median", "mode", "sum", "first", "last", "max", "min"
)
# Kapacitor Tick Script template IDs
TICK_SCRIPT_TEMPLATES = ("threshold", "relative", "deadman")
# Allowed comparison operators and their logical values
COMPARISON_OPERATORS = {"lt": "<", "gt": ">", "lte": "<=", "gte": ">=", "eq": "=", "neq": "<>"}
# Regular expression for validating http handlers
URL_REGEX = compile(
r'^https?://' # http:// or https://
r'(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|' # domain, e.g. example.domain.com
r'localhost|' # or localhost...
r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})' # or IP address (IPv4 format)
r'(?::\d{2,5})?' # optional port number
r'(?:[/?#][^\s]*)?$', # URL path or query parameters
IGNORECASE)
# Global tags allowed to be used for filtering in the trigger condition
CLMC_INFORMATION_MODEL_GLOBAL_TAGS = ("sfc", "sfci", "sf_package", "sf", "sf_endpoint", "host", "location")
ALERTS_SPECIFICATION_SCHEMA = Schema({
"tosca_definitions_version": And(str, lambda v: v == "tosca_simple_profile_for_nfv_1_0_0"),
Optional("description"): str,
"imports": And([lambda s: s.endswith("flame_clmc_alerts_definitions.yaml")], lambda l: len(l) == 1),
"metadata": {
"sfc": str,
"sfci": str
},
"topology_template": {
"policies": [
{
str: {
"type": Or("eu.ict-flame.policies.StateChange", "eu.ict-flame.policies.Alert"),
"triggers": And({
str: {
Optional("description"): str,
"event_type": And(str, lambda s: s in TICK_SCRIPT_TEMPLATES),
"metric": And(str, lambda s: len(s.split('.', 1)) == 2),
"condition": {
"threshold": Or(int, float),
"granularity": int,
"aggregation_method": And(str, lambda s: s in INFLUX_QL_FUNCTIONS),
Optional("resource_type"): {
And(str, lambda s: s in CLMC_INFORMATION_MODEL_GLOBAL_TAGS): str
},
"comparison_operator": And(str, lambda s: s in COMPARISON_OPERATORS)
},
"action": {
"implementation":
[
And(str, lambda s: URL_REGEX.match(s) is not None)
]
}
}
}, lambda l: len(l) > 0)
}
}
]
}
})
def fill_http_post_handler_vars(handler_id, handler_url):
"""
Creates a dictionary object ready to be posted to kapacitor to create an alert handler.
:param handler_id: handler identifier
:param handler_url: url to post alerts to
:return: a dictionary object ready to be posted to kapacitor to create an alert handler.
"""
return {
"id": handler_id,
"kind": "post",
"options": {
"url": handler_url
}
}
def fill_threshold_template_vars(db, measurement, field, influx_function, critical_value, comparison_operator, alert_period, topic_id, where_clause=None):
"""
Creates a dictionary object ready to be posted to kapacitor to create a task from template.
:param db: db name
:param measurement: measurement name
:param field: field name
:param influx_function: influx function to use for querying
:param critical_value: critical value to compare with
:param comparison_operator: type of comparison
:param alert_period: alert period to query influx
:param topic_id: topic identifier
:param where_clause: optional argument for filtering the influx query by tag values
:return: a dictionary object ready to be posted to kapacitor to create a task from template.
"""
comparison_lambda = "\"real_value\" {0} {1}".format(comparison_operator, critical_value) # build up lambda string, e.g. "real_value" >= 10
tempalte_vars = {
"db": {
"type": "string",
"value": db
},
"measurement": {
"type": "string",
"value": measurement
},
"field": {
"type": "string",
"value": field
},
"influxFunction": {
"type": "string",
"value": influx_function
},
"comparisonLambda": {
"type": "lambda",
"value": comparison_lambda
},
"alertPeriod": {
"type": "duration",
"value": alert_period
},
"topicID": {
"type": "string",
"value": topic_id
}
}
if where_clause is not None:
tempalte_vars["whereClause"] = {
"type": "string",
"value": where_clause
}
return tempalte_vars
#!/usr/bin/python3
"""
// © University of Southampton IT Innovation Centre, 2018
//
// Copyright in this software belongs to University of Southampton
// IT Innovation Centre of Gamma House, Enterprise Road,
// Chilworth Science Park, Southampton, SO16 7NS, UK.
//
// This software may not be used, sold, licensed, transferred, copied
// or reproduced in whole or in part in any manner or form or in or
// on any media by any person other than in accordance with the terms
// of the Licence Agreement supplied with the software, or otherwise
// without the prior written consent of the copyright owners.
//
// This software is distributed WITHOUT ANY WARRANTY, without even the
// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE, except where stated in the Licence Agreement supplied with
// the software.
//
// Created By : Nikolay Stanchev
// Created Date : 14-08-2018
// Created for Project : FLAME
"""
# Python standard libs
from os import listdir
from os.path import isfile, join
from yaml import load
# PIP installed libs
import pytest
from pyramid import testing
from toscaparser.tosca_template import ToscaTemplate
# CLMC-service imports
from clmcservice.alertsapi.utilities import adjust_tosca_definitions_import, validate_clmc_alerts_specification
from clmcservice.alertsapi.views import AlertsConfigurationAPI
from clmcservice import ROOT_DIR
class TestAlertsConfigurationAPI(object):
"""
A pytest-implementation test for the Alerts Configuration API endpoints.
"""
@pytest.fixture(autouse=True)
def print_fixture(self):
"""
Fixture to adjust the printing format when running pytest with the "-s" flag - by default print messages mix up with pytest's output
"""
print()
@pytest.fixture()
def app_config(self):
"""
A fixture to implement setUp/tearDown functionality for all tests by initializing configuration structure for the web service
"""
self.registry = testing.setUp()
yield
testing.tearDown()
def test_alerts_config_tosca_parsing(self):
"""
Tests that what we consider a valid/invalid alerts specification is successfully/unsuccessfully parsed by the TOSCA-parser.
"""
for path_suffix, valid_expected in (("valid", True), ("invalid", False)):
test_data_path = join(ROOT_DIR, *["resources", "tosca", "test-data", "tosca-parser", path_suffix])
for test_file_path in listdir(test_data_path):
alert_config_abs_path = join(test_data_path, test_file_path)
if not isfile(alert_config_abs_path):
continue # skip directories
if not test_file_path.lower().endswith('.yaml'):
continue # non-yaml files are not intended for being tested
print(alert_config_abs_path, valid_expected)
with open(alert_config_abs_path, 'r') as fh:
yaml_content = load(fh)
adjust_tosca_definitions_import(yaml_content)
valid_real = True
try:
ToscaTemplate(yaml_dict_tpl=yaml_content)
except Exception:
valid_real = False
assert valid_expected == valid_real, "TOSCA parser test failed for file: {0}".format(alert_config_abs_path)
def test_alerts_config_clmc_validation(self):
"""
Tests the custom CLMC validation of the TOSCA alerts specification.
"""
for path_suffix, valid_expected in (("valid", True), ("invalid", False)):
test_data_path = join(ROOT_DIR, *["resources", "tosca", "test-data", "clmc-validator", path_suffix])
for test_file_path in listdir(test_data_path):
alert_config_abs_path = join(test_data_path, test_file_path)
if not isfile(alert_config_abs_path):
continue # skip directories
if not test_file_path.lower().endswith('.yaml'):
continue # non-yaml files are not intended for being tested
print(alert_config_abs_path, valid_expected)
with open(alert_config_abs_path, 'r') as fh:
yaml_content = load(fh)
adjust_tosca_definitions_import(yaml_content)
# do not catch exceptions here since we are testing the clmc validator, the tosca parsing is tested in the previous test method
alert_tosca_spec = ToscaTemplate(yaml_dict_tpl=yaml_content)
valid_real, err = validate_clmc_alerts_specification(alert_tosca_spec.tpl, include_error=True)
assert valid_expected == valid_real, "CLMC alerts specification validator test failed for file: {0}".format(alert_config_abs_path)
def test_alerts_config_api_post(self, app_config):
"""
Tests the POST API endpoint of the alerts configuration API responsible for receiving alerts specifications.
:param app_config: fixture for setUp/tearDown of the web service registry
"""
pass
#!/usr/bin/python3
"""
// © University of Southampton IT Innovation Centre, 2018
//
// Copyright in this software belongs to University of Southampton
// IT Innovation Centre of Gamma House, Enterprise Road,
// Chilworth Science Park, Southampton, SO16 7NS, UK.
//
// This software may not be used, sold, licensed, transferred, copied
// or reproduced in whole or in part in any manner or form or in or
// on any media by any person other than in accordance with the terms
// of the Licence Agreement supplied with the software, or otherwise
// without the prior written consent of the copyright owners.
//
// This software is distributed WITHOUT ANY WARRANTY, without even the
// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE, except where stated in the Licence Agreement supplied with
// the software.
//
// Created By : Nikolay Stanchev
// Created Date : 16-08-2018
// Created for Project : FLAME
"""
# Python standard libs
from os.path import join
# PIP installed libs
from schema import SchemaError
# CLMC-service imports
from clmcservice import ROOT_DIR
from clmcservice.alertsapi.alerts_specification_schema import ALERTS_SPECIFICATION_SCHEMA
CLMC_ALERTS_TOSCA_DEFINITIONS_REL_PATH = ["resources", "tosca", "flame_clmc_alerts_definitions.yaml"]
CLMC_ALERTS_TOSCA_DEFINITIONS_ABS_PATH = join(ROOT_DIR, *CLMC_ALERTS_TOSCA_DEFINITIONS_REL_PATH)
CLMC_ALERTS_TOSCA_DEFINITIONS_FILE = CLMC_ALERTS_TOSCA_DEFINITIONS_REL_PATH[-1]
def adjust_tosca_definitions_import(alert_spec):
"""
A utility function to adjust any imports of flame_clmc_alerts_definitions.yaml to point to the correct location of
the tosca definitions file.
:param alert_spec: the TOSCA alert specification content (yaml dict)
"""
global CLMC_ALERTS_TOSCA_DEFINITIONS_ABS_PATH
try:
import_index = alert_spec["imports"].index(CLMC_ALERTS_TOSCA_DEFINITIONS_FILE)
alert_spec["imports"][import_index] = CLMC_ALERTS_TOSCA_DEFINITIONS_ABS_PATH
except Exception:
pass # nothing to replace if the import is not specified (either imports are missed, or no reference to the clmc tosca definitions file)
def validate_clmc_alerts_specification(tosca_yaml_tpl, include_error=False):
"""
CLMC validation for the TOSCA alerts specification, uses the schema defined in alerts_specification_schema.py
:param tosca_yaml_tpl: the tosca template to validate (as python dictionary object)
:param include_error: a flag indicating whether the output of the function should include a caught SchemaError
(if set to True and no error is thrown, returns None as the error object)
:return: True/False if the tosca_tpl is valid/invalid along with any error (None if no error) that was thrown during validation (if argument include_error is set to True)
"""
try:
ALERTS_SPECIFICATION_SCHEMA.validate(tosca_yaml_tpl)
valid, err = True, None
except SchemaError as e:
valid, err = False, e
if include_error:
return valid, err
else:
return valid
#!/usr/bin/python3
"""
// © University of Southampton IT Innovation Centre, 2018
//
// Copyright in this software belongs to University of Southampton
// IT Innovation Centre of Gamma House, Enterprise Road,
// Chilworth Science Park, Southampton, SO16 7NS, UK.
//
// This software may not be used, sold, licensed, transferred, copied
// or reproduced in whole or in part in any manner or form or in or
// on any media by any person other than in accordance with the terms
// of the Licence Agreement supplied with the software, or otherwise
// without the prior written consent of the copyright owners.
//
// This software is distributed WITHOUT ANY WARRANTY, without even the
// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE, except where stated in the Licence Agreement supplied with
// the software.
//
// Created By : Nikolay Stanchev
// Created Date : 14-08-2018
// Created for Project : FLAME
"""
# Python standard libs
import logging
# PIP installed libs
from pyramid.httpexceptions import HTTPBadRequest
from pyramid.view import view_defaults, view_config
from yaml import load, YAMLError
from toscaparser.tosca_template import ToscaTemplate
from requests import post
# CLMC-service imports
from clmcservice.alertsapi.utilities import validate_clmc_alerts_specification, adjust_tosca_definitions_import
from clmcservice.alertsapi.alerts_specification_schema import COMPARISON_OPERATORS, fill_threshold_template_vars, fill_http_post_handler_vars
# initialise logger
log = logging.getLogger('service_logger')
@view_defaults(renderer='json')
class AlertsConfigurationAPI(object):
"""
A class-based view for configuring alerts within CLMC.
"""
def __init__(self, request):
"""
Initialises the instance of the view with the request argument.
:param request: client's call request
"""
self.request = request
@view_config(route_name='alerts_configuration', request_method='POST')
def post_alerts_specification(self):
"""
The view for receiving and configuring alerts based on the TOSCA alerts specification document.
:raises HTTPBadRequest: if the request doesn't contain a (YAML) file input referenced as alert-spec representing the TOSCA Alerts Specification
"""
if not hasattr(self.request.POST.get('alert-spec'), "file") or not hasattr(self.request.POST.get('alert-spec'), "filename"):
raise HTTPBadRequest("Request to this API endpoint must include a (YAML) file input referenced as 'alert-spec' representing the TOSCA Alerts Specification.")
input_filename = self.request.POST['alert-spec'].filename
input_file = self.request.POST['alert-spec'].file
if not input_filename.lower().endswith('.yaml'):
raise HTTPBadRequest("Request to this API endpoint must include a (YAML) file input referenced as 'alert-spec' representing the TOSCA Alerts Specification.")
try:
yaml_content = load(input_file)
adjust_tosca_definitions_import(yaml_content)
except YAMLError as err:
log.error("Couldn't parse user request file {0} to yaml format due to error: {1}".format(input_filename, err))
log.error("Invalid content is: {0}".format(input_file.read()))
raise HTTPBadRequest("Request alert specification file could not be parsed as valid YAML document.")
try:
tosca_tpl = ToscaTemplate(yaml_dict_tpl=yaml_content)
except Exception as e:
log.error(e)
raise HTTPBadRequest("Request alert specification file could not be parsed as a valid TOSCA document.")
valid_alert_spec = validate_clmc_alerts_specification(tosca_tpl.tpl)
if not valid_alert_spec:
raise HTTPBadRequest("Request alert specification file could not be validated as a CLMC TOSCA alerts specification document.")
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
for policy in tosca_tpl.policies:
for trigger in policy.triggers:
event_id = trigger.name
event_type = trigger.trigger_tpl["event_type"]
template_id = "{0}_template".format(event_type)
measurement, field = trigger.trigger_tpl["metric"].split(".")
critical_value = float(trigger.trigger_tpl["condition"]["threshold"])
alert_period = "{0}s".format(trigger.trigger_tpl["condition"]["granularity"])
influx_function = trigger.trigger_tpl["condition"]["aggregation_method"]
where_clause = None
if "resource_type" in trigger.trigger_tpl["condition"]:
tags = trigger.trigger_tpl["conditon"]["resource_type"]
where_clause = " AND ".join(map(lambda tag_name: "{0}={1}".format(tag_name, tags[tag_name]), tags))
comparison_operator = COMPARISON_OPERATORS[trigger.trigger_tpl["condition"]["comparison_operator"]]
http_handlers = trigger.trigger_tpl["action"]["implementation"]
topic_id = "{0}___{1}___{2}".format(sfc, sfc_instance, event_id) # scoped per service function chain instance (no two sfc instances report to the same topic)
alert_id = "{0}___{1}".format(policy.name, event_id)
# create and activate alert task
kapacitor_api_tasks_url = "http://localhost:9092/kapacitor/v1/tasks"
if event_type == "threshold":
kapacitor_http_request_body = {
"id": alert_id,
"template-id": template_id,
"dbrps": [{"db": db, "rp": "autogen"}],
"status": "enabled",
"vars": fill_threshold_template_vars(db, measurement, field, influx_function, critical_value,
comparison_operator, alert_period, topic_id, where_clause=where_clause)
}
response = post(kapacitor_api_tasks_url, data=kapacitor_http_request_body)
response_content = response.json()
log.info(response_content)
kapacitor_api_handlers_url = "http://localhost:9092/kapacitor/v1/alerts/topics/{0}/handlers".format(topic_id)
for http_handler_url in http_handlers:
handler_id = "{0}___{1}___{2}".format(policy.name, event_id, http_handler_url)
kapacitor_http_request_body = fill_http_post_handler_vars(handler_id, http_handler_url)
response = post(kapacitor_api_handlers_url, data=kapacitor_http_request_body)
response_content = response.json()
log.info(response_content)
return {"msg": "Alerts specification has been successfully validated and configured", "service_function_chain_id": sfc,
"service_function_chain_instance_id": sfc_instance}
var db string var db string // database per service function chain, so db is named after sfc
var rp = 'autogen' // default value for the retention policy var rp = 'autogen' // default value for the retention policy
...@@ -6,21 +6,24 @@ var measurement string ...@@ -6,21 +6,24 @@ var measurement string
var field string var field string
var whereCondition = 'TRUE' // default value is TRUE, hence no filtering of the query result var influxFunction string
var whereClause = 'TRUE' // default value is TRUE, hence no filtering of the query result
var messageValue = 'TRUE' // default value is TRUE, as this is what SFEMC expects as a notification for an event rule var messageValue = 'TRUE' // default value is TRUE, as this is what SFEMC expects as a notification for an event rule
var criticalValue float var comparisonLambda lambda
var alertPeriod = 60s // this value is read from TOSCA and is measured in seconds, default value is 60 seconds var alertPeriod duration
var topicID string var topicID string
batch batch
|query('SELECT mean(' + field + ') AS mean_value FROM "' + db + '"."' + rp + '"."' + measurement + '" WHERE ' + whereCondition) |query('SELECT ' + influxFunction + '(' + field + ') AS real_value FROM "' + db + '"."' + rp + '"."' + measurement + '" WHERE ' + whereClause)
.period(alertPeriod) .period(alertPeriod)
.every(alertPeriod) .every(alertPeriod)
|alert() |alert()
.crit(lambda: "mean_value" >= criticalValue) .crit(comparisonLambda)
.message('{' + topicID + ':' + messageValue + '}') .message(messageValue)
.topic(topicID) .topic(topicID)
tosca_definitions_version: tosca_simple_profile_for_nfv_1_0_0
policy_types:
eu.ict-flame.policies.StateChange:
derived_from: tosca.policies.Update
eu.ict-flame.policies.Alert:
derived_from: tosca.policies.Root
\ No newline at end of file
tosca_definitions_version: tosca_simple_profile_for_nfv_1_0_0
description: TOSCA Alerts Configuration document
imports:
- flame_clmc_alerts_definitions.yaml
metadata:
sfc: companyA-VR
sfci: companyA-VR-premium
topology_template:
policies:
- high_latency_policy:
type: eu.ict-flame.policies.StateChange
triggers:
high_latency:
description: This event triggers when the mean network latency in a given location exceeds a given threshold (in ms).
event_type: threshold
metric: network.latency
condition:
threshold: 45
granularity: 120
aggregation_method: mean
resource_type:
location: watershed
comparison_operator: gt
action:
implementation:
- http://sfemc.flame.eu/notify
- http://companyA.alert-handler.flame.eu/high-latency
- low_requests_policy:
type: eu.ict-flame.policies.StateChange
triggers:
low_requests:
description: |
This event triggers when the last reported number of requests for a given service function
falls behind a given threshold.
event_type: threshold
metric: storage.requests
condition:
threshold: 5
granularity: 60
aggregation_method: last
resource_type:
sf_package: storage
sf: storage-users
location: watershed
comparison_operator: lt
action:
implementation:
# Fails since policy has no HTTP alert handlers in the implementation.
\ No newline at end of file
tosca_definitions_version: tosca_simple_profile_for_nfv_1_0_0
description: TOSCA Alerts Configuration document
imports:
- flame_clmc_alerts_definitions.yaml
metadata:
sfc_ID: companyA-VR # correct format is sfc, not sfc_ID
sfci_ID: companyA-VR-premium # correct format is sfci, not sfci_ID
topology_template:
policies:
- high_latency_policy:
type: eu.ict-flame.policies.StateChange
triggers:
high_latency:
description: This event triggers when the mean network latency in a given location exceeds a given threshold (in ms).
event_type: threshold
metric: network.latency
condition:
threshold: 45
granularity: 120
aggregation_method: mean
resource_type:
location: watershed
comparison_operator: gt
action:
implementation:
- http://sfemc.flame.eu/notify
- http://companyA.alert-handler.flame.eu/high-latency
- low_requests_policy:
type: eu.ict-flame.policies.StateChange
triggers:
low_requests:
description: |
This event triggers when the last reported number of requests for a given service function
falls behind a given threshold.
event_type: threshold
metric: storage.requests
condition:
threshold: 5
granularity: 60
aggregation_method: last
resource_type:
sf_package: storage
sf: storage-users
location: watershed
comparison_operator: lt
action:
implementation:
- http://sfemc.flame.eu/notify
- http://companyA.alert-handler.flame.eu/low-requests
tosca_definitions_version: tosca_simple_profile_for_nfv_1_0_0
description: TOSCA Alerts Configuration document
imports:
- flame_clmc_alerts_definitions.yaml
metadata:
sfc: companyA-VR
sfci: companyA-VR-premium
topology_template:
policies:
- high_latency_policy:
type: eu.ict-flame.policies.StateChange
triggers:
high_latency:
description: This event triggers when the mean network latency in a given location exceeds a given threshold (in ms).
event_type: threshold
metric: network.latency
condition:
threshold: 45
granularity: 120
aggregation_method: mean
resource_type:
location: watershed
comparison_operator: gt
action:
implementation:
- http://sfemc.flame.eu/notify
- http://companyA.alert-handler.flame.eu/high-latency
- low_requests_policy:
type: eu.ict-flame.policies.StateChange
triggers:
low_requests:
description: |
This event triggers when the last reported number of requests for a given service function
falls behind a given threshold.
event_type: threshold
metric: storage.requests
condition:
threshold: 5
granularity: 60
aggregation_method: last
resource_type:
sf_package: storage
sf: storage-users
location: watershed
comparison_operator: less than # invalid comparison operator
action:
implementation:
- http://companyA.alert-handler.flame.eu/high-latency
\ No newline at end of file
tosca_definitions_version: tosca_simple_profile_for_nfv_1_0_0
description: TOSCA Alerts Configuration document
imports:
- flame_clmc_alerts_definitions.yaml
metadata:
sfc: companyA-VR
sfci: companyA-VR-premium
topology_template:
policies:
- low_requests_policy:
type: eu.ict-flame.policies.StateChange
triggers:
low_requests:
description: |
This event triggers when the last reported number of requests for a given service function
falls behind a given threshold.
event_type: threshold
metric: storage.requests
condition:
threshold: 5
granularity: 60
aggregation_method: last
resource_type:
sf_package_id: storage # sf_package_id is not the correct tag name, it is sf_package
sf: storage-users
location: watershed
comparison_operator: lt
action:
implementation:
- http://companyA.alert-handler.flame.eu/high-latency
\ No newline at end of file
tosca_definitions_version: tosca_simple_profile_for_nfv_1_0_0
description: TOSCA Alerts Configuration document
imports:
- flame_clmc_alerts_definitions.yaml
metadata:
sfc: companyA-VR
sfci: companyA-VR-premium
topology_template:
policies:
- low_requests_policy:
type: eu.ict-flame.policies.StateChange
triggers:
low_requests:
description: |
This event triggers when the last reported number of requests for a given service function
falls behind a given threshold.
event_type: threshold
metric: storage.requests
condition:
threshold: 5
granularity: 60
aggregation_method: average # wrong aggregation method - should be mean, not average
resource_type:
sf_package: storage
sf: storage-users
location: watershed
comparison_operator: lt
action:
implementation:
- http://companyA.alert-handler.flame.eu/high-latency
\ No newline at end of file
tosca_definitions_version: tosca_simple_profile_for_nfv_1_0_0
description: TOSCA Alerts Configuration document
imports:
- flame_clmc_alerts_definitions.yaml
metadata:
sfc: companyA-VR
sfci: companyA-VR-premium
topology_template:
policies:
- low_requests_policy:
type: eu.ict-flame.policies.StateChange
triggers:
low_requests:
description: |
This event triggers when the last reported number of requests for a given service function
falls behind a given threshold.
event_type: threshold
metric: storage.requests
condition:
threshold: 5
granularity: 60
aggregation_method: mean
resource_type:
sf_package: storage
sf: storage-users
location: watershed
comparison_operator: lt
action:
implementation:
- http://companyA.alert-handler.flame.eu/high-latency
- sfemc-webhook # should be a valid URL address
\ No newline at end of file
tosca_definitions_version: tosca_simple_profile_for_nfv_1_0_0
description: TOSCA Alerts Configuration document
imports:
- flame_clmc_alerts_definitions.yaml
metadata:
sfc: companyA-VR
sfci: companyA-VR-premium
topology_template:
policies:
- high_latency_policy:
type: eu.ict-flame.policies.StateChange
triggers:
high_latency:
description: This event triggers when the mean network latency in a given location exceeds a given threshold (in ms).
event_type: threshold
metric: network-latency # should be in format measurement.field - e.g. network.latency
condition:
threshold: 45
granularity: 120
aggregation_method: mean
resource_type:
location: watershed
comparison_operator: gt
action:
implementation:
- http://sfemc.flame.eu/notify
- http://companyA.alert-handler.flame.eu/high-latency
- low_requests_policy:
type: eu.ict-flame.policies.StateChange
triggers:
low_requests:
description: |
This event triggers when the last reported number of requests for a given service function
falls behind a given threshold.
event_type: threshold
metric: storage.requests
condition:
threshold: 5
granularity: 60
aggregation_method: last
resource_type:
sf_package: storage
sf: storage-users
location: watershed
comparison_operator: lt
action:
implementation:
- http://companyA.alert-handler.flame.eu/high-latency
\ No newline at end of file
tosca_definitions_version: tosca_simple_profile_for_nfv_1_0_0
description: TOSCA Alerts Configuration document
imports:
- flame_clmc_alerts_definitions.yaml
metadata:
sfc: companyA-VR
sfci: companyA-VR-premium
topology_template:
policies:
- high_latency_policy:
type: eu.ict-flame.policies.StateChange
triggers:
high_latency:
description: This event triggers when the mean network latency in a given location exceeds a given threshold (in ms).
event_type: threshold-template # should be one of ("threshold", "relative", "deadman")
metric: network.latency
condition:
threshold: 45
granularity: 120
aggregation_method: mean
resource_type:
location: watershed
comparison_operator: gt
action:
implementation:
- http://sfemc.flame.eu/notify
- http://companyA.alert-handler.flame.eu/high-latency
- low_requests_policy:
type: eu.ict-flame.policies.StateChange
triggers:
low_requests:
description: |
This event triggers when the last reported number of requests for a given service function
falls behind a given threshold.
event_type: threshold
metric: storage.requests
condition:
threshold: 5
granularity: 60
aggregation_method: last
resource_type:
sf_package: storage
sf: storage-users
location: watershed
comparison_operator: lt
action:
implementation:
- http://sfemc.flame.eu/notify
- http://companyA.alert-handler.flame.eu/low-requests
tosca_definitions_version: tosca_simple_profile_for_nfv_1_0_0
description: TOSCA Alerts Configuration document
imports:
- flame_clmc_alerts_definitions.yaml
metadata:
sfc: companyA-VR
sfci: companyA-VR-premium
topology_template:
policies:
- high_latency_policy:
type: eu.ict-flame.policies.StateChange
triggers:
# should specify at least 1 trigger
- low_requests_policy:
type: eu.ict-flame.policies.StateChange
triggers:
low_requests:
description: |
This event triggers when the last reported number of requests for a given service function
falls behind a given threshold.
event_type: threshold
metric: storage.requests
condition:
threshold: 5
granularity: 60
aggregation_method: last
resource_type:
sf_package: storage
sf: storage-users
location: watershed
comparison_operator: lt
action:
implementation:
- http://sfemc.flame.eu/notify
- http://companyA.alert-handler.flame.eu/low-requests
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment