35bf49fb6df66322f710d87b61d62ee341538802
[sdc.git] /
1 ruby_block "check_ElasticSearch_Cluster_Health" do
2     block do
3                 #tricky way to load this Chef::Mixin::ShellOut utilities
4                 Chef::Resource::RubyBlock.send(:include, Chef::Mixin::ShellOut)
5                 curl_command = "http://#{node['Nodes']['ES']}:9200/_cluster/health?pretty=true"
6                 resp = Net::HTTP.get_response URI.parse(curl_command)
7                 stat = JSON.parse(resp.read_body)['status']
8
9                 case stat
10                         when "green"
11                                 printf("\033[32m%s\n\033[0m", "  ElasticSearch Cluster status is green.")
12                         when "yellow"
13                                 printf("\033[33m%s\n\033[0m", "  ElasticSearch Cluster status is yellow...")
14                         when "red"
15                                 printf("\033[31m%s\n\033[0m", "  ElasticSearch Cluster status is red!")
16                                 break;
17                 end
18    end
19    retries 50
20    retry_delay 2
21 end
22
23
24 bash "create audit mapping" do
25         code <<-EOH
26                 curl -i -X PUT -d '{ "order": 1, "template": "auditingevents-*", "settings": {}, "mappings":
27         {
28                 "distributiondownloadevent": { 
29                         "properties": {
30                                 "TIMESTAMP": { "include_in_all": true, "ignore_malformed": false, "format": "yyyy-MM-dd HH:mm:ss.SSS z", "precision_step": 4, "type": "date" },
31                                 "REQUEST_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
32                                 "SERVICE_INSTANCE_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
33                                 "ACTION": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
34                                 "DESC": { "include_in_all": true, "type": "string" },
35                                 "STATUS": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
36                                 "RESOURCE_URL": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
37                                 "CONSUMER_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" }
38                         },
39                         "_all": { "enabled": true } 
40                 },
41                 "auditinggetuebclusterevent": { 
42                         "properties": {
43                                 "TIMESTAMP": { "include_in_all": true, "ignore_malformed": false, "format": "yyyy-MM-dd HH:mm:ss.SSS z", "precision_step": 4, "type": "date" },
44                                 "REQUEST_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
45                                 "SERVICE_INSTANCE_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
46                                 "ACTION": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
47                                 "DESC": { "include_in_all": true, "type": "string" },
48                                 "STATUS": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
49                                 "CONSUMER_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" }
50                         },
51                         "_all": { "enabled": true } 
52                 },
53                 "distributionstatusevent": {
54                         "properties": {
55                                 "TIMESTAMP": { "include_in_all": true, "ignore_malformed": false, "format": "yyyy-MM-dd HH:mm:ss.SSS z", "precision_step": 4, "type": "date" },
56                                 "REQUEST_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
57                                 "SERVICE_INSTANCE_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
58                                 "ACTION": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
59                                 "DESC": { "include_in_all": true, "type": "string" },
60                                 "STATUS": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
61                                 "RESOURCE_URL": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
62                                 "DID": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
63                                 "TOPIC_NAME":{ "include_in_all": true, "index": "not_analyzed", "type": "string" },
64                                 "CONSUMER_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" }
65                         },
66                         "_all": { "enabled": true } 
67                 },
68                 "distributionengineevent": {
69                         "properties": {
70                                 "TIMESTAMP": { "include_in_all": true, "ignore_malformed": false, "format": "yyyy-MM-dd HH:mm:ss.SSS z", "precision_step": 4, "type": "date" },
71                                 "REQUEST_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
72                                 "SERVICE_INSTANCE_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
73                                 "ACTION": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
74                                 "DESC": { "include_in_all": true, "type": "string" },
75                                 "STATUS": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
76                                 "TOPIC_NAME":{ "include_in_all": true, "index": "not_analyzed", "type": "string" },
77                                 "ROLE": { "include_in_all": true, "type": "string" },
78                                 "API_KEY": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
79                                 "D_ENV": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
80                                 "CONSUMER_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" }
81                         },
82                         "_all": { "enabled": true } 
83                 },
84                 "useraccessevent": { 
85                         "properties": {
86                                 "TIMESTAMP": { "include_in_all": true, "ignore_malformed": false, "format": "yyyy-MM-dd HH:mm:ss.SSS z", "precision_step": 4, "type": "date" },
87                                 "REQUEST_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
88                                 "SERVICE_INSTANCE_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
89                                 "ACTION": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
90                                 "DESC": { "include_in_all": true, "type": "string" },
91                                 "STATUS": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
92                                 "USER": { "include_in_all": true, "type": "string" }
93                         },
94                         "_all": { "enabled": true }
95                 },
96                 "resourceadminevent": {
97                         "properties": {
98                                 "TIMESTAMP": { "include_in_all": true, "ignore_malformed": false, "format": "yyyy-MM-dd HH:mm:ss.SSS z", "precision_step": 4, "type": "date" },
99                                 "REQUEST_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
100                                 "SERVICE_INSTANCE_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
101                                 "INVARIANT_UUID": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
102                                 "ACTION": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
103                                 "DESC": { "include_in_all": true, "type": "string" },
104                                 "STATUS": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
105                                 "CURR_VERSION": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
106                                 "CURR_STATE": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
107                                 "DID": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
108                                 "MODIFIER": { "include_in_all": true, "type": "string" },
109                                 "PREV_VERSION": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
110                                 "PREV_STATE": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
111                                 "RESOURCE_NAME": { "include_in_all": true, "type": "string" },
112                                 "RESOURCE_TYPE": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
113                                 "DPREV_STATUS": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
114                                 "DCURR_STATUS": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
115                                 "TOSCA_NODE_TYPE": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
116                                 "COMMENT": { "include_in_all": true, "type": "string" },
117                                 "ARTIFACT_DATA": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
118                                 "PREV_ARTIFACT_UUID": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
119                                 "CURR_ARTIFACT_UUID": { "include_in_all": true, "index": "not_analyzed", "type": "string" } 
120                         },
121                         "_all": { "enabled": true }
122                 },
123                 "useradminevent": {
124                         "properties": {
125                                 "TIMESTAMP": { "include_in_all": true, "ignore_malformed": false, "format": "yyyy-MM-dd HH:mm:ss.SSS z", "precision_step": 4, "type": "date" },
126                                 "REQUEST_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
127                                 "SERVICE_INSTANCE_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
128                                 "ACTION": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
129                                 "DESC": { "include_in_all": true, "type": "string" },
130                                 "STATUS": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
131                                 "USER_AFTER": { "include_in_all": true, "type": "string" },
132                                 "USER_BEFORE": { "include_in_all": true, "type": "string" },
133                                 "MODIFIER": { "include_in_all": true, "type": "string" }
134                         },
135                         "_all": { "enabled": true } 
136                 },
137                 "distributionnotificationevent": {
138                         "properties": {
139                                 "TIMESTAMP": { "include_in_all": true, "ignore_malformed": false, "format": "yyyy-MM-dd HH:mm:ss.SSS z", "precision_step": 4, "type": "date" },
140                 "REQUEST_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
141                 "SERVICE_INSTANCE_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
142                 "ACTION": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
143                 "DESC": { "include_in_all": true, "type": "string" },
144                 "STATUS": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
145                 "CURR_STATE": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
146                 "CURR_VERSION": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
147                 "DID": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
148                 "MODIFIER": { "include_in_all": true, "type": "string" },
149                 "RESOURCE_NAME": { "include_in_all": true, "type": "string" },
150                 "RESOURCE_TYPE": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
151                 "TOPIC_NAME":{ "include_in_all": true, "index": "not_analyzed", "type": "string" }
152                         },
153             "_all": { "enabled": true } 
154                 },
155                 "categoryevent": {
156                         "properties": {
157                                 "ACTION": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
158                                 "DESC": { "include_in_all": true, "type": "string" },
159                                 "MODIFIER": { "include_in_all": true, "type": "string" },
160                                 "REQUEST_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
161                                 "CATEGORY_NAME": { "include_in_all": true, "type": "string" },
162                                 "SUB_CATEGORY_NAME": { "include_in_all": true, "type": "string" },
163                                 "GROUPING_NAME": { "include_in_all": true, "type": "string" },
164                                 "RESOURCE_TYPE": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
165                                 "SERVICE_INSTANCE_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
166                                 "STATUS": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
167                                 "TIMESTAMP": { "include_in_all": true, "ignore_malformed": false, "format": "yyyy-MM-dd HH:mm:ss.SSS z", "precision_step": 4, "type": "date" }
168                         },
169             "_all": { "enabled": true } 
170                 },
171                 "authevent": {
172                         "properties": {
173                                 "TIMESTAMP": { "include_in_all": true, "ignore_malformed": false, "format": "yyyy-MM-dd HH:mm:ss.SSS z", "precision_step": 4, "type": "date" },
174                                 "DESC": { "include_in_all": true, "type": "string" },
175                                 "STATUS": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
176                                 "URL": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
177                                 "ACTION": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
178                                 "USER": { "include_in_all": true, "type": "string" },
179                                 "AUTH_STATUS": { "include_in_all": true, "index": "not_analyzed","type": "string" } ,
180                                 "REALM": { "include_in_all": true, "index": "not_analyzed","type": "string" }
181                         },
182                         "_all": { "enabled": true }
183                 },
184                 "consumerevent": {
185                         "properties": {
186                                 "ACTION": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
187                                 "MODIFIER": { "include_in_all": true, "type": "string" },
188                                 "STATUS": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
189                                 "DESC": { "include_in_all": true, "type": "string" },
190                                 "REQUEST_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
191                                 "ECOMP_USER": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
192                                 "TIMESTAMP": { "include_in_all": true, "ignore_malformed": false, "format": "yyyy-MM-dd HH:mm:ss.SSS z", "precision_step": 4, "type": "date" }
193                         },
194                         "_all": { "enabled": true } 
195                 },
196                 "getuserslistevent": {
197                         "properties": {
198                                 "ACTION": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
199                                 "MODIFIER": { "include_in_all": true, "type": "string" },
200                                 "STATUS": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
201                                 "DESC": { "include_in_all": true, "type": "string" },
202                                 "REQUEST_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
203                                 "DETAILS": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
204                                 "TIMESTAMP": { "include_in_all": true, "ignore_malformed": false, "format": "yyyy-MM-dd HH:mm:ss.SSS z", "precision_step": 4, "type": "date" }
205                         },
206             "_all": { "enabled": true } 
207                 },
208                 "getcategoryhierarchyevent": {
209                         "properties": {
210                                 "ACTION": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
211                                 "MODIFIER": { "include_in_all": true, "type": "string" },
212                                 "STATUS": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
213                                 "DESC": { "include_in_all": true, "type": "string" },
214                                 "REQUEST_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
215                                 "DETAILS": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
216                                 "TIMESTAMP": { "include_in_all": true, "ignore_malformed": false, "format": "yyyy-MM-dd HH:mm:ss.SSS z", "precision_step": 4, "type": "date" }
217                         },
218                         "_all": { "enabled": true } 
219                 },
220                 "distributiondeployevent": {
221                         "properties": {
222                                 "ACTION": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
223                                 "CURR_VERSION": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
224                                 "DESC": { "include_in_all": true, "type": "string" },
225                                 "DID": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
226                                 "MODIFIER": { "include_in_all": true, "type": "string" },
227                                 "REQUEST_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
228                                 "RESOURCE_NAME": { "include_in_all": true, "type": "string" },
229                                 "RESOURCE_TYPE": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
230                                 "SERVICE_INSTANCE_ID": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
231                                 "STATUS": { "include_in_all": true, "index": "not_analyzed", "type": "string" },
232                                 "TIMESTAMP": { "include_in_all": true, "ignore_malformed": false, "format": "yyyy-MM-dd HH:mm:ss.SSS z", "precision_step": 4, "type": "date" }
233                         },
234             "_all": { "enabled": true } }
235                 },
236         "aliases": { "last_3_months": {}}}' http://#{node['Nodes']['ES']}:9200/_template/audit_template
237         EOH
238 end
239
240 bash "set default index for Kibana" do
241         code <<-EOH
242         curl -XPUT http://#{node['Nodes']['ES']}:9200/.kibana/index-pattern/auditingevents-* -d '{"title" : "events-*",  "timeFieldName": "TIMESTAMP"}'
243         curl -XPUT http://#{node['Nodes']['ES']}:9200/.kibana/config/4.3.3 -d '{"defaultIndex" : "auditingevents-*"}'
244     EOH
245 end