Skip to content

Commit

Permalink
elasticsearch: fix index creation
Browse files Browse the repository at this point in the history
  • Loading branch information
Corentin Chary authored and iksaif committed Jul 11, 2018
1 parent 4efca55 commit 0269089
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions biggraphite/drivers/elasticsearch.py
Expand Up @@ -58,9 +58,9 @@
"index": {
"number_of_shards": 3,
"number_of_replicas": 1,
"refresh_interval": 60,
"refresh_interval": "60s",
"translog": {
"sync_interval": 120,
"sync_interval": "120s",
"durability": "async",
},
"search": {
Expand Down Expand Up @@ -394,12 +394,15 @@ def get_index(self, metric):
# metric metadata, for example, per owner.
index_name = self._index_prefix + datetime.datetime.now().strftime(self._index_suffix)
if index_name not in self._known_indices:
self.client.indices.create(
index=index_name,
body=INDEX_SETTINGS,
ignore=400
)
if not self.client.indices.exists(index=index_name):
self.client.indices.create(
index=index_name,
body=INDEX_SETTINGS,
ignore=409
)
self.client.indices.flush()
self._known_indices[index_name] = True

return index_name

def insert_points_async(self, metric, datapoints, on_done=None):
Expand Down

0 comments on commit 0269089

Please sign in to comment.