-
Notifications
You must be signed in to change notification settings - Fork 0
/
configuration.py
83 lines (63 loc) · 2.61 KB
/
configuration.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
"""docstring for installed packages."""
import os
import logging
import fourier_model
import prophet_model
import sarima_model
from prometheus_api_client.utils import parse_datetime, parse_timedelta
if os.getenv("FLT_DEBUG_MODE", "False") == "True":
LOGGING_LEVEL = logging.DEBUG
else:
LOGGING_LEVEL = logging.INFO
logging.basicConfig(
format="%(asctime)s:%(levelname)s:%(name)s: %(message)s", level=LOGGING_LEVEL
)
_LOGGER = logging.getLogger(__name__)
class Configuration:
"""docstring for Configuration."""
prometheus_url = os.getenv("PROMETEUS_URL", "http://prometheus-k8s-monitoring.192.168.99.104.nip.io")
prometheus_headers = None
if os.getenv("PROMETEUS_ACCESS_TOKEN"):
prom_connect_headers = {
"Authorization": "bearer " + os.getenv("PROMETEUS_ACCESS_TOKEN")
}
metrics_list = str(
os.getenv(
"METRICS_LIST",
"go_memstats_heap_objects{endpoint='web',instance='172.17.0.17:9090',job='prometheus-k8s',namespace='monitoring',pod='prometheus-k8s-1',service='prometheus-k8s'}",
)
).split(";")
rolling_training_window_size = parse_timedelta(
"now", os.getenv("ROLLING_TRAINING_WINDOW_SIZE", "120m")
)
retraining_interval_minutes = int(
os.getenv("RETRAINING_INTERVAL_MINUTES", "60")
)
metric_chunk_size = parse_timedelta("now", str(retraining_interval_minutes) + "m")
deviations = int(
os.getenv("DEVIATIONS", "3")
)
anomaly_border = str(
os.getenv("ANOMALY_BORDER", "both")
)
algorithm_name = str(
os.getenv("ALGORITHM", "agile")
)
algorithm_resolver = {
"robust": prophet_model.MetricPredictor,
"agile": sarima_model.MetricPredictor,
"basic": fourier_model.MetricPredictor
}
algorithm = algorithm_resolver.get(algorithm_name)
seasonality = str(
os.getenv("SEASONALITY", "daily")
)
mlflow_tracking_uri = "http://localhost:5000"
metric_start_time = parse_datetime(os.getenv("DATA_START_TIME", "2020-02-05 13:00:00"))
metric_end_time = parse_datetime(os.getenv("DATA_END_TIME", "2020-02-05 13:36:00"))
metric_train_data_end_time = metric_start_time + rolling_training_window_size
_LOGGER.info("Metric train data start time: %s", metric_start_time)
_LOGGER.info("Metric train data end time/test data start time: %s", metric_train_data_end_time)
_LOGGER.info("Metric test end time: %s", metric_end_time)
_LOGGER.info("Metric data rolling training window size: %s", rolling_training_window_size)
_LOGGER.info("Model retraining interval: %s minutes", retraining_interval_minutes)