#!/usr/bin/env python
# -*- coding: utf-8 -*-
import logging
import sys
import time
from pprint import pprint
import requests
ES_URL_STAT = 'http://127.0.0.1:9200/_stats'
TIME_DURATION = 60
compare_data = {}
while True:
resp = requests.get(ES_URL_STAT)
resp_data = resp.json()
indices = resp_data['indices']
for index_name, index_data in indices.items():
index_data = index_data['primaries']
compare_data[index_name] = {
'index': index_data['indexing']['index_total'] / ((index_data['indexing']['index_time_in_millis']+1) / 1000),
'search_query': index_data['search']['query_total'] / ((index_data['search']['query_time_in_millis']+1) / 1000),
'search_fetch': index_data['search']['fetch_total'] / ((index_data['search']['fetch_time_in_millis']+1) / 1000),
'refresh': index_data['refresh']['total'] / ((index_data['refresh']['total_time_in_millis']+1) / 1000),
}
print(compare_data)
print()
sys.stdout.flush()
time.sleep(TIME_DURATION)
es stat
- 本文链接: https://github.com/blog/2020/10/20/es_monitor
- 版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 3.0 许可协议。转载请注明出处!