默認狀況下,X-Pack監控被啓用,可是數據收集被禁用,高級監控設置使你可以控制收集數據的頻率、配置超時以及爲本地存儲的監控索引設置保留期,你還能夠調整監控數據的顯示方式。html
收集關於你的Elasticsearch集羣的監控數據:java
xpack.monitoring.enabled
和xpack.monitoring.collection.enabled
設置是否爲true
。可選:指定要監控的索引。
默認狀況下,監控代理從全部Elasticsearch索引中收集數據,要從特定索引中收集數據,配置xpack.monitoring.collection.indices
設置,能夠將多個索引指定爲逗號分隔的列表或使用索引模式匹配多個索引,例如:node
xpack.monitoring.collection.indices: logstash-*, index1, test2
你能夠前置+
或-
來顯式地包含或排除索引名稱或模式,例如,要包含除test3
以外以test
開頭的全部索引,能夠指定+test*
、-test3
。segmentfault
xpack.monitoring.collection.interval
設置的默認值爲10秒。可選:將你的集羣配置爲將從Kibana、Beats和Logstash等源的監控數據路由到監控集羣:數組
xpack.monitoring.collection.enabled
設置是否爲true
。默認狀況下,X-Pack監控使用local
導出器對同一集羣上的監控數據進行索引,參閱默認導出器和本地導出器。安全
或者,你可使用http
導出器將數據發送到單獨的監視集羣,參閱HTTP導出器。服務器
有關典型監控體系結構的更多信息,請參見監控工做原理。oracle
若是啓用了X-Pack安全性,而且你正在使用http
導出器將數據發送到專用的監控集羣中:app
在監控集羣上建立具備remote_monitoring_agent
內置角色的用戶,例如,下面的請求建立了一個remote_monitor
用戶,該用戶具備remote_monitoring_agent
角色:socket
POST /_xpack/security/user/remote_monitor { "password" : "changeme", "roles" : [ "remote_monitoring_agent"], "full_name" : "Internal Agent For Remote Monitoring" }
在被監控的集羣中的每一個節點上,配置http
導出器,以便在將數據發送到監控集羣時使用適當的憑據。
若是監控集羣上啓用了SSL/TLS,則必須在host
設置中使用HTTPS協議,還必須在每一個節點的可信證書中包含CA證書,以便在監控集羣中驗證節點的身份。
下面的示例使用certificate_authority
設置指定PEM編碼證書的位置:
xpack.monitoring.exporters: id1: type: http host: ["https://es-mon1:9200", "https://es-mon2:9200"] auth: username: remote_monitor password: changeme ssl: certificate_authorities: [ "/path/to/ca.crt" ] id2: type: local
username
和password
參數提供用戶憑證。
或者,你可使用信truststore(包含證書的Java Keystore文件)來配置受信任的證書:
xpack.monitoring.exporters: id1: type: http host: ["https://es-mon1:9200", "https://es-mon2:9200"] auth: username: remote_monitor password: changeme ssl: truststore.path: /path/to/file truststore.password: password id2: type: local
在存儲監控數據的集羣上設置X-Pack監控UI用戶,也就是監控集羣,要授予全部必要的權限,請向用戶分配monitoring_user
和kibana_user
角色,或更多信息,請參閱將用戶和組映射到角色。
索引模板用於配置存儲從集羣收集的監控數據的索引。
你能夠經過_template
API檢索模板:
GET /_template/.monitoring-*
默認狀況下,模板爲監控索引配置一個碎片和一個副本,要覆蓋默認設置,請添加你本身的模板:
template
模式爲.monitoring-*
。order
設置爲1
,這確保你的模板是在默認模板以後應用的,默認模板的順序是0
。settings
部分中指定number_of_shards
和/或number_of_replicas
。例如,下面的模板將碎片數量增長到5個,副本數量增長到2個。
PUT /_template/custom_monitoring { "index_patterns": ".monitoring-*", "order": 1, "settings": { "number_of_shards": 5, "number_of_replicas": 2 } }
只設置settings
部分中的number_of_shards
和number_of_replicas
,覆蓋其餘監控模板設置可能致使監控儀表盤中止正常工做。
若是你經過tribe節點鏈接到集羣,而且但願監控tribe節點,那麼還須要在該節點上安裝X-Pack。
經過這種配置,tribe節點包含在監控UI中顯示的節點計數中,但不包含在節點列表中,由於它不向監控集羣導出任何數據。
要將tribe節點包含在監控數據中,請在tribe級別啓用監控數據收集:
node.name: my-tribe-node1 tribe: on_conflict: prefer_cluster1 c1: cluster.name: cluster1 discovery.zen.ping.unicast.hosts: [ "cluster1-node1:9300", "cluster1-node2:9300", "cluster1-node2:9300" ] xpack.monitoring.enabled: true c2: cluster.name: cluster2 discovery.zen.ping.unicast.hosts: [ "cluster2-node3:9300", "cluster2-node3:9300", "cluster2-node3:9300" ] xpack.monitoring: enabled: true exporters: id1: type: http host: [ "monitoring-cluster:9200" ]
xpack.monitoring.enabled: true
=> 啓用使用本地導出器從tribe節點收集數據。type: http
=> 啓用使用HTTP導出器從tribe節點收集數據。當你啓用來自tribe節點的數據收集時,它將包含在節點計數和節點列表中。
默認狀況下,啓用監控,但禁用數據收集,要啓用數據收集,使用xpack.monitoring.collection.enabled
設置。
你能夠在elasticsearch.yml
文件中配置這些監控設置,經過使用集羣更新設置API,還能夠跨集羣設置其中的一些。
集羣設置優先於
elasticsearch.yml
文件中的設置。
要調整監控數據在監控UI中的顯示方式,請在kibana.yml中配置xpack.monitoring設置,要控制如何從Logstash收集監控數據,請在logstash.yml
中配置xpack.monitoring設置。
有關更多信息,請參見監控Elastic Stack。
xpack.monitoring.enabled
設置爲true
(默認)以啓用Elasticsearch X-Pack監控節點上的Elasticsearch。
要啓用數據收集,你必須還要設置xpack.monitoring.collection.enabled
爲true
,它默認值爲false
。
xpack.monitoring.collection
設置控制如何從Elasticsearch節點收集數據。
xpack.monitoring.collection.enabled
true
以啓用監控數據的收集,當此設置爲false
(默認值)時,不會收集Elasticsearch監控數據,而且會忽略來自Kibana、Beats和Logstash等其餘源的全部監控數據。xpack.monitoring.collection.interval
-1
以禁用數據收集從6.3.0開始已被棄用。控制收集數據樣本的頻率,默認爲10s
。若是你修改了收集間隔,在kibana.yml
中設置xpack.monitoring.min_interval_seconds
選項爲相同的值。
你也能夠經過集羣更新設置API更新此設置。
xpack.monitoring.collection.cluster.stats.timeout
10s
。xpack.monitoring.collection.indices
test1,test2,test3
,名稱能夠包括通配符,例如test*
。你能夠經過前置+
包含索引或-
排除索引來顯式地包含或排除索引,例如,要包含除test3
以外以test
開頭的全部索引,能夠指定+test*,-test3
。你能夠經過集羣更新設置API更新此設置。
xpack.monitoring.collection.index.stats.timeout
10s
。xpack.monitoring.collection.index.recovery.active_only
true
只收集活動的recoveries,默認爲false
。xpack.monitoring.collection.index.recovery.timeout
10s
。xpack.monitoring.history.duration
設置保存期限,超過此期限,監控導出器建立的索引將被自動刪除,默認爲7d
(7天)。
此設置的最小值爲1d
(1天),以確保某些內容正在被監控,而且不能禁用它。
這種設置目前隻影響
local
類型的導出器,使用http導出器建立的索引不會自動刪除。
若是X-Pack監控和Watcher都啓用了,那麼你也可使用這個設置來影響Watcher清理服務,有關更多信息,請參閱在Watcher設置中的xpack.watcher.history.cleaner_service.enabled
設置。
xpack.monitoring.exporters
local
導出器是監控使用的默認導出器,顧名思義,它將數據導出到本地集羣,這意味着不須要進行太多配置。
若是你不提供任何導出器,那麼監控將自動爲你建立一個,若是提供了任何導出器,則不增長默認的。
xpack.monitoring.exporters.my_local: type: local
type
local
,這是必須的。use_ingest
true
。若是禁用,那麼這意味着它將不會使用管道,這意味着未來的版本不能自動地將批量請求升級到將來的版本。cluster_alerts.management.enabled
true
,要使用此特性,必須啓用Watcher,若是你具備基本許可證,則不會顯示集羣警報。下面列出了http
導出器能夠提供的設置,全部設置以下所示,你爲你的導出器選擇的名稱:
xpack.monitoring.exporters.my_remote: type: http host: ["host:port", ...]
type
http
,這是必需的。host
Host支持多種格式,既有數組格式,也有單值格式,支持的格式包括hostname
、hostname:port
、http://hostname
、http://hostname:port
、https://hostname
和https://hostname:port
。Host不能是假的,默認方案老是http
,端口若是不做爲host
字符串的一部分提供,默認端口老是9200
。
xpack.monitoring.exporters: example1: type: http host: "10.1.2.3" example2: type: http host: ["http://10.1.2.4"] example3: type: http host: ["10.1.2.5", "10.1.2.6"] example4: type: http host: ["https://10.1.2.3:9200"]
auth.username
auth.password
,則須要用戶名。auth.password
auth.username
的密碼。connection.timeout
6s
。connection.read_timeout
10 * connection.timeout
(若是都沒有設置,則爲60s
)。ssl
proxy.base_path
/base/path
(例如,批量請求將以/base/path/_bulk
的形式發送),沒有默認值。headers
添加到每一個請求中的可選headers,它能夠協助經過代理路由請求。
xpack.monitoring.exporters.my_remote: headers: X-My-Array: [abc, def, xyz] X-My-Header: abc123
基於數組的headers被髮送n
次,其中n
是數組的大小,沒法設置Content-Type
和Content-Length
,監控代理建立的任何headers都會覆蓋這裏定義的任何內容。
index.name.time_format
use_ingest
true
,若是禁用,那麼這意味着它將不會使用管道,這意味着未來的版本不能自動地將批量請求升級到將來的版本。cluster_alerts.management.enabled
true
,要使用此特性,必須啓用Watcher,若是你具備基本許可證,則不會顯示集羣警報。cluster_alerts.management.blacklist
防止建立特定的集羣警報,它還刪除了當前集羣中已經存在的任何可用的watches。
你能夠在黑名單中添加如下任何一個watch標識符:
elasticsearch_cluster_status
elasticsearch_version_mismatch
elasticsearch_nodes
kibana_version_mismatch
logstash_version_mismatch
xpack_license_expiration
例如:["elasticsearch_version_mismatch","xpack_license_expiration"]
。
你能夠配置如下TLS/SSL設置,若是沒有配置這些設置,則使用默認的TLS/SSL設置。
xpack.monitoring.exporters.$NAME.ssl.supported_protocols
SSLv2Hello
、SSLv3
、TLSv1
、TLSv1.1
、TLSv1.2
,默認爲TLSv1.2
、TLSv1.1
、TLSv1
,默認爲xpack.ssl.supported_protocols
的值。xpack.monitoring.exporters.$NAME.ssl.verification_mode
none
、certificate
和full
,有關這些值的描述,請參閱xpack.ssl.verification_mode
,默認爲xpack.ssl.verification_mode
的值。xpack.monitoring.exporters.$NAME.ssl.cipher_suites
xpack.ssl.cipher_suites
的值。如下設置用於指定經過SSL/TLS鏈接進行通訊時應該使用的私鑰、證書和可信證書,私鑰和證書是可選的,若是服務器用於PKI身份驗證要求客戶端身份驗證,則將使用它們,若是沒有指定如下設置,則使用默認的TLS/SSL設置。
在使用PEM編碼文件時,請使用如下設置:
xpack.monitoring.exporters.$NAME.ssl.key
xpack.monitoring.exporters.$NAME.ssl.key_passphrase
xpack.monitoring.exporters.$NAME.ssl.secure_key_passphrase
(安全)
xpack.monitoring.exporters.$NAME.ssl.certificate
xpack.monitoring.exporters.$NAME.ssl.certificate_authorities
當使用包含私鑰、證書和應該受信任的證書的Java keystore文件(JKS)時,請使用如下設置:
xpack.monitoring.exporters.$NAME.ssl.keystore.path
index.name.time_format
xpack.monitoring.exporters.$NAME.ssl.keystore.secure_password
(安全)
xpack.monitoring.exporters.$NAME.ssl.keystore.key_password
xpack.monitoring.exporters.$NAME.ssl.keystore.password
相同。xpack.monitoring.exporters.$NAME.ssl.keystore.secure_key_password
(安全)
xpack.monitoring.exporters.$NAME.ssl.truststore.path
xpack.monitoring.exporters.$NAME.ssl.truststore.password
ixpack.monitoring.exporters.$NAME.ssl.truststore.secure_password
(安全)
能夠將X-Pack安全性配置爲使用PKCS#12容器文件(.p12
或.pfx
文件),這些文件包含私鑰、證書和應該受信任的證書。
PKCS#12文件的配置方式與Java密鑰存儲文件相同:
xpack.monitoring.exporters.$NAME.ssl.keystore.path
xpack.monitoring.exporters.$NAME.ssl.keystore.type
PKCS12
,以指示keystore是PKCS#12文件。xpack.monitoring.exporters.$NAME.ssl.keystore.password
xpack.monitoring.exporters.$NAME.ssl.keystore.secure_password
(安全)
xpack.monitoring.exporters.$NAME.ssl.keystore.key_password
xpack.monitoring.exporters.$NAME.ssl.keystore.password
相同。xpack.monitoring.exporters.$NAME.ssl.keystore.secure_key_password
(安全)
xpack.monitoring.exporters.$NAME.ssl.truststore.path
xpack.monitoring.exporters.$NAME.ssl.truststore.type
PKCS12
,以指示truststore是PKCS#12文件。xpack.monitoring.exporters.$NAME.ssl.truststore.password
xpack.monitoring.exporters.$NAME.ssl.truststore.secure_password
(安全)
能夠將X-Pack安全性配置爲使用PKCS#11令牌,該令牌包含私鑰、證書和應該受信任的證書。
PKCS#11令牌須要在JVM級別上進行額外的配置,能夠經過如下設置啓用:
xpack.monitoring.exporters.$NAME.keystore.type
PKCS11
,以指示PKCS#11令牌應該用做keystore。xpack.monitoring.exporters.$NAME.truststore.type
PKCS11
,以指示PKCS#11令牌應該用做truststore。