python 监控elasticsearch集群状态并推送到openfalcon
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python 监控elasticsearch集群状态并推送到openfalcon相关的知识,希望对你有一定的参考价值。
#!/usr/bin/python #! --*-- coding:utf-8 --*-- import requests import time import json import sys import commands ts = int(time.time()) #print ts cmd = 'curl 172.31.0.92:9200/_cat/health' (a, b) = commands.getstatusoutput(cmd) #print b status= b.split(' ')[157] if status=='green': healthy=3 elif status=='yellow': healthy=2 elif status=='red': healthy=1 else: healthy=0 #print healthy payload = [ { "endpoint": "TBK01", "metric": "elasticsearch_status", "timestamp": ts, "step": 60, "value": 1, "counterType": "GAUGE", "tags": "status=green", } ] r = requests.post("http://127.0.0.1:1988/v1/push", data=json.dumps(payload)) #print r.text
以上是关于python 监控elasticsearch集群状态并推送到openfalcon的主要内容,如果未能解决你的问题,请参考以下文章
ElasticSearch 集群与x-pack监控集群分开部署
Prometheus监控elasticsearch集群(以elasticsearch-6.4.2版本为例)
prometheus监控之elasticsearch监控(elasticsearch-exporter)