查询到指定 index 日志,符合条件并报警 #!/bin/python3 #Author:cuijianzhe from elasticsearch import Elasticsearch from datetime import datetime, timedelta #paradigm+ import requests import json import sys import os def search(es_object, index_name, search): res = es_object.search(index=index_name, body=search) for hit in res['hits']['hits']: # print(hit) timestamp = hit["_source"]["@timestamp"] local_time = str(datetime.strptime(timestamp, '%Y-%m-%dT%H:%M:%S.%fZ') + timedelta(hours=8)) host = hit["_sourc.... ES相关操作 elasticsearch