diff --git a/Flask-Login b/Flask-Login new file mode 100644 index 0000000000000000000000000000000000000000..3236403e2bd8c1b6dc807d3d06c83a487ce288bc --- /dev/null +++ b/Flask-Login @@ -0,0 +1,11 @@ +from flask_login import UserMixin, LoginManager +from werkzeug.security import generate_password_hash, check_password_hash + +class User(UserMixin): + def __init__(self, id, username, password): + self.id = id + self.username = username + self.password_hash = generate_password_hash(password) + + def check_password(self, password): + return check_password_hash(self.password_hash, password) diff --git a/Scikit-learn b/Scikit-learn new file mode 100644 index 0000000000000000000000000000000000000000..e5c72383e30c85160c58bde6d289ab992acda9dc --- /dev/null +++ b/Scikit-learn @@ -0,0 +1,10 @@ +from sklearn.ensemble import IsolationForest +import pandas as pd + +def anomaly_detection(data): + model = IsolationForest(contamination=0.01) + data = pd.DataFrame(data) # 假设数据为字典列表格式 + model.fit(data) + predictions = model.predict(data) + anomalies = data[predictions == -1] + return anomalies diff --git a/elk b/elk new file mode 100644 index 0000000000000000000000000000000000000000..1b80f26d54a5750ac03b4653320f83b89cb3d998 --- /dev/null +++ b/elk @@ -0,0 +1,6 @@ +from elasticsearch import Elasticsearch + +def fetch_elk_logs(index_name, query_body): + es = Elasticsearch(['http://localhost:9200']) + response = es.search(index=index_name, body=query_body) + return response['hits']['hits'] diff --git a/sls b/sls new file mode 100644 index 0000000000000000000000000000000000000000..ead9a7ca6176fcc99f877848c3f1ae5541ebae0e --- /dev/null +++ b/sls @@ -0,0 +1,13 @@ +from aliyunsdkcore.client import AcsClient +from aliyunsdklog.request.v20200619 import GetLogsRequest + +def fetch_sls_logs(project_name, logstore_name, from_time, to_time): + client = AcsClient('', '', 'cn-hangzhou') + request = GetLogsRequest.GetLogsRequest() + request.set_ProjectName(project_name) + request.set_LogstoreName(logstore_name) + request.set_FromTime(from_time) + request.set_ToTime(to_time) + + response = client.do_action_with_exception(request) + return response