默认状况下,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。