feat:增加批量插入和查询日志告警功能
This commit is contained in:
@@ -1,27 +1,19 @@
|
||||
import requests
|
||||
from requests.auth import HTTPBasicAuth
|
||||
|
||||
from config.setting import settings
|
||||
from schemas.log_alert import OpenobserveQuery
|
||||
|
||||
|
||||
def get_log():
|
||||
url = 'http://192.168.1.7:5080/api/default/_search'
|
||||
username = 'njcxx0822@163.com'
|
||||
password = '19940822Cxx'
|
||||
|
||||
def get_log(start_time: int, end_time: int) -> str:
|
||||
response = requests.post(
|
||||
url,
|
||||
settings.openobserve_url,
|
||||
headers={
|
||||
'accept': 'application/json',
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
json={
|
||||
"query": OpenobserveQuery(
|
||||
start_time=1760773184953420,
|
||||
end_time=1760773189953431
|
||||
).model_dump()
|
||||
},
|
||||
auth=HTTPBasicAuth(username, password)
|
||||
json={"query": OpenobserveQuery(start_time=start_time, end_time=end_time).model_dump()},
|
||||
auth=HTTPBasicAuth(settings.openobserve_username, settings.openobserve_password)
|
||||
)
|
||||
|
||||
print(response)
|
||||
return response.json()
|
||||
|
||||
Reference in New Issue
Block a user