從es獲取數(shù)據(jù)最新一次數(shù)據(jù)
import json
import requests
es = "192.168.26.133:9200"
index = "xxx_log_monitor-2020-07-08"
url = "http://{}/{}/_search".format(es,index)
data = {
"query": {
"match_all": {}
},
"size": "1",
"sort": [
{
"@timestamp": {
"order": "desc"
}
}
]
}
headers = {
"Content-Type": "application/json; charset=UTF-8"
}
resp = requests.post(url=url,data=json.dumps(data),headers=headers)
print(resp.text)