Introduction of external URLs
[aai/sparky-fe.git] / scripts / elasticsearch / commands.txt
1
2 ElasticSearch Configuration:
3 ============================
4
5 1. Verify that your ElasticSearch instance configuation contains the following cors parameters in the elasticsearch.yaml file.  The CORS
6    workaround has proven to work for Firefox, Chrome, and Opera.
7
8 http.cors.enabled: true
9 http.cors.allow-origin: "/.*/"
10 http.cors.allow-headers: ["X-Requested-With", "Content-Type", "Content-Length"]
11 http.cors.allow-credentials: true
12
13 2. Start up Elastic Search by running running the elasticsearch.bat in the elasticsearch 2.3.1 bin folder.
14
15 If you want to do a cleanup before running these instructions, then you can execute this
16 optional command which will destroy the index settings and data.
17
18 curl -XDELETE "http://localhost:9200/auditdata?pretty"
19
20 Expected Result:
21 {
22   "acknowledged" : true
23 }
24
25
26 ElasticSearch Index Setup and Bulk Load Instructions:
27 =====================================================
28
29 1.   Configure Elastic Search Index
30
31 curl -XPUT localhost:9200/auditdata?pretty --data-binary @auditdataConfigSettings.json
32
33 Expected Result:
34 {
35   "acknowledged" : true
36 }
37
38 2.   Prepare elastic search bulk import:
39
40 prepareElasticSearchBulkImport.pl sampleAuditLog5.csv auditBulkLoad.json
41
42 curl -XPUT localhost:9200/_bulk?pretty --data-binary @auditBulkLoad.json
43
44 At the top of the output verify if there any import errors by looking at the errors field.
45
46 Expected Result:
47 {
48   "took" : 103,
49   "errors" : false,  <-------- this field is important.  if true you need to look at the output, otherwise you can ignore it
50   "items" : [ {
51     "create" : {
52       "_index" : "auditdata",
53       "_type" : "everything",
54       "_id" : "AVXN0g6Ve6sNoEtMKGxy",
55       "_version" : 1,
56       "_shards" : {
57         "total" : 2,
58         "successful" : 1,
59         "failed" : 0
60       },
61       "status" : 201
62     }
63
64
65
66 3.   Verify that auditdata index contains data
67
68 curl -XGET http://localhost:9200/_cat/indices?v
69
70 Expected Result:
71
72 health status index                   pri rep docs.count docs.deleted store.size pri.store.size
73 yellow open   auditdata                 5   1        250            0     85.2kb         85.2kb
74
75 4.   Verify configuration of elastic search index parameter settings:
76
77 curl -XGET http://localhost:9200/auditdata?pretty
78
79 Expected Result:
80 {
81   "auditdata" : {
82     "aliases" : { },
83     "mappings" : {
84       "everything" : {
85         "properties" : {
86           "date" : {
87             "type" : "date",
88             "format" : "MMM d y HH:m:s||dd-MM-yyyy HH:mm:ss||yyyy-MM-dd'T'HH:mm:ss.SSSZZ||MM/dd/yyyy"
89           },
90           "entityKey" : {
91             "type" : "string"
92           },
93           "entityType" : {
94             "type" : "string"
95           },
96           "message" : {
97             "type" : "string"
98           },
99           "severity" : {
100             "type" : "string"
101           },
102           "status" : {
103             "type" : "string"
104           }
105         }
106       },
107       "auditdata" : {
108         "properties" : {
109           "date" : {
110             "type" : "date",
111             "format" : "MMM d y HH:m:s||dd-MM-yyyy HH:mm:ss||yyyy-MM-dd'T'HH:mm:ss.SSSZZ||MM/dd/yyyy"
112           },
113           "entityKey" : {
114             "type" : "string"
115           },
116           "entityType" : {
117             "type" : "string"
118           },
119           "message" : {
120             "type" : "string"
121           },
122           "severity" : {
123             "type" : "string"
124           },
125           "status" : {
126             "type" : "string"
127           }
128         }
129       }
130     },
131     "settings" : {
132       "index" : {
133         "creation_date" : "1468250773569",
134         "number_of_shards" : "5",
135         "number_of_replicas" : "1",
136         "uuid" : "IgJe5PZyQmSfCLzuxm3Ulw",
137         "version" : {
138           "created" : "2030199"
139         }
140       }
141     },
142     "warmers" : { }
143   }
144 }
145
146 5.   Test that you can retrieve data:
147
148 curl -XGET "http://localhost:9200/auditdata/_search/?size=3&pretty"
149
150 Expected Result:
151 {
152   "took" : 8,
153   "timed_out" : false,
154   "_shards" : {
155     "total" : 5,
156     "successful" : 5,
157     "failed" : 0
158   },
159   "hits" : {
160     "total" : 250,
161     "max_score" : 1.0,
162     "hits" : [ {
163       "_index" : "auditdata",
164       "_type" : "everything",
165       "_id" : "AVXakQNNe6sNoEtMKG1y",
166       "_score" : 1.0,
167       "_source" : {
168         "date" : "May 26 2016 15:24:13",
169         "severity" : "CRITICAL",
170         "entityType" : "vpls-pe",
171         "entityKey" : "sfcca303vr1",
172         "status" : "prov-status=[ACTIVE]",
173         "message" : "Invalid prov-status value. Must have a value not equal to ACTIVE/active."
174       }
175     },{
176       "_index" : "auditdata",
177       "_type" : "everything",
178       "_id" : "AVXakQNNe6sNoEtMKG13",
179       "_score" : 1.0,
180       "_source" : {
181         "date" : "May 26 2016 15:24:13",
182         "severity" : "CRITICAL",
183         "entityType" : "vpe",
184         "entityKey" : "VPESAT-ashah401me6",
185         "status" : "prov-status=[NULL]",
186         "message" : "Invalid prov-status value. Must have a value not equal to ACTIVE/active."
187       }
188     },{
189       "_index" : "auditdata",
190       "_type" : "everything",
191       "_id" : "AVXakQNNe6sNoEtMKG17",
192       "_score" : 1.0,
193       "_source" : {
194         "date" : "May 26 2016 15:24:13",
195         "severity" : "CRITICAL",
196         "entityType" : "vpe",
197         "entityKey" : "VPESAT-eshah401me6",
198         "status" : "prov-status=[]",
199         "message" : "Invalid prov-status value. Must have a value not equal to ACTIVE/active."
200       }
201     } ]
202   }
203 }
204
205