1 # Get the first es node in the list
2 es_node = node['Nodes']['ES'].first
4 ruby_block "check_ElasticSearch_Cluster_Health" do
6 #tricky way to load this Chef::Mixin::ShellOut utilities
7 Chef::Resource::RubyBlock.send(:include, Chef::Mixin::ShellOut)
8 curl_command = "http://#{es_node}:9200/_cluster/health?pretty=true"
9 resp = Net::HTTP.get_response URI.parse(curl_command)
10 stat = JSON.parse(resp.read_body)['status']
14 printf("\033[32m%s\n\033[0m", " ElasticSearch Cluster status is green.")
16 printf("\033[33m%s\n\033[0m", " ElasticSearch Cluster status is yellow...")
18 printf("\033[31m%s\n\033[0m", " ElasticSearch Cluster status is red!")
32 bash "create monitoring mapping" do
34 curl -i -X PUT -d '{ "order": 1, "template": "monitoring_events-*", "settings": {}, "mappings":
38 "hostid": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
39 "hostcpu": { "include_in_all": true, "type": "long" },
40 "hostmem": { "include_in_all": true, "type": "double" },
41 "hostdisk": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
42 "jvmid": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
43 "jvmcpu": { "include_in_all": true,"type": "long" },
44 "jvmmem": { "include_in_all": true, "type": "long" },
45 "jvmtnum": { "include_in_all": true, "type": "integer" },
46 "appid": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
47 "appstat": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
48 "timestamp": { "include_in_all": true, "index": "not_analyzed", "ignore_malformed": false, "format": "yyyy-MM-dd HH:mm:ss.SSS z", "precision_step": 4, "type": "date" }
50 "_all": { "enabled": true }
53 "aliases": { "last_3_months": {} }
54 }' http://#{es_node}:9200/_template/monitoring_template