Skip to content

Commit

Permalink
[task_panels] Improve the build of Kibiter URL to create the .kibana …
Browse files Browse the repository at this point in the history
…index

Use global constants to define the Kibiter URL to create the .kibana index.
Manage the exception if the URL call fails.
  • Loading branch information
Alvaro del Castillo committed Jan 27, 2018
1 parent 518b5a5 commit 2bdaf2b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions mordred/task_panels.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@

# Header mandatory in Ellasticsearc 6 (optional in earlier versions)
ES6_HEADER = {"Content-Type": "application/json"}
ES6_KIBANA_INIT_DATA = '{"value": "*"}'
ES6_KIBANA_INIT_URL_PATH = "/api/kibana/settings/indexPattern:placeholder"


def es_version(url):
Expand Down Expand Up @@ -172,17 +174,16 @@ def __configure_kibiter(self):
# Force the creation of the .kibana index
# We don't have this data so it just works for this value
k6_init_url = self.conf['panels']["kibiter_url"]
k6_init_url += "/api/kibana/settings/indexPattern:placeholder"
k6_init_data = '{"value": "*"}'
k6_init_url += ES6_KIBANA_INIT_URL_PATH
k6_init_headers = {
"Accept": "application/json",
"Content-Type": "application/json",
"kbn-version": self.conf['panels']['kibiter_version']
}

res = requests.post(k6_init_url, headers=k6_init_headers,
data=k6_init_data)
try:
res = requests.post(k6_init_url, headers=k6_init_headers,
data=ES6_KIBANA_INIT_DATA)
res.raise_for_status()
except Exception as ex:
logger.error("Can not create the .kibana in ES6 %s", ex)
Expand Down

0 comments on commit 2bdaf2b

Please sign in to comment.