elk結合zabbix 日誌告警

pip3 install elasticsearch
# -*- coding: utf-8 -*-
from elasticsearch import Elasticsearch

# 查詢索引中的所有內容
es = Elasticsearch([{'host':'172.16.xx.xx','port':9200}])
index = "logstash-nginx-access-2018.11.20"
query = {"query":{"match_all":{}}}
resp = es.search(index, body=query)
resp_docs = resp["hits"]["hits"]
total = resp['hits']['total']

print(total)     #總共查找到的數量
print(resp_docs[0]['_source']['@timestamp'])   #輸出一個字段
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章