elasticsearch 获取最新一次数据(sort by @

2020-07-08  本文已影响0人  tglmm

从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)
上一篇 下一篇

猜你喜欢

热点阅读