从es获取数据最新一次数据
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)
网友评论