Skip to content

Commit

Permalink
Added fill previous to queries so that graphite calculations do not b…
Browse files Browse the repository at this point in the history
…reak due to gaps in influxdb data caused by finer group by interval than data sampling rate. Updated tests to reflect this.
  • Loading branch information
pkittenis committed Oct 26, 2016
1 parent e53831b commit 6c26680
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion influxgraph/classes/finder.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ def _gen_influxdb_query(self, start_time, end_time, paths, interval):
aggregation_func, field, field) for field in fields])
query = 'select %s from %s where (time > %ds and time <= %ds) ' % (
query_fields, measurement, start_time, end_time,)
group_by = ' GROUP BY time(%ss)' % (interval,)
group_by = ' GROUP BY time(%ss) fill(previous)' % (interval,)
if tags:
_queries = []
_query = query
Expand Down
2 changes: 1 addition & 1 deletion influxgraph/classes/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def fetch(self, start_time, end_time):
'unit_is_ms',
'what_is_query_individual_duration'])
_query = 'select %s(value) as value from "%s" where (time > %ds and ' \
'time <= %ds) GROUP BY time(%ss)' % (
'time <= %ds) GROUP BY time(%ss) fill(previous)' % (
aggregation_func, self.path, start_time, end_time, interval,)
logger.debug("fetch() path=%s querying influxdb query: '%s'",
self.path, _query)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_influxdb_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def setup_db(self):
self.assertTrue(self.client.write_points(data))

def setUp(self):
self.step, self.num_datapoints, self.db_name = 60, 2, 'integration_test'
self.step, self.num_datapoints, self.db_name = 60, 31, 'integration_test'
self.start_time, self.end_time = (datetime.datetime.utcnow() - datetime.timedelta(hours=1)), \
datetime.datetime.utcnow()
self.steps = int(round((int(self.end_time.strftime("%s")) - \
Expand Down
2 changes: 1 addition & 1 deletion tests/test_influxdb_templates_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def setUp(self):
self.measurements = ['cpu', 'memory', 'load', 'iops']
self.graphite_series = ["%s" % (".".join(
[self.tags[p] for p in self.paths] + [m])) for m in self.measurements]
self.step, self.num_datapoints, self.db_name = 60, 2, 'integration_test'
self.step, self.num_datapoints, self.db_name = 60, 31, 'integration_test'
self.start_time, self.end_time = (datetime.datetime.utcnow() - datetime.timedelta(hours=1)), \
datetime.datetime.utcnow()
self.steps = int(round((int(self.end_time.strftime("%s")) - \
Expand Down

0 comments on commit 6c26680

Please sign in to comment.