Skip to content

Commit

Permalink
Error Handling for Mapping/Dashboard Import
Browse files Browse the repository at this point in the history
Have to wait for the service to start so the initial kibana index gets
created.
  • Loading branch information
Travis Smith authored and Travis Smith committed Jul 13, 2017
1 parent 5c4da11 commit 3430bb5
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions install/kibana.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
import os
import shutil
import sys

from elasticsearch import Elasticsearch
from time import sleep

import hashCheck

Expand Down Expand Up @@ -87,11 +86,21 @@ def install(chosenInterfaceIP):
for file in os.listdir(dashboardPath):
importDashboard(os.path.join(dashboardPath, file))
#Set logstash-* as the default Kibana index
from elasticsearch import Elasticsearch
esService = Elasticsearch()
body = {'doc' : {'defaultIndex': 'logstash-*'}}
esService.update(index='.kibana', id='5.5.0', doc_type='config', body=body)
while True:

try:
esService.update(index='.kibana', id='5.5.0', doc_type='config', body=body)
break
except:
print "Waiting for Elasticsearch to start..."
sleep(10)


def importDashboard(jsonFileName):
from elasticsearch import Elasticsearch
esService = Elasticsearch()
with open(jsonFileName) as kibana_file:
dashboardJson = json.load(kibana_file)
Expand All @@ -100,6 +109,7 @@ def importDashboard(jsonFileName):


def importIndexMapping(jsonFileName):
from elasticsearch import Elasticsearch
esService = Elasticsearch()
with open(jsonFileName) as kibanaFile:
jsonString = kibanaFile.read()
Expand Down

0 comments on commit 3430bb5

Please sign in to comment.