Skip to content

Commit eecc87b

Browse files
committed
Add .kibana index conversion to v6
1 parent 424f19b commit eecc87b

File tree

1 file changed

+295
-0
lines changed

1 file changed

+295
-0
lines changed

jobs/kibana/templates/bin/kibana_ctl

Lines changed: 295 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,298 @@ function wait_for_template {
2929
set -e
3030
}
3131

32+
function convert_kibana_index {
33+
# do the migration as per https://www.elastic.co/guide/en/kibana/6.0/migrating-6.0-index.html#migrating-6.0-index
34+
curl -X PUT "localhost:9200/.kibana/_settings" -H 'Content-Type: application/json' -d'{"index.blocks.write": true}'
35+
curl -X PUT "localhost:9200/.kibana-6" -H 'Content-Type: application/json' -d'
36+
{
37+
"settings" : {
38+
"number_of_shards" : 1,
39+
"index.mapper.dynamic": false
40+
},
41+
"mappings" : {
42+
"doc": {
43+
"properties": {
44+
"type": {
45+
"type": "keyword"
46+
},
47+
"updated_at": {
48+
"type": "date"
49+
},
50+
"config": {
51+
"properties": {
52+
"buildNum": {
53+
"type": "keyword"
54+
}
55+
}
56+
},
57+
"index-pattern": {
58+
"properties": {
59+
"fieldFormatMap": {
60+
"type": "text"
61+
},
62+
"fields": {
63+
"type": "text"
64+
},
65+
"intervalName": {
66+
"type": "keyword"
67+
},
68+
"notExpandable": {
69+
"type": "boolean"
70+
},
71+
"sourceFilters": {
72+
"type": "text"
73+
},
74+
"timeFieldName": {
75+
"type": "keyword"
76+
},
77+
"title": {
78+
"type": "text"
79+
}
80+
}
81+
},
82+
"visualization": {
83+
"properties": {
84+
"description": {
85+
"type": "text"
86+
},
87+
"kibanaSavedObjectMeta": {
88+
"properties": {
89+
"searchSourceJSON": {
90+
"type": "text"
91+
}
92+
}
93+
},
94+
"savedSearchId": {
95+
"type": "keyword"
96+
},
97+
"title": {
98+
"type": "text"
99+
},
100+
"uiStateJSON": {
101+
"type": "text"
102+
},
103+
"version": {
104+
"type": "integer"
105+
},
106+
"visState": {
107+
"type": "text"
108+
}
109+
}
110+
},
111+
"search": {
112+
"properties": {
113+
"columns": {
114+
"type": "keyword"
115+
},
116+
"description": {
117+
"type": "text"
118+
},
119+
"hits": {
120+
"type": "integer"
121+
},
122+
"kibanaSavedObjectMeta": {
123+
"properties": {
124+
"searchSourceJSON": {
125+
"type": "text"
126+
}
127+
}
128+
},
129+
"sort": {
130+
"type": "keyword"
131+
},
132+
"title": {
133+
"type": "text"
134+
},
135+
"version": {
136+
"type": "integer"
137+
}
138+
}
139+
},
140+
"dashboard": {
141+
"properties": {
142+
"description": {
143+
"type": "text"
144+
},
145+
"hits": {
146+
"type": "integer"
147+
},
148+
"kibanaSavedObjectMeta": {
149+
"properties": {
150+
"searchSourceJSON": {
151+
"type": "text"
152+
}
153+
}
154+
},
155+
"optionsJSON": {
156+
"type": "text"
157+
},
158+
"panelsJSON": {
159+
"type": "text"
160+
},
161+
"refreshInterval": {
162+
"properties": {
163+
"display": {
164+
"type": "keyword"
165+
},
166+
"pause": {
167+
"type": "boolean"
168+
},
169+
"section": {
170+
"type": "integer"
171+
},
172+
"value": {
173+
"type": "integer"
174+
}
175+
}
176+
},
177+
"timeFrom": {
178+
"type": "keyword"
179+
},
180+
"timeRestore": {
181+
"type": "boolean"
182+
},
183+
"timeTo": {
184+
"type": "keyword"
185+
},
186+
"title": {
187+
"type": "text"
188+
},
189+
"uiStateJSON": {
190+
"type": "text"
191+
},
192+
"version": {
193+
"type": "integer"
194+
}
195+
}
196+
},
197+
"url": {
198+
"properties": {
199+
"accessCount": {
200+
"type": "long"
201+
},
202+
"accessDate": {
203+
"type": "date"
204+
},
205+
"createDate": {
206+
"type": "date"
207+
},
208+
"url": {
209+
"type": "text",
210+
"fields": {
211+
"keyword": {
212+
"type": "keyword",
213+
"ignore_above": 2048
214+
}
215+
}
216+
}
217+
}
218+
},
219+
"server": {
220+
"properties": {
221+
"uuid": {
222+
"type": "keyword"
223+
}
224+
}
225+
},
226+
"timelion-sheet": {
227+
"properties": {
228+
"description": {
229+
"type": "text"
230+
},
231+
"hits": {
232+
"type": "integer"
233+
},
234+
"kibanaSavedObjectMeta": {
235+
"properties": {
236+
"searchSourceJSON": {
237+
"type": "text"
238+
}
239+
}
240+
},
241+
"timelion_chart_height": {
242+
"type": "integer"
243+
},
244+
"timelion_columns": {
245+
"type": "integer"
246+
},
247+
"timelion_interval": {
248+
"type": "keyword"
249+
},
250+
"timelion_other_interval": {
251+
"type": "keyword"
252+
},
253+
"timelion_rows": {
254+
"type": "integer"
255+
},
256+
"timelion_sheet": {
257+
"type": "text"
258+
},
259+
"title": {
260+
"type": "text"
261+
},
262+
"version": {
263+
"type": "integer"
264+
}
265+
}
266+
},
267+
"graph-workspace": {
268+
"properties": {
269+
"description": {
270+
"type": "text"
271+
},
272+
"kibanaSavedObjectMeta": {
273+
"properties": {
274+
"searchSourceJSON": {
275+
"type": "text"
276+
}
277+
}
278+
},
279+
"numLinks": {
280+
"type": "integer"
281+
},
282+
"numVertices": {
283+
"type": "integer"
284+
},
285+
"title": {
286+
"type": "text"
287+
},
288+
"version": {
289+
"type": "integer"
290+
},
291+
"wsState": {
292+
"type": "text"
293+
}
294+
}
295+
}
296+
}
297+
}
298+
}
299+
}
300+
'
301+
curl -X POST "localhost:9200/_reindex" -H 'Content-Type: application/json' -d'
302+
{
303+
"source": {
304+
"index": ".kibana"
305+
},
306+
"dest": {
307+
"index": ".kibana-6"
308+
},
309+
"script": {
310+
"inline": "ctx._source = [ ctx._type : ctx._source ]; ctx._source.type = ctx._type; ctx._id = ctx._type + \":\" + ctx._id; ctx._type = \"doc\"; ",
311+
"lang": "painless"
312+
}
313+
}
314+
'
315+
curl -X POST "localhost:9200/_aliases" -H 'Content-Type: application/json' -d'
316+
{
317+
"actions" : [
318+
{ "add": { "index": ".kibana-6", "alias": ".kibana" } },
319+
{ "remove_index": { "index": ".kibana" } }
320+
]
321+
}
322+
'
323+
}
32324

33325
case $1 in
34326

@@ -63,6 +355,9 @@ case $1 in
63355
<% end %>
64356
<% end %>
65357

358+
# convert index to new version
359+
curl -s localhost:9200/_cat/indices | awk '{print $3}'| grep .kibana-6 || convert_kibana_index
360+
66361
exec /var/vcap/packages/kibana/bin/kibana \
67362
-c $JOB_DIR/config/kibana.conf \
68363
>>$LOG_DIR/kibana.stdout.log \

0 commit comments

Comments
 (0)