Parse both new and old ES timestamp formats
The new ElasticSearch uses the +00:00 notation instead of 'Z' to signify the timezone. Since we have both old and new data this change is backward compatible. Change-Id: Iaccb6a21b6929826e08f3adfc0b601e4a90fa4d5 Note: this patch assumes the timezone is always +00:00
This commit is contained in:
parent
314a18a193
commit
2cc815ca20
@ -68,8 +68,15 @@ def all_fails(classifier):
|
||||
# gate. Would be nice if there was a zuul attr for this in es.
|
||||
if re.search("(^openstack/|devstack|grenade)", result.project):
|
||||
name = result.build_name
|
||||
timestamp = time.strptime(result.timestamp,
|
||||
"%Y-%m-%dT%H:%M:%S.%fZ")
|
||||
if "+00:00" in result.timestamp:
|
||||
# Newer ES adds timezone into the timestamp, and it will
|
||||
# always be +00:00
|
||||
timestamp = time.strptime(result.timestamp,
|
||||
"%Y-%m-%dT%H:%M:%S.%f+00:00")
|
||||
else:
|
||||
timestamp = time.strptime(result.timestamp,
|
||||
"%Y-%m-%dT%H:%M:%S.%fZ")
|
||||
|
||||
log = result.log_url.split("console.html")[0]
|
||||
all_fails["%s.%s" % (build, name)] = {
|
||||
'log': log,
|
||||
|
@ -109,7 +109,12 @@ class FacetSet(dict):
|
||||
def _histogram(self, data, facet, res=3600):
|
||||
"""A preprocessor for data should we want to bucket it."""
|
||||
if facet == "timestamp":
|
||||
ts = datetime.datetime.strptime(data, "%Y-%m-%dT%H:%M:%S.%fZ")
|
||||
if "+00:00" in data:
|
||||
ts = datetime.datetime.strptime(data,
|
||||
"%Y-%m-%dT%H:%M:%S.%f+00:00")
|
||||
else:
|
||||
ts = datetime.datetime.strptime(data, "%Y-%m-%dT%H:%M:%S.%fZ")
|
||||
|
||||
tsepoch = int(time.mktime(ts.timetuple()))
|
||||
# take the floor based on resolution
|
||||
ts -= datetime.timedelta(
|
||||
|
Loading…
Reference in New Issue
Block a user