diff --git a/docs/AlertsSpecification.md b/docs/AlertsSpecification.md index e4e1cc78d2501ac79baec43bb11594b2eba0a826..a5391d846b1fcd6bf75fabd913cb0e5cfa7192c1 100644 --- a/docs/AlertsSpecification.md +++ b/docs/AlertsSpecification.md @@ -116,8 +116,6 @@ topology_template: threshold: 100 # requests have increased by at least 100 granularity: 120 resource_type: - flame_sfc: companyA-VR - flame_sfci: companyA-VR-premium flame_sfp: storage flame_sf: storage-users flame_server: watershed @@ -239,8 +237,10 @@ the format is still the same for consistency. Therefore, using `<measurement>.*` 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: `"flame_sfc", "flame_sfci", "flame_sfp", "flame_sf", "flame_sfe", "flame_server", "flame_location"`. -Keep in mind that filtering for **sfc** and **sfci** is automatically generated by extracting the metadata values from the alerts specification. +This includes any of the following: `"flame_sfp", "flame_sf", "flame_sfe", "flame_server", "flame_location"`. +Keep in mind that **flame_sfc** and **flame_sfci** are also part of the CLMC Information Model. However, filtering on +these tags is automatically generated and added to all InfluxDB queries by using the metadata values from the +alerts specification. Therefore, including **flame_sfc** and **flame_sfci** in the **resource_type** is considered INVALID. For more information on the global tags, please check the [documentation](monitoring.md). * **comparison_operator** - the logical operator to use for comparison - lt (less than), gt (greater than), lte (less than or equal to), etc. diff --git a/src/service/clmcservice/alertsapi/alerts_specification_schema.py b/src/service/clmcservice/alertsapi/alerts_specification_schema.py index e2365bf21704b2b926ee8049badd956fca6330c2..bc3a985e7130ab713df9789d9d6ac8d57e045e43 100644 --- a/src/service/clmcservice/alertsapi/alerts_specification_schema.py +++ b/src/service/clmcservice/alertsapi/alerts_specification_schema.py @@ -62,7 +62,9 @@ URL_REGEX = re.compile( re.IGNORECASE) # Global tags allowed to be used for filtering in the trigger condition -CLMC_INFORMATION_MODEL_GLOBAL_TAGS = {"flame_sfc", "flame_sfci", "flame_sfp", "flame_sf", "flame_sfe", "flame_server", "flame_location"} +CLMC_INFORMATION_MODEL_GLOBAL_TAGS = {"flame_sfp", "flame_sf", "flame_sfe", "flame_server", "flame_location"} +# NOTICE that "flame_sfc", "flame_sfci" are not allowed, eventhough they are part of the CLMC Information Model +# This is because those two tags are automatically added to the InfluxDB queries - the required values are retrieved from the alert spec. metadata ALERTS_SPECIFICATION_SCHEMA = Schema({ "tosca_definitions_version": And(str, lambda v: v == "tosca_simple_profile_for_nfv_1_0_0"), diff --git a/src/service/clmcservice/alertsapi/views.py b/src/service/clmcservice/alertsapi/views.py index 74ce6e928c2495243c64dec30906d4f942755fb7..ba07e26911289976f0faa5bb655339350c300bbc 100644 --- a/src/service/clmcservice/alertsapi/views.py +++ b/src/service/clmcservice/alertsapi/views.py @@ -225,7 +225,7 @@ 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 + # make sure alert tasks are executing with queries for the given sfc and sfc instance - automatically add those tags using the metadata values tags["flame_sfc"] = sfc tags["flame_sfci"] = sfc_instance diff --git a/src/service/resources/tosca/test-data/clmc-validator/invalid/alerts_test_config-11.yaml b/src/service/resources/tosca/test-data/clmc-validator/invalid/alerts_test_config-11.yaml new file mode 100644 index 0000000000000000000000000000000000000000..44837acabde8a7c6f5eef382c0c2a96037b1649f --- /dev/null +++ b/src/service/resources/tosca/test-data/clmc-validator/invalid/alerts_test_config-11.yaml @@ -0,0 +1,75 @@ +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: + flame_sfc: companyA-VR # not allowed - sfc tag is automatically added in the filters + flame_location: watershed + comparison_operator: gt + action: + implementation: + - http://sfemc.flame.eu/notify + - http://companyA.alert-handler.flame.eu/high-latency + - requests_diff_policy: + type: eu.ict-flame.policies.StateChange + triggers: + decrease_in_requests: + description: | + This event triggers when the number of requests has decreased relative to the number of requests received + 120 seconds ago. + event_type: relative + metric: storage.requests + condition: + threshold: -100 # requests have decreased by at least 100 + granularity: 120 + resource_type: + flame_sfp: storage + flame_sf: storage-users + flame_location: watershed + comparison_operator: lte + action: + implementation: + - http://sfemc.flame.eu/notify + - 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: + flame_sfp: storage + flame_sf: storage-users + flame_location: watershed + comparison_operator: lt + action: + implementation: + - http://sfemc.flame.eu/notify + - http://companyA.alert-handler.flame.eu/low-requests diff --git a/src/service/resources/tosca/test-data/clmc-validator/invalid/alerts_test_config-12.yaml b/src/service/resources/tosca/test-data/clmc-validator/invalid/alerts_test_config-12.yaml new file mode 100644 index 0000000000000000000000000000000000000000..42d33a8b6fdc6c69b1bae50e02e70496ff9154a4 --- /dev/null +++ b/src/service/resources/tosca/test-data/clmc-validator/invalid/alerts_test_config-12.yaml @@ -0,0 +1,75 @@ +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: + flame_sfci: companyA-VR-premium # not allowed - sfci tag is automatically added in the filters + flame_location: watershed + comparison_operator: gt + action: + implementation: + - http://sfemc.flame.eu/notify + - http://companyA.alert-handler.flame.eu/high-latency + - requests_diff_policy: + type: eu.ict-flame.policies.StateChange + triggers: + decrease_in_requests: + description: | + This event triggers when the number of requests has decreased relative to the number of requests received + 120 seconds ago. + event_type: relative + metric: storage.requests + condition: + threshold: -100 # requests have decreased by at least 100 + granularity: 120 + resource_type: + flame_sfp: storage + flame_sf: storage-users + flame_location: watershed + comparison_operator: lte + action: + implementation: + - http://sfemc.flame.eu/notify + - 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: + flame_sfp: storage + flame_sf: storage-users + flame_location: watershed + comparison_operator: lt + action: + implementation: + - http://sfemc.flame.eu/notify + - http://companyA.alert-handler.flame.eu/low-requests diff --git a/src/service/resources/tosca/test-data/clmc-validator/valid/alerts_test_config-2.yaml b/src/service/resources/tosca/test-data/clmc-validator/valid/alerts_test_config-2.yaml index 5169f5d4d205f3f9121c5c390a2596235e05de49..80ae206971d839272e4be8aff891e3a270caaf99 100644 --- a/src/service/resources/tosca/test-data/clmc-validator/valid/alerts_test_config-2.yaml +++ b/src/service/resources/tosca/test-data/clmc-validator/valid/alerts_test_config-2.yaml @@ -25,8 +25,6 @@ topology_template: threshold: -100 # requests have decreased by at least 100 granularity: 120 resource_type: - flame_sfc: companyA-VR # sfc tag is also allowed, even though it is already included in the metadata - flame_sfci: companyA-VR-premium # sfci tag is also allowed, even though it is already included in the metadata flame_sfp: storage flame_sf: storage-users flame_location: watershed diff --git a/src/test/clmctest/alerts/alerts_test_config.yaml b/src/test/clmctest/alerts/alerts_test_config.yaml index fe293a0308352acb4f694e208708db7c1d3d06fa..f2fb3baa511fbcd7df520bb229bb900a7d76d0ee 100644 --- a/src/test/clmctest/alerts/alerts_test_config.yaml +++ b/src/test/clmctest/alerts/alerts_test_config.yaml @@ -54,8 +54,6 @@ topology_template: threshold: 1 granularity: 10 resource_type: - flame_sfc: MS_Template_1 # value is already given in metadata so this is optional - flame_sfci: MS_I1 # value is already given in metadata so this is optional flame_sfp: nginx flame_sf: adaptive_streaming_nginx_I1 flame_location: DC1 @@ -76,8 +74,6 @@ topology_template: threshold: 0 granularity: 5 resource_type: - flame_sfc: MS_Template_1 # value is already given in metadata so this is optional - flame_sfci: MS_I1 # value is already given in metadata so this is optional flame_sfp: nginx flame_sf: adaptive_streaming_nginx_I1 flame_location: DC1