elasticsearch之watcher插件安装文档

elasticsearch之watcher插件安装文档

watcher插件可以提供elasticsearch集群的监控提醒功能。
You need to install the License and Watcher plugins on each node in your cluster.
你需要在你的集群中所有节点安装license和watcher插件

安装watcher插件
1:安装license
bin/plugin install license

2:安装watcher插件
bin/plugin install watcher
3:在安装的时候需要确认一下
Continue with installation? [y/N]y
Specify the --batch option when running the install command to automatically grant these permissions and bypass this install prompt.
或者指定在安装插件命令后面添加 --batch,忽略确认直接安装。
4:【默认这一步不需要操作,因为默认情况下es并没有禁用自动创建索引库功能】If you have disabled automatic index creation in Elasticsearch, configure action.auto_create_index in elasticsearch.yml to allow watcher to create the .watches, .triggered_watches, and .watcher-history* indices:
如果你在es中禁用了自动创建索引库的功能。那么你需要在elasticsearch.yml中配置action.auto_create_index 以便允许watcher去创建.watches, .triggered_watches, and .watcher-history* 索引库。

action.auto_create_index: .watches,.triggered_watches,.watcher-history*

If you have Shield installed, you must also allow Shield to create the .security index.
如果你已经安装了shield,你必须允许shield创建.security索引库

5:启动es
bin/elasticsearch

6:验证
curl -XGET ‘http://localhost:9200/_watcher/stats?pretty’

{
“watcher_state”: “started”,
“watch_count”: 0,
“execution_thread_pool”: {
“queue_size”: 0,
“max_size”: 0
}
}

监控功能:
1:监控错误日志
Watch Log Data for Errors
https://www.elastic.co/guide/en/watcher/current/watch-log-data.html
2:监控集群监控状态
Watch Your Cluster Health
https://www.elastic.co/guide/en/watcher/current/watch-cluster-status.html

下面以监控集群状态为例演示:
1:创建一个每10秒运行一次的调度器
curl -XPUT ‘http://192.168.80.100:9200/_watcher/watch/cluster_health_watch’ -d ‘{
“trigger” : {
“schedule” : { “interval” : “10s” }
}
}’

2:给这个调度器增加一个input,把集群的健康状态添加到watcher中
curl -XPUT ‘http://192.168.80.100:9200/_watcher/watch/cluster_health_watch’ -d ‘{
“trigger” : {
“schedule” : { “interval” : “10s” }
},
“input” : {
“http” : {
“request” : {
“host” : “192.168.80.100”,
“port” : 9200,
“path” : “/_cluster/health”
}
}
}
}’

3:给这个wacher添加一个条件,判断集群的状态是否为red
curl -XPUT ‘http://192.168.80.100:9200/_watcher/watch/cluster_health_watch’ -d ‘{
“trigger” : {
“schedule” : { “interval” : “10s” }
},
“input” : {
“http” : {
“request” : {
“host” : “192.168.80.100”,
“port” : 9200,
“path” : “/_cluster/health”
}
}
},
“condition” : {
“compare” : {
“ctx.payload.status” : { “eq” : “red” }
}
}
}’

4:给watcher设置触发任务,当满足条件的时候,执行。
一般都是发送邮件。
所以需要先配置邮箱信息。修改es的配置文件。
vi conf/elasticsearch.yml
watcher.actions.email.service.account:
work:
profile: qqmail
smtp:
auth: true
starttls.enable: true
host: smtp.qq.com
port: 587
user: 12345677@qq.com
password: 12345678
添加触发任务【手动把某一个索引库的分片删除一部分可以模拟分片丢失,集群状态会变为red,此任务就会被触发,发送邮件。】
curl -XPUT ‘http://192.168.80.100:9200/_watcher/watch/cluster_health_watch’ -d ‘{
“trigger” : {
“schedule” : { “interval” : “10s” }
},
“input” : {
“http” : {
“request” : {
“host” : “192.168.80.100”,
“port” : 9200,
“path” : “/_cluster/health”
}
}
},
“condition” : {
“compare” : {
“ctx.payload.status” : { “eq” : “yellow” }
}
},
“actions” : {
“send_email” : {
“email” : {
“to” : “87654321@qq.com”,
“subject” : “Cluster Status Warning”,
“body” : “Cluster status is RED”
}
}
}
}’

验证集群状态,如果集群状态为red,则刚才配置的watcher任务就会执行,发送邮件提醒。

curl -XGET ‘http://192.168.80.100:9200/_cluster/health?pretty’
5:实验结束,可以移除掉这个watcher
curl -XDELETE ‘http://192.168.80.100:9200/_watcher/watch/cluster_health_watch’

卸载watcher
To uninstall Watcher:

1:停止Elasticsearch.
2:从Elasticsearch中移除watcher:
bin/plugin remove watcher

3:启动Elasticsearch.

获取更多大数据资料,视频以及技术交流请加群:

在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值