01. elastcsearch-monitor (es 监控)


这里主要是学习一下es的monitor机制
首先是整个链路的数据都要监控的包括filebeat,logstash,kibana,es,都可以收集到es集群中去。
借用es官方的一个图
在这里插入图片描述

1.数据的搜集目的地维度可以有两个

  1. 监控数据放到原来的集群,和存放业务数据的集群是同一个集群
  2. 监控数据放到新的集群,监控数据单独存放

2. 监控在一个集群内的配置也可以有多个维度

  1. 有些配置是针对整个集群的配置
  2. 有些配置只是针对es 或者kibana,或者logstash,或者kibana

3. 监控的实现方式也有多种

  1. 使用export
  2. 使用metricbeat

4. kibana配置监控

因为kibana是用来显示所有的监控数据的,他的监控数据也可以分发到任意的其他集群。
kibana是使用node-server将数据发送到了对应的es当中,不像es,logstash可以使用exporter,metricbeat多种收集方式,

4.1 监控相关的通用配置

xpack.monitoring.enabled: true  打开监控的features,如果设置为false,负责监控的进程的进程就不会启动,
包括产生kibana的监控数据,包括去es中拉取对应的其他的比如es,logstash,filebeat等的监控数据。

下面3个配置的是kibana监控数据将发到那个es集群
xpack.monitoring.elasticsearch.hosts
xpack.monitoring.elasticsearch.username
xpack.monitoring.elasticsearch.password

4.2 kibana的monitor-data相关

1. xpack.monitoring.kibana.collection.enabled: true 这个是设置收集kibana monitor data数据到es当中
2. xpack.monitoring.kibana.collection.interval: 监控数据收集的间隔ms

4.3 极简集群搭建

es的配置为

cluster.name: dev-log
node.name: ES01
bootstrap.system_call_filter: false
network.host: 10.76.0.98
http.port: 12200
transport.port: 12300
discovery.seed_hosts: ["10.76.0.98:12300","10.76.3.145:12300","10.76.0.129:12300"]
cluster.initial_master_nodes: ["ES01", "ES02","ES03"]

此时的kibana配置

server.name: ch-dev
server.port: 45601
server.host: 10.76.0.129
elasticsearch.hosts: ["http://10.76.0.98:12200"]

此时可以看到没有任何关于监控的显式设置,监控相关都是使用的默认设置
启动es之后,直接打开kibna,如果打开监控对应的菜单,显示

We checked the cluster defaults settings and found
that xpack.monitoring.collection.enabled is set to false
Would you like to turn it on?

说明默认情况下数据并不能成功的收集到集群当中去。还是需要开启的。

4.4 开启集群监控功能

  通过上面的配置不能进行监控,并不是kibana的设置有问题,而是整个集群的监控功能没有开启,xpack.monitoring.collection.enabled 配置就是针对整个集群的配置,这个配置针对的是es,告诉es是否收集自己的monitor-data,是否接收由kibana,logstash,filebeat等发送过来的监控数据。这个可以直接通过api在集群中进行动态的设置。也可以在每个es节点中进行设置。

4.4.1 通过es开启集群监控

如果在每个es节点中都设置

xpack.monitoring.collection.enabled: true

重启整个集群,kibana就不会有这个提示了,而且可以直接显示出来监控面板
同时还有kibana的监控菜单里面也有kibana的monitor-data

4.4.2 通过kibana开启集群监控

在kibana的提示下开启监控:
这个时候是使用集群的_cluster/setting api进行设置的
点击完kibana的确认按钮之后可以查询接口查询到cluster已经有了这样的设置。

GET _cluster/settings  只能显示动态配置的东西

{
  "persistent" : {
    "xpack" : {
      "monitoring" : {
        "collection" : {
          "enabled" : "true"
        }
      }
    }
  },
  "transient" : { }
}

4.5 kibana monitor-data的设置

如果将

xpack.monitoring.kibana.collection.enabled: false

