Commit 2666bd1f authored by Jean-Didier's avatar Jean-Didier
Browse files

performance model hackathon

parent aa00dbe8
......@@ -23,12 +23,12 @@ stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
[program:rpc_server]
command=/app/start_rpc.sh
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
#[program:rpc_server]
#command=/app/start_rpc.sh
#stdout_logfile=/dev/stdout
#stdout_logfile_maxbytes=0
#stderr_logfile=/dev/stderr
#stderr_logfile_maxbytes=0
[program:db_checker]
command=/app/start_dbchecker.sh
......@@ -43,3 +43,10 @@ stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
[program:activemq_listener]
command=/app/start_activemq_listener.sh
stdout_logfile=/dev/stdout
stdout_logfile_maxbytes=0
stderr_logfile=/dev/stderr
stderr_logfile_maxbytes=0
......@@ -17,6 +17,7 @@ features_4 = ["EstimatedRemainingTimeContext","SimulationLeftNumber","Simulation
#post_data = {'url_file': url_file, 'application': 'application-1','target':'performance','features': features}
#post_data_2 = {'url_file': "", 'application': 'demo','target':'response_time','features': features_2, "variant": "vm"}
#post_data_3 = {'url_file': url_file_3, 'application': 'application-3','target':'performance','features': features_3}
# "default_application"
post_data_4 = {'url_file': url_file_4, 'application': 'genome','target':'EstimatedRemainingTimeContext','features': features_4,'variant':'vm'}
#print("Get model")
#response = requests.post(url+"/api/v1/model", data='{"application":"application-2"}', headers={'Content-Type':'application/json'})
......@@ -34,4 +35,29 @@ print(response)
#features = {'cpu_usage': 31, "memory": 4500.23, 'latency': 2.1, 'level': 1}
#post_data = {'application': 'fcr','target':'response_time','features':features}
#response = requests.post(url+"/api/v1/model/predict", data=json.dumps(post_data),headers={'Content-Type':'application/json'}).text
#print(response)
\ No newline at end of file
#print(response)
# utility : input (configs) - Mem , Cpu, Number vm provided to an application
# utility : metrics (formula) - datasets
# ??
# utility : output (utility value)
"""
Training
topic : performance_module_train
data: [
{'application': 'genome','target':'EstimatedRemainingTimeContext','features': features_4,'variant':'vm', 'sender_id':'solver_id'},
{'application': 'genome','target':'SimulationLeftNumber','features': features_4,'variant':'vm'},
]
Predict
topic : performance_module_predict
data : {'application': 'fcr','target':'response_time','features':features, 'variant': 'vm', 'sender_id':'solver_id'}
Prediction response
topic : performance_module_predict_feedback
data : {'application': 'app_name', 'target': 'targeted_field', 'variant': 'vm', 'value':'value_predicted (float)', 'sender_id': 'solver-id'}
Feedback
topic : performance_module_train_feedback
data : {'application': 'application_name', 'target': 'SimulationLeftNumber', 'variant': 'vm', 'sender_id':'solver_id'}
"""
\ No newline at end of file
class Metric(enumerate):
"""
[0] (current/detected) Metrics & SLOs Events Format:
This event is aggregated by EMS and it is persisted in InfluxDB. Moreover,
Prediction Orchestrator will subscribe and receive the current metrics in order to
evaluate the forecasting methods, according to the defined KPIs (e.g., MAPE)
* Topic: [metric_name]
> (e.g. MaxCPULoad)
{
"metricValue": 12.34,
"level": 1,
"timestamp": 143532341251,
"refersTo": "MySQL_12345",
"cloud": "AWS-Dublin",
"provider": "AWS"
}
https://confluence.7bulls.eu/display/MOR/Forecasting+Mechanism+Sub-components+Communication
"""
TIMESTAMP = "timestamp"
METRIC_VALUE = "metricValue"
REFERS_TO = "refersTo"
CLOUD = "cloud"
PROVIDER = "provider"
class PredictionMetric(enumerate):
"""
[1] Predicted Metrics & SLOs Events Format
This event is produced by the Prediction Orchestrator and reflects the final predicted value for a metric.
- Topic: prediction.[metric_name]
> (e.g. prediction.MaxCPULoad)
{
"metricValue": 12.34,
"level": 1,
"timestamp": 143532341251,
"probability": 0.98,
"confidence_interval " : [8,15]
"predictionTime": 143532342,
"refersTo": "MySQL_12345",
"cloud": "AWS-Dublin",
"provider": "AWS"
}
https://confluence.7bulls.eu/display/MOR/Forecasting+Mechanism+Sub-components+Communication
"""
_match = "prediction."
METRICVALUE= "metricValue"
'''Predicted metric value'''
LEVEL= "level"
'''Level of VM where prediction occurred or refers'''
TIMESTAMP= "timestamp"
'''Prediction creation date/time from epoch'''
PROBABILITY= "probability"
'''Probability of the predicted metric value (range 0..1)'''
CONFIDENCE_INTERVAL= "confidence_interval"
'''the probability-confidence interval for the prediction'''
PREDICTION_TIME= "predictionTime"
'''This refers to time point in the imminent future (that is relative to the time
that is needed for reconfiguration) for which the predicted value is considered
valid/accurate (in UNIX Epoch)'''
REFERSTO= "refersTo"
'''The id of the application or component or (VM) host for which the prediction refers to'''
CLOUD= "cloud"
'''Cloud provider of the VM (with location)'''
PROVIDER= "provider"
'''Cloud provider name'''
class MetricsToPredict(enumerate):
"""
[2] Translator – to – Forecasting Methods/Prediction Orchestrator Events Format
This event is produced by the translator, to:
imform Dataset Maker which metrics should subscribe to in order to aggregate the appropriate tanning dataset in the time-series DB.
instruct each of the Forecasting methods to predict the values of one or more monitoring metrics
inform the Prediction Orchestrator for the metrics which will be forecasted
* Topic: metrics_to_predict
*Note:* This event could be communicated through Mule
[
{
"metric": "MaxCPULoad",
"level": 3,
"publish_rate": 60000,
},
{
"metric": "MinCPULoad",
"level": 3,
"publish_rate": 50000,
}
]
https://confluence.7bulls.eu/display/MOR/Forecasting+Mechanism+Sub-components+Communication
"""
_match = "metrics_to_predict"
METRIC = "metric"
'''name of the metric to predict'''
LEVEL = "level"
'''Level of monitoring topology where this metric may be produced/found'''
PUBLISH_RATE = "publish_rate"
'''expected rate for datapoints regarding the specific metric (according to CAMEL)'''
class TraningModels(enumerate):
"""
[3] Forecasting Methods – to – Prediction Orchestrator Events Format
This event is produced by each of the Forecasting methods, to inform the
Prediction Orchestrator that the method has (re-)trained its model for one or more metrics.
* Topic: training_models
{
"metrics": ["MaxCPULoad","MinCPULoad"]",
"forecasting_method": "ESHybrid",
"timestamp": 143532341251,
}
https://confluence.7bulls.eu/display/MOR/Forecasting+Mechanism+Sub-components+Communication
"""
_match = "training_models"
METRICS = "metrics"
'''metrics for which a certain forecasting method has successfully trained or re-trained its model'''
FORECASTING_METHOD = "forecasting_method"
'''the method that is currently re-training its models'''
TIMESTAMP = "timestamp"
'''date/time of model(s) (re-)training'''
class IntermediatePrediction(enumerate):
"""
[4] Forecasting Methods – to – Prediction Orchestrator Events Format
This event is produced by each of the Forecasting methods, and is used by the Prediction Orchestrator to determine the final prediction value for the particular metric.
* Topic: intermediate_prediction.[forecasting_method].[metric_name]
* (e.g. intermediate_prediction.ESHybrid.MaxCPULoad)
* We note that any component will be able to subscribe to topics like:
* intermediate_prediction.*.MaxCPULoad → gets MaxCPULoad predictions produced by all forecasting methods or
* intermediate_prediction.ESHybrid.* → gets all metrics predictions from ESHybrid method
* We consider that each forecasting method publishes a static (but configurable) number m of predicted values (under the same timestamp) for time points into the future. These time points into the future are relevant to the reconfiguration time that it is needed (and can also be updated).
* For example if we configure m=5 predictions into the future and the reconfiguration time needed is TR=10 minutes, then at t0 a forecasting method publishes 5 events with the same timestamp and prediction times t0+10, t0+20, t0+30, t0+40, t0+50.
{
"metricValue": 12.34,
"level": 3,
"timestamp": 143532341251,
"probability": 0.98,
"confidence_interval " : [8,15]
"predictionTime": 143532342,
"refersTo": "MySQL_12345",
"cloud": "AWS-Dublin",
"provider": "AWS"
}
https://confluence.7bulls.eu/display/MOR/Forecasting+Mechanism+Sub-components+Communication
"""
_match="intermediate_prediction."
METRICVALUE = "metricValue"
'''Predicted metric value (more than one such events will be produced for different time points into the future – this can be valuable to the Prediction Orchestrator in certain situations e.g., forecasting method is unreachable for a time period)'''
LEVEL = "level"
'''Level of VM where prediction occurred or refers'''
TIMESTAMP = "timestamp"
'''Prediction creation date/time from epoch'''
PROBABILITY = "probability"
'''Probability of the predicted metric value (range 0..1)'''
CONFIDENCE_INTERVAL = "confidence_interval"
'''the probability-confidence interval for the prediction'''
PREDICTION_TIME = "predictionTime"
'''This refers to time point in the imminent future (that is relative to the time that is needed for reconfiguration) for which the predicted value is considered valid/accurate (in UNIX Epoch)'''
REFERS_TO = "refersTo"
'''The id of the application or component or (VM) host for which the prediction refers to'''
CLOUD = "cloud"
'''Cloud provider of the VM (with location)'''
PROVIDER = "provider"
'''Cloud provider name'''
class Prediction(enumerate):
"""
[5] Prediction Orchestrator – to – Severity-based SLO Violation Detector Events Format
This event is used by the Prediction Orchestrator to inform the SLO Violation Detector about the current values of a metric, which can possibly lead to an SLO Violation detection.
* Topic: prediction.[metric_name]
* (e.g. prediction.MaxCPULoad)
{
"metricValue": 12.34,
"level": 1,
"timestamp": 143532341251,
"probability": 0.98,
"confidence_interval " : [8,15]
"predictionTime": 143532342,
"refersTo": "MySQL_12345",
"cloud": "AWS-Dublin",
"provider": "AWS"
}
https://confluence.7bulls.eu/display/MOR/Forecasting+Mechanism+Sub-components+Communication
"""
_match = "prediction."
METRICVALUE = "metricValue"
'''Predicted metric value'''
LEVEL = "level"
'''Level of VM where prediction occurred or refers'''
TIMESTAMP = "timestamp"
'''Prediction creation date/time from epoch'''
PROBABILITY = "probability"
'''Probability of the predicted metric value (range 0..1)'''
CONFIDENCE_INTERVAL = "confidence_interval"
'''the probability-confidence interval for the prediction'''
PREDICTIONTIME = "predictionTime"
'''This refers to time point in the imminent future (that is relative to the time that is needed for reconfiguration) for which the predicted value is considered valid/accurate (in UNIX Epoch)'''
REFERSTO = "refersTo"
'''The id of the application or component or (VM) host for which the prediction refers to'''
CLOUD = "cloud"
'''Cloud provider of the VM (with location)'''
PROVIDER = "provider"
'''Cloud provider name'''
class StopForecasting(enumerate):
"""
[6] Prediction Orchestrator – to – Forecasting Methods Events Format
This event is used by the Prediction Orchestrator to instruct a forecasting method to stop producing predicted values for a selection of metrics.
* Topic: stop_forecasting.[forecasting_method]
* Each component that implements a specific forecasting method it should subscribe to its relevant topic (e.g. the ES-Hybrid component should subscribe to stop_forecasting.eshybrid topic)
{
"metrics": ["MaxCPULoad","MinCPULoad"],
"timestamp": 143532341251,
}
https://confluence.7bulls.eu/display/MOR/Forecasting+Mechanism+Sub-components+Communication
"""
_match="stop_forecasting."
METRICS = "metrics"
'''metrics for which a certain method should stop producing predictions (because of poor results)'''
TIMESTAMP = "timestamp"
'''date/time of the command of the orchestrator'''
class StartForecasting(enumerate):
"""
[7] Prediction Orchestrator – to – Forecasting Methods Events Format
This event is used by the Prediction Orchestrator to instruct a forecasting method to start producing predicted values for a selection of metrics.
* Topic: start_forecasting.[forecasting_method]
* Each component that implements a specific forecasting method it should subscribe to its relevant topic (e.g. the ES-Hybrid component should subscribe to start_forecasting.eshybrid topic)
* We consider that each forecasting method should publish a static (but configurable) number m of predicted values (under the same timestamp) for time points into the future. These time points into the future are relevant to the reconfiguration time that it is needed (and can also be updated).
* For example if we configure m=5 predictions into the future and the reconfiguration time needed is TR=10 minutes, then at t0 a forecasting method publishes 5 events with the same timestamp and prediction times t0+10, t0+20, t0+30, t0+40, t0+50.
{
"metrics": ["MaxCPULoad","MinCPULoad"],
"timestamp": 143532341251,
"epoch_start": 143532341252,
"number_of_forward_predictions": 5,
"prediction_horizon": 600
}
https://confluence.7bulls.eu/display/MOR/Forecasting+Mechanism+Sub-components+Communication
"""
_match="start_forecasting."
METRICS = "metrics"
'''metrics for which a certain method should start producing predictions'''
TIMESTAMP = "timestamp"
'''date/time of the command of the orchestrator'''
EPOCH_START = "epoch_start"
'''this time refers to the start time after which all predictions will be considered (i.e. t0)'''
NUMBER_OF_FORWARD_PREDICTIONS = "number_of_forward_predictions"
''' this is a number that indicates how many time points into the future do we need predictions for.'''
PREDICTION_HORIZON = "prediction_horizon"
'''This time equals to the time (in seconds) that is needed for the platform to implement an application reconfiguration (i.e. TR).'''
\ No newline at end of file
import stomp
import logging
import json
from stomp.listener import PrintingListener
class Connection:
subscriptions = []
def __init__(self, username, password,
host='localhost',
port=61613,
debug=False):
self.username = username
self.password = password
self.hosts = [(host, port)]
self.conn = stomp.Connection(host_and_ports=self.hosts, auto_content_length=False)
if debug:
logging.debug("Enabling debug")
self.conn.set_listener('print', PrintingListener())
def _build_id(self,topic,id):
return "id.%s-%s" % (topic,id)
def set_listener(self, id, listener):
if self.conn:
self.conn.set_listener(id,listener)
def subscribe(self,destination, id, ack='auto'):
if not self.conn:
raise RuntimeError('You need to connect first')
self.conn.subscribe(destination, id, ack)
def topic(self,destination, id, ack='auto'):
self.subscribe("/topic/%s" % destination ,self._build_id(destination,id),ack)
def queue(self,destination, id, ack='auto'):
self.subscribe("/queue/%s" % destination ,self._build_id(destination,id),ack)
def unsubscribe(self, topic,id):
if not self.conn:
return
self.conn.unsubscribe(self._build_id(topic,id))
def connect(self, wait=True):
if not self.conn:
return
self.conn.connect(self.username, self.password, wait=wait)
def disconnect(self):
self.conn.disconnect()
def send_to_topic(self,destination, body, content_type, headers={}, **kwargs):
if not self.conn:
logging.error("Connect first")
return
str = json.dumps(body)
self.conn.send(destination="/topic/%s" % destination,
body= str,
content_type=content_type,
headers=headers, **kwargs)
from json import JSONDecodeError
from stomp.listener import ConnectionListener
import logging
import json
from slugify import slugify
class MorphemicListener(ConnectionListener):
def is_topic(self,headers, event):
if not hasattr(event,"_match"):
return False
match = getattr(event,'_match')
return headers.get('destination').startswith(match)
def has_topic_name(self,headers, string):
return headers.get('destination').startswith(string)
def get_topic_name(self,headers):
return headers.get('destination').replace('/topic/','')
def has_topic_name(self,headers, string):
return headers.get('destination').startswith(string)
def get_topic_name(self,headers):
return headers.get('destination').replace('/topic/','')
def on(self,headers, res):
logging.debug("Unknown message %s %s ",headers, res)
pass