Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ssis/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Monitoring 如何使用nagios监控elasticsearch_Monitoring_<img Src="//i.stack.imgur.com/RUiNP.png" Height="16" Width="18" Alt="" Class="sponsor Tag Img">elasticsearch_Nagios - Fatal编程技术网 elasticsearch,nagios,Monitoring,elasticsearch,Nagios" /> elasticsearch,nagios,Monitoring,elasticsearch,Nagios" />

Monitoring 如何使用nagios监控elasticsearch

Monitoring 如何使用nagios监控elasticsearch,monitoring,elasticsearch,nagios,Monitoring,elasticsearch,Nagios,我想使用nagios监控elasticsearch。 基本上,我想知道elasticsearch是否已启动 我想我可以使用elasticsearch集群健康API() 使用我返回的“状态”(绿色、黄色或红色),但我仍然不知道如何使用nagios(nagios在一台服务器上,elasticsearc在另一台服务器上) 还有别的办法吗 编辑: 我刚刚发现-。我想我会试试的。过了一会儿-我已经设法使用nrpe监控elasticsearch。 我想使用elasticsearch群集运行状况API,但由于

我想使用nagios监控elasticsearch。 基本上,我想知道elasticsearch是否已启动

我想我可以使用elasticsearch集群健康API()

使用我返回的“状态”(绿色、黄色或红色),但我仍然不知道如何使用nagios(nagios在一台服务器上,elasticsearc在另一台服务器上)

还有别的办法吗

编辑:
我刚刚发现-。我想我会试试的。

过了一会儿-我已经设法使用nrpe监控elasticsearch。 我想使用elasticsearch群集运行状况API,但由于安全问题,我无法从另一台机器上使用它。。。 因此,在监控服务器中,我创建了一个新服务——check_命令是
check_命令check_nrpe!检查弹性体
。现在在elasticsearch所在的远程服务器上,我用以下内容编辑了nrpe.cfg文件:

command[check_elastic]=/usr/local/nagios/libexec/check_http -H localhost -u /_cluster/health -p 9200 -w 2 -c 3 -s green
这是允许的,因为这个命令是从远程服务器运行的-所以这里没有安全问题

它工作!!!
我仍然会尝试我在qeustion中发布的这个check_http_json命令,但现在,我的解决方案已经足够好了。

在讨论了本文中的建议后,我编写了一个简单的脚本。它返回的状态为
OK
WARNING
CRITICAL
,分别对应于集群健康响应中的“status”参数(“绿色”、“黄色”和“红色”)

它还从健康页面获取所有其他参数,并以标准Nagios格式转储它们

享受吧

无耻插头:


您可以将它与ZenOSS/Nagios一起使用来监控集群运行状况、数据索引和单个节点堆的使用情况。

您可以使用这个很酷的Python脚本来监控Elasticsearch集群。此脚本检查IP:端口的Elasticsearch状态。可以找到一个或多个用于监视Elasticsearch的Python脚本。


我在一百万年前写过这篇文章,它可能仍然有用:

但这取决于你想监控什么。上述措施:

  • 如果Elasticsearch响应HTTP
  • 如果摄入率下降到规定水平以下
  • 如果文档总数下降到定义的级别
但当然还有更多有趣的东西。从查询时间到JVM堆使用率。我们在这里写了一篇关于最重要的博客文章:


Elasticsearch为所有这些都提供了API,因此您可以使用通用的API来获取所需的指标。或者,您可能希望使用类似的方法,这样就可以将这些指标开箱即用。(披露:我为Sematext工作)

谢谢你弄明白了这一点!除了跨系统工作以避开安全问题外,它还非常适合在具有不同目录结构的计算机上监视集群。check_http插件位于我们不同服务器上的3个不同目录中。此方法允许我运行检查,但允许本地计算机管理插件路径。再次感谢!我可以用这个检查未分配的\u碎片吗?第23行应该更改为,host=opts.host或'localhost'
#!/usr/bin/python
from nagioscheck import NagiosCheck, UsageError
from nagioscheck import PerformanceMetric, Status
import urllib2
import optparse

try:
    import json
except ImportError:
    import simplejson as json


class ESClusterHealthCheck(NagiosCheck):

    def __init__(self):

        NagiosCheck.__init__(self)

        self.add_option('H', 'host', 'host', 'The cluster to check')
        self.add_option('P', 'port', 'port', 'The ES port - defaults to 9200')

    def check(self, opts, args):
        host = opts.host
        port = int(opts.port or '9200')

        try:
            response = urllib2.urlopen(r'http://%s:%d/_cluster/health'
                                       % (host, port))
        except urllib2.HTTPError, e:
            raise Status('unknown', ("API failure", None,
                         "API failure:\n\n%s" % str(e)))
        except urllib2.URLError, e:
            raise Status('critical', (e.reason))

        response_body = response.read()

        try:
            es_cluster_health = json.loads(response_body)
        except ValueError:
            raise Status('unknown', ("API returned nonsense",))

        cluster_status = es_cluster_health['status'].lower()

        if cluster_status == 'red':
            raise Status("CRITICAL", "Cluster status is currently reporting as "
                         "Red")
        elif cluster_status == 'yellow':
            raise Status("WARNING", "Cluster status is currently reporting as "
                         "Yellow")
        else:
            raise Status("OK",
                         "Cluster status is currently reporting as Green")

if __name__ == "__main__":
    ESClusterHealthCheck().run()