文章目录
之前讨论的都是使用当前存数据的cluster作为monitor cluster,但是在生产上一般都推荐使用sepatate cluster用户存储data cluster的监控数据,使用separate monitoring-cluster有两种方式
- 使用http-exporter
- 使用metric-beat
1. es的exporter
es的exporter的收集逻辑终于是基本上明白了,exporter主要是存在于es上,他的功能是接收由当前节点的es转发过来的消息再写入目标es(监控数据存储的es)
1.1 exporter主要功能
- 接收集群接收到的其他组件kibana,logstash,filebeat等的监控数据,这些监控数据会转发给exporter,然后由exporter决定发送到哪个集群
- 接收本地es的collector搜集到的数据,发送monitoring es集群
1.2 exporter分为两类
- local-exporter: 主要是将collector的数据和es转发过来的数据发送到当前节点的es当中
- http-exporter: 将1中的数据发送到配置的http路径下的es集群当中,进而可以实现monitoring-cluster的separated
当es配置了
xpack.monitoring.collection.enabled: false
那么exporter就不会工作了,对应的当前es的monitor-data,从logstash,kibana等上报到当前集群的monitor-data都会不再被收集。
1.3 es文档中的route的含义
这个时候终于懂了es文档中总是会提到的production-cluster route monitor data to monitoring-cluster是啥意思了,这里
The Elasticsearch cluster that is configured for use with X-Pack monitoring for
Logstash is expected to be the production cluster. This configuration enables the
production Elasticsearch cluster to add metadata (for example, its cluster UUID) to the
Logstash monitoring data then route it to the monitoring clusters.
就是logstash将数据发送到production-cluster 然后可以通过production-cluster转发给他http-exporter 再由exporter转发给monitoring-cluster,因为production会加一些信息,可以更好的区分logstash是和这个集群相关的。
1.4 使用http exporter配置separated monitoring-cluster
1.4.1 production-cluster
production-cluster-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"]
xpack.monitoring.elasticsearch.collection.enabled: true
xpack.monitoring.enabled: true
xpack.monitoring.collection.enabled: true
# 这里的host是monitoring-cluster的地址
xpack.monitoring.exporters:
my_remote:
type: http
host: ["10.76.0.98:13200","10.76.3.145:13200","10.76.0.129:13200"]
productiong-kibana
server.name: following-search-dev
server.port: 45601
server.host: 10.76.0.129
elasticsearch.hosts: ["http://10.76.0.98:12200"]
xpack.monitoring.kibana.collection.enabled: true
xpack.monitoring.enabled: true
xpack.monitoring.elasticsearch.hosts: ["http://10.76.0.98:12200"]
1.4.2 monitoring-cluster
monitoring-es
cluster.name: monitor-log
node.name: ES01
bootstrap.system_call_filter: false
network.host: 10.76.0.98
http.port: 13200
transport.port: 13300
discovery.seed_hosts: ["10.76.0.98:13300","10.76.3.145:13300","10.76.0.129:13300"]
cluster.initial_master_nodes: ["ES01", "ES02","ES03"]
xpack.monitoring.elasticsearch.collection.enabled: true
xpack.monitoring.enabled: true
## 这个地方设置为了false,禁止收集当前集群的信息,禁止了exporter功能
xpack.monitoring.collection.enabled: false
monitor-kibana
server.name: monitor-search-dev
server.port: 55601
server.host: 10.76.0.129
elasticsearch.hosts: ["http://10.76.0.98:13200"]
# 禁止收集当前kibana的监控信息
xpack.monitoring.kibana.collection.enabled: false
#xpack.monitoring.enabled: true
采用上面的配置,在production-kibana的监控面板中就没有信息了,只需要使用kibana的其他功能就好了,比如创建图表等功能
在monitor-kibana的监控面板中显示的是production-es 和production-kibana的monitor-data,
在上面的配置,假如将production-kibana中的
xpack.monitoring.elasticsearch.hosts: ["http://10.76.0.98:12200"]
直接配置为,monitor-es的地址的话,反而会出现无法收集production-kibana monitor-data的情况,因为monitor-es已经设置了
xpack.monitoring.collection.enabled: false
exporter不再接受由es转发而来的信息。
1.5 使用exporter设置seperated monitoring-cluster总结
使用exporter设置监控数据的独立data的集群的方式,除了es的数据是通过collector–>http exporter到monitoer-es的,其他的集群组件都是通过production-es route到http-exporter然后再到monitor-es的。
所以集群中的kibana,logstash,filbeat等都要配置monitor-data的目的地是production-es才行,直接配置monitoer-es会导致monitoer数据无法收集的情况。
2. 使用metricbeat监控
这个其实就是metribeat的使用,这个需要在每个节点上都装metricbeat,看起来比较麻烦,后期再整吧