提交 7daac06c 编写于 作者: U u010395817

Fri Mar 14 18:09:00 CST 2025 inscode

上级 0a575cc3
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)
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
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']
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('<your-access-key-id>', '<your-access-key-secret>', '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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册