diff --git a/src/test/clmctest/alerts/alert_example.tick b/src/test/clmctest/alerts/alert_example.tick index bf45d3d8040e34238e13b8134f7828c58fde106b..b218eae128969294deb6d88a7bbc28be564faf21 100644 --- a/src/test/clmctest/alerts/alert_example.tick +++ b/src/test/clmctest/alerts/alert_example.tick @@ -9,5 +9,5 @@ batch .every(10s) |alert() .crit(lambda: "mean" > 1) - .message('TRUE') + .message('{"http_topic": "true"}') .topic('http_topic') \ No newline at end of file diff --git a/src/test/clmctest/alerts/configuration.json b/src/test/clmctest/alerts/configuration.json new file mode 100644 index 0000000000000000000000000000000000000000..d889e4eae900ea77740aa59a803a45ce8ab0a9bb --- /dev/null +++ b/src/test/clmctest/alerts/configuration.json @@ -0,0 +1,43 @@ +[ + { + "type": "threshold", + "comparison": "greater_than", + "db": "database", + "rp": "retention_policy", + "measurement": "measurement_name", + "field": "field_name", + "period": "50", (read this from TOSCA or default value) + "context": { + "sfc": "sfc_id", + "sfc_instance": "sfc_i_id", + "sf": "sf_node_name", + "sf_endpoint": "sf_endpoint_id" + }, + "threshold_value": <number>, + "event_name": "pub_sub_topic_id", + "http_handlers": [ + "http://handler1.com", + "http://handler2.com" + ] ??? + }, + { + "type": "threshold", + "comparison": "greater_than", + "db": "database", + "rp": "retention_policy", + "measurement": "measurement_name", + "field": "field_name", + "context": { + "sfc": "sfc_id", + "sfc_instance": "sfc_i_id", + "sf": "sf_node_name", + "sf_endpoint": "sf_endpoint_id" + }, + "threshold_value": <number>, + "event_name": "pub_sub_topic_id", + "http_handlers": [ + "http://handler1.com", + "http://handler2.com" + ] + } +] \ No newline at end of file diff --git a/src/test/clmctest/alerts/http_server.py b/src/test/clmctest/alerts/http_server.py index 80fed529b528df53c114cfad655b7b9f916d36c8..6a478ded0939f95e09eb6c38c57f54dd66f8a888 100644 --- a/src/test/clmctest/alerts/http_server.py +++ b/src/test/clmctest/alerts/http_server.py @@ -19,6 +19,7 @@ class CustomHTTPHandler(BaseHTTPRequestHandler): def do_POST(self): content_length = int(self.headers['Content-Length']) post_data = self.rfile.read(content_length) + post_data = post_data.decode(self.headers['Accept-Charset']) logger.debug(post_data) def do_GET(self): diff --git a/src/test/clmctest/alerts/threshold_configuration.json b/src/test/clmctest/alerts/threshold_configuration.json new file mode 100644 index 0000000000000000000000000000000000000000..dc20c7979c606ef8d411d53b4fb9ae54aaf43daf --- /dev/null +++ b/src/test/clmctest/alerts/threshold_configuration.json @@ -0,0 +1,8 @@ +{ + "db": {"type": "string", "value": "_internal"}, + "rp": {"type": "string", "value": "monitor"}, + "measurement": {"type": "string", "value": "database"}, + "field": {"type": "string", "value": "numMeasurements"}, + "criticalValue": {"type": "float", "value": 2.0}, + "topicID": {"type": "string", "value": "dummyAlert"} +} \ No newline at end of file diff --git a/src/test/clmctest/alerts/threshold_template.tick b/src/test/clmctest/alerts/threshold_template.tick new file mode 100644 index 0000000000000000000000000000000000000000..5c5658be6d922e0b2e086c01a509787bfff6e4b8 --- /dev/null +++ b/src/test/clmctest/alerts/threshold_template.tick @@ -0,0 +1,26 @@ +var db string + +var rp = 'autogen' // default value for the retention policy + +var measurement string + +var field string + +var whereCondition = '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 criticalValue float + +var alertPeriod = 60s // this value is read from TOSCA and is measured in seconds, default value is 60 seconds + +var topicID string + +batch + |query('SELECT mean(' + field + ') AS mean_value FROM "' + db + '"."' + rp + '"."' + measurement + '" WHERE ' + whereCondition) + .period(alertPeriod) + .every(alertPeriod) + |alert() + .crit(lambda: "mean_value" >= criticalValue) + .message('{' + topicID + ':' + messageValue + '}') + .topic(topicID)