diff --git a/README.md b/README.md index 2aaec47..94c772a 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,10 @@ 另外:Metis开源项目侧重于学件的实现,利用新的方法改进一些基于规则的运维问题。学件聚焦在局部运维的解决,底层海量数据的存储和流式数据处理框架不在开源范围内,此方面的需求可在交流社区内寻找方案支持。 + +/metis/app/model/time_series_detector + + ## 支持平台 目前运行的操作系统平台如下: diff --git a/app/service/time_series_detector/detect_service.py b/app/service/time_series_detector/detect_service.py index c97efe8..016afef 100644 --- a/app/service/time_series_detector/detect_service.py +++ b/app/service/time_series_detector/detect_service.py @@ -8,17 +8,19 @@ https://opensource.org/licenses/BSD-3-Clause Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. """ -import time import os import threading +import time + +from app.common.common import * +from app.common.errorcode import * from app.dao.time_series_detector import anomaly_op from app.dao.time_series_detector import sample_op from app.dao.time_series_detector import train_op -from time_series_detector.algorithm import xgboosting from time_series_detector import detect -from app.common.errorcode import * -from app.common.common import * +from time_series_detector.algorithm import xgboosting from time_series_detector.common.tsd_errorcode import * + MODEL_PATH = os.path.join(os.path.dirname(__file__), './model/') @@ -97,7 +99,7 @@ class DetectService(object): return build_ret_data(LACK_SAMPLE, "") train_op_obj.insert_train_info(train_params) try: - t = threading.Thread(target=self.__generate_model, args=(samples_list, task_id, )) + t = threading.Thread(target=self.__generate_model, args=(samples_list, task_id,)) t.setDaemon(False) t.start() except Exception: @@ -120,7 +122,9 @@ class DetectService(object): return True def __check_param(self, data): - if ("viewName" not in data.keys()) or ("viewId" not in data.keys()) or ("attrId" not in data.keys()) or ("attrName" not in data.keys()) or ("time" not in data.keys()) or ("dataC" not in data.keys()) or ("dataB" not in data.keys()) or ("dataA" not in data.keys()): + if ("viewName" not in data.keys()) or ("viewId" not in data.keys()) or ("attrId" not in data.keys()) or ( + "attrName" not in data.keys()) or ("time" not in data.keys()) or ("dataC" not in data.keys()) or ( + "dataB" not in data.keys()) or ("dataA" not in data.keys()): return CHECK_PARAM_FAILED, "missing parameter" return OP_SUCCESS, "" @@ -140,7 +144,8 @@ class DetectService(object): "data_b": data["dataB"], "data_a": data["dataA"] } - self.anomaly_op_obj.insert_anomaly(anomaly_params) + # always save anomaly data + self.anomaly_op_obj.insert_anomaly(anomaly_params) return build_ret_data(ret_code, ret_data) def rate_predict(self, data):