使用 Metricbeat 收集有關 Elasticsearch 的數據并將其發送到監控集群

1、安裝監控集群es-mon+Kibana 
a、驗證監控集群xpack.monitoring.collection.enabled=false
curl -X GET "http://elastic:6CvDdDCwc3ZXPmiRgYOe@localhost:6200/_cluster/settings?pretty"
curl -X PUT "http://elastic:6CvDdDCwc3ZXPmiRgYOe@localhost:6200/_cluster/settings?pretty" -H 'Content-Type: application/json' -d'
{
  "persistent": {
    "xpack.monitoring.collection.enabled": false
  }
}
'   

使用 Metricbeat 收集 生產Elasticsearch 監控數據
1、啟用生產集群監控數據的收集 xpack.monitoring.collection.enabled=true
curl -X GET "http://elastic:yOUzNlC5XX1R5xgH1aeC@localhost:6200/_cluster/settings?pretty"
curl -X PUT "localhost:9200/_cluster/settings?pretty" -H 'Content-Type: application/json' -d'
{
  "persistent": {
    "xpack.monitoring.collection.enabled": true
  }
}
'   
2、Metricbeat 安裝和配置
安裝 Metricbeat
curl -L -O https://artifacts.elastic.co/downloads/beats/metricbeat/metricbeat-7.16.2-linux-x86_64.tar.gz
tar xzvf metricbeat-8.2.2-linux-x86_64.tar.gz      
3、在每個生產Elasticsearch 節點上啟用 Metricbeat 中的 Elasticsearch 模塊。
./metricbeat modules list #查看支持的模塊
./metricbeat modules enable elasticsearch-xpack #啟用Elasticsearch 模塊
4、在每個 生產Elasticsearch 節點上的 Metricbeat 中配置 Elasticsearch 模塊。
配置modules.d/elasticsearch-xpack.yml
- module: elasticsearch
    xpack.enabled: true
    period: 10s
    hosts: ["http://localhost:9200"] 
    #scope: node 
    #username: "user"
    #password: "secret"
    #ssl.enabled: true
    #ssl.certificate_authorities: ["/etc/pki/root/ca.pem"]
    #ssl.certificate: "/etc/pki/client/cert.pem"
    #ssl.key: "/etc/pki/client/cert.key"
    #ssl.verification_mode: "full"
5、生產集群禁用 Metricbeat 中的系統模塊。
./metricbeat modules disable system
6、確定將監控數據發送到何處 metricbeat.yml
output.elasticsearch:
  # Array of hosts to connect to.
  hosts: ["http://es-mon-1:9200", "http://es-mon-2:9200"] 

  # Optional protocol and basic auth credentials.
  #protocol: "https"
  #username: "elastic"
  #password: "changeme"
7、在每個節點上 啟動 Metricbeat 。
./metricbeat test config -e  #測試配置文件
./metricbeat setup -e
啟用metrics
sudo chown root metricbeat.yml 
sudo chown root modules.d/nginx.yml 
sudo ./metricbeat -e
8、生產集群禁用 Elasticsearch 監控指標的默認集合。
curl -X PUT "http://elastic:yOUzNlC5XX1R5xgH1aeC@localhost:6200/_cluster/settings?pretty" -H 'Content-Type: application/json' -d'
{
  "persistent": {
    "xpack.monitoring.elasticsearch.collection.enabled": false
  }
}
'
9、在 Kibana 中查看監控數據
http://localhost:5601

#-----------------------------
b、如果es-mon集群啟用安全功能,請創建可以發送和檢索監控數據的用戶
    使用 Kibana 查看監控數據,用戶名和密碼憑證必須在 Kibana 服務器和監控集群上都有效
    使用 Metricbeat 收集有關 Elasticsearch 或 Kibana 的數據
    創建一個具有remote_monitoring_collector內置角色的用戶和一個具有remote_monitoring_agent 內置角色的用戶。
    或者,使用 remote_monitoring_user 內置用戶。
curl -X POST "localhost:9200/_security/user/remote_monitor?pretty" -H 'Content-Type: application/json' -d'
{
  "password" : "changeme",
  "roles" : [ "remote_monitoring_agent"],
  "full_name" : "Internal Agent For Remote Monitoring"
}
'

參考文檔

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容