添加到kibana的配置当中,那么kibana的数据就从监控面板中消失了,但是es的数据还是有的

如果再添加一个设置

xpack.monitoring.enabled: false

kibana服务还可以访问,但是监控的菜单直接消失了,就是所有的监控相关的功能都不再提供了,不会去es中拉取相关的数据了。
所以xpack.monitoring.enabled 控制的是kibana中提供监控展示等服务模块是否还工作。

4.6 简单回顾

在进一步学习之前,通过对kibana的监控配置简单做一个回顾
集群做了很多的默认配置,使监控变得更加简单,但是默认情况下是无法进行监控的,需要通过

xpack.monitoring.collection.enabled: true

来开启集群的设置,然后kibana通过开启

xpack.monitoring.enabled: true  打开监控的features,如果设置为false,负责监控的进程的进程就不会启动,包括产生kibana的监控数据,包括去es中拉取对应的其他的比如es,logstash,filebeat等的监控数据。

xpack.monitoring.elasticsearch.hosts  默认使用kibana连接的集群,可以单独配置
xpack.monitoring.elasticsearch.username  在集群开启security配置的时候才需要这个
xpack.monitoring.elasticsearch.password  同上
xpack.monitoring.kibana.collection.enabled: true 这个是设置收集kibana monitor-data数据到es当中,
xpack.monitoring.kibana.collection.interval: 10000  (10s)

5. logstash monitor-data设置

logstash相对于es和kibana需要设置的东西更少,因为在整个监控链路中,es不仅作为被监控对象,同时作为监控数据的存储库,kibana不仅作为被监控对象,而且是监控数据的展示终端,需要有专门的进程去对监控数据做聚合等查询,而logstash则仅仅是作为被监控对象存在。

5.1 监控相关的配置

  1. 首先要要保证集群的监控功能开启了,即
xpack.monitoring.collection.enabled: true

在es节点或者_cluster/setting当中进行设置了

  1. logstash自身的配置
    在config/logstash.yml中配置
xpack.monitoring.enabled: true # 默认配置
xpack.monitoring.elasticsearch.hosts: ["http://es-prod-node-1:9200", "http://es-prod-node-2:9200"]
xpack.monitoring.elasticsearch.username: "logstash_system"
xpack.monitoring.elasticsearch.password: "changeme"
xpack.monitoring.collection.interval: 10000

可以看到,直接通过xpack.monitoring.enabled控制了是否收集logstash的数据。
不像kibana中单独使用了xpack.monitoring.kibana.collection.enabled来进行kibana数据是否搜集的配置,同样在es中也有一个类似的这样的配置

5.2 logstash使用metrict作为监控

在5.1中logstash使用的监控默认的是internal的collection收集方式
可以使用metricbeat来进行收集,应为使用metricbeat是单独部署的方式,后面再看

6. elasticsearch 的配置

es身兼的角色比较多,所以相关的配置也更多。

6.1 相关配置概览

首先,集群级别的配置

xpack.monitoring.collection.enabled: true

可以通过cluster-setting api进行设置,也可以通过在es的配置文件中进行设置

接下来是es的三个相关设置

xpack.monitoring.enabled: true 开启当前node的monitor设置
xpack.monitoring.elasticsearch.collection.enabled: true 这个设置了是否收集es相关的data
xpack.monitoring.collection.interval: 10000

xpack.monitoring.collection.enabled: true的作用自不必多说,下面主要说一下其他两个的作用

6.2 xpack.monitoring.enabled

当我在es的节点上设置

xpack.monitoring.enabled: false

出现了下面两种情况

6.2.1 当前节点为非master节点

只要这个节点不是master节点话,kibana上的监控都比较正常,有kibana的数据,也有es的数据,但是对应的那个设置为false的es节点的数据没有了。
这个也很自然,这个配置理论上至少可以达到禁止当前节点的monitor的效果。

6.2.2 当前节点为master节点

如果master节点设置了

xpack.monitoring.enabled: false

打开kibana的监控菜单,会看到这样的信息

You need to make some adjustments
To run monitoring please perform the following steps

We checked the nodeId: ADi2c-NmTnWhTmb2dDlCeA settings and found that xpack.monitoring.enabled is set to false set, which disables monitoring. Removing the xpack.monitoring.enabled: false setting from your configuration will put the default into effect and enable Monitoring.

在这里插入图片描述
也就是说这个应该是以master的为主,在es集群内生效,可能会导致kibana拿不到数据。

6.3 xpack.monitoring.elasticsearch.collection.enabled

这个配置的含义是比较直观的,经过测试,确实是这样,他的作用类似

xpack.monitoring.kibana.collection.enabled: true 这个是设置收集kibana monitor-data数据到es当中,

就是设置了当前node的数据是否收集到es当中
在实际测试中当master节点设置了false的话,kibana的显示也是不正常的,监控菜单打不开,
在这里插入图片描述

但是这个时候kibana的数据实际上是能够进入es的,因为在调整为true后发现es对应节点在过去的一段时间里面是没有数据的,但是kibana的数据是有的,所以是展示有一些问题,但是功能上和描述相差不大。

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
ey Features Understand common performance and reliability pitfalls in ElasticSearch Use popular monitoring tools such as ElasticSearch-head, BigDesk, Marvel, Kibana, and more This is a step-by-step guide with lots of case studies on solving real-world ElasticSearch cluster issues Book Description ElasticSearch is a distributed search server similar to Apache Solr with a focus on large datasets, a schema-less setup, and high availability. This schema-free architecture allows ElasticSearch to index and search unstructured content, making it perfectly suited for both small projects and large big data warehouses with petabytes of unstructured data. This book is your toolkit to teach you how to keep your cluster in good health, and show you how to diagnose and treat unexpected issues along the way. You will start by getting introduced to ElasticSearch, and look at some common performance issues that pop up when using the system. You will then see how to install and configure ElasticSearch and the ElasticSearch monitoring plugins. Then, you will proceed to install and use the Marvel dashboard to monitor ElasticSearch. You will find out how to troubleshoot some of the common performance and reliability issues that come up when using ElasticSearch. Finally, you will analyze your cluster's historical performance, and get to know how to get to the bottom of and recover from system failures. This book will guide you through several monitoring tools, and utilizes real-world cases and dilemmas faced when using ElasticSearch, showing you how to solve them simply, quickly, and cleanly. What you will learn Explore your cluster with ElasticSearch-head and BigDesk Access the underlying data of the ElasticSearch monitoring plugins using the ElasticSearch API Analyze your cluster's performance with Marvel Troubleshoot some of the common performance and reliability issues that come up when using ElasticSearch Analyze a cluster's historical performance, and get to the bottom of and recover from system failures Use and install various other tools and plugins such as Kibana and Kopf, which is helpful to monitor ElasticSearch About the Author Dan Noble is a software engineer with a passion for writing secure, clean, and articulate code. He enjoys working with a variety of programming languages and software frameworks, particularly Python, Elasticsearch, and frontend technologies. Dan currently works on geospatial web applications and data processing systems. Dan has been a user and advocate of Elasticsearch since 2011. He has given talks about Elasticsearch at various meetup groups, and is the author of the Python Elasticsearch client rawes. Dan was also a technical reviewer for the Elasticsearch Cookbook, Second Edition, by Alberto Paro. Table of Contents Chapter 1. Introduction to Monitoring Elasticsearch Chapter 2. Installation and the Requirements for Elasticsearch Chapter 3. Elasticsearch-head and Bigdesk Chapter 4. Marvel Dashboard Chapter 5. System Monitoring Chapter 6. Troubleshooting Performance and Reliability Issues Chapter 7. Node Failure and Post-Mortem Analysis Chapter 8. Looking Forward
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值