Skip to content

Commit

Permalink
POC: use a time series data stream for metrics
Browse files Browse the repository at this point in the history
* Assumes TSDS index templates are already installed in the metricsstore
  • Loading branch information
inqueue committed May 29, 2024
1 parent fc8822e commit 9af9153
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions esrally/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -897,25 +897,27 @@ def open(self, race_id=None, race_timestamp=None, track_name=None, challenge_nam
MetricsStore.open(self, race_id, race_timestamp, track_name, challenge_name, car_name, ctx, create)
self._index = self.index_name()
# reduce a bit of noise in the metrics cluster log
if create:
# always update the mapping to the latest version
self._client.put_template("rally-metrics", self._get_template())
if not self._client.exists(index=self._index):
self._client.create_index(index=self._index)
else:
self.logger.info("[%s] already exists.", self._index)
else:
# we still need to check for the correct index name - prefer the one with the suffix
new_name = self._migrated_index_name(self._index)
if self._client.exists(index=new_name):
self._index = new_name
# if create:
# # always update the mapping to the latest version
# self._client.put_template("rally-metrics", self._get_template())
# if not self._client.exists(index=self._index):
# self._client.create_index(index=self._index)
# else:
# self.logger.info("[%s] already exists.", self._index)
# else:
# # we still need to check for the correct index name - prefer the one with the suffix
# new_name = self._migrated_index_name(self._index)
# if self._client.exists(index=new_name):
# self._index = new_name

# ensure we can search immediately after opening
self._client.refresh(index=self._index)

def index_name(self):
ts = time.from_iso8601(self._race_timestamp)
return "rally-metrics-%04d-%02d" % (ts.year, ts.month)
# ts = time.from_iso8601(self._race_timestamp)
## Tempporarily modify to use a time series data stream
# return "rally-metrics-%04d-%02d" % (ts.year, ts.month)
return "tsds-rally-metrics"

def _migrated_index_name(self, original_name):
return f"{original_name}.new"
Expand Down

0 comments on commit 9af9153

Please sign in to comment.