Skip to content

Commit 1230228

Browse files
author
cbbarclay
committed
recipes
1 parent 1557c34 commit 1230228

File tree

6 files changed

+71
-0
lines changed

6 files changed

+71
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node.default[:elasticsearch][:custom_config] = {'node.rack_id' => "#{node[:opsworks][:instance][:availability_zone]}"}
2+
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Create script that pushes custom metrics into Cloudwatch
2+
#
3+
template "/usr/local/bin/cloudwatch-custom.sh" do
4+
source "elasticsearch.cloudwatch-custom.sh.erb"
5+
mode "0550"
6+
owner "root"
7+
group "root"
8+
end
9+
10+
# Cron it so that it runs every minute
11+
#
12+
cron "cloudwatch-custom" do
13+
hour "*"
14+
minute "*"
15+
weekday "*"
16+
command "/usr/local/bin/cloudwatch-custom.sh"
17+
end
18+

layer-custom/recipes/esmonit.rb

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
template "/etc/monit.d/elasticsearch-monit.conf" do
2+
source "elasticsearch.monitrc.conf.erb"
3+
mode 0440
4+
owner "root"
5+
group "root"
6+
end

layer-custom/recipes/esplugins.rb

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
script "install_plugin_es_head" do
2+
interpreter "bash"
3+
user "root"
4+
cwd "#{node.elasticsearch[:dir]}/elasticsearch-#{node.elasticsearch[:version]}/bin/"
5+
code <<-EOH
6+
plugin -install mobz/elasticsearch-head
7+
EOH
8+
not_if { File.exist?("#{node.elasticsearch[:dir]}/elasticsearch-#{node.elasticsearch[:version]}/plugins/head") }
9+
end
10+
11+
#notifies :restart, 'service[elasticsearch]' unless node.elasticsearch[:skip_restart]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/sh
2+
aws cloudwatch put-metric-data --region <%= node[:opsworks][:instance][:region] %> --namespace "ElasticSearch-<%= node.elasticsearch[:cluster][:name] %>" --metric-name "number_of_data_nodes" --unit "Count" --value "`curl -s 'http://localhost:9200/_cluster/health' | python -c 'import json,sys;obj=json.load(sys.stdin);print obj["number_of_data_nodes"]'`"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# ------------------------------------------
2+
# Monit configuration file for ElasticSearch
3+
# ------------------------------------------
4+
5+
check process elasticsearch with pidfile <%= node.elasticsearch[:pid_file] %>
6+
start program = "/etc/init.d/elasticsearch restart" with timeout 60 seconds
7+
stop program = "/etc/init.d/elasticsearch stop"
8+
if cpu > 90% for 15 cycles then alert
9+
if totalmem > 90% for 15 cycles then alert
10+
if loadavg(15min) greater than 10 for 50 cycles then alert
11+
group elasticsearch
12+
13+
<% if node.monit[:notify_email] %>
14+
check host elasticsearch_connection with address 0.0.0.0
15+
if failed url http://0.0.0.0:<%= node.elasticsearch[:http][:port] %>/ with timeout 15 seconds then alert
16+
group elasticsearch
17+
18+
check host elasticsearch_cluster_health with address 0.0.0.0
19+
if failed url http://0.0.0.0:<%= node.elasticsearch[:http][:port] %>/_cluster/health
20+
and content == 'green'
21+
with timeout 60 seconds
22+
then alert
23+
alert <%= node.monit[:notify_email] %> with mail-format {
24+
subject: [monit] elasticsearch: CLUSTER HEALTH PROBLEM at <%= node.hostname %>
25+
message: [<%= node.hostname %>] $SERVICE $ACTION
26+
<% if node.monit[:http_auth] && node.cloud %>
27+
--
28+
http://<%= node.monit[:http_auth]['username'] %>:<%= node.monit[:http_auth]['password_encoded'] %>@<%= node.cloud.public_hostname %>:2812/elasticsearch_cluster_health
29+
<% end %>
30+
}
31+
group elasticsearch
32+
<% end %>

0 commit comments

Comments
 (0)