diff --git a/monasca_persister/conf/influxdb.py b/monasca_persister/conf/influxdb.py index f0fef3a0..1f3020e7 100644 --- a/monasca_persister/conf/influxdb.py +++ b/monasca_persister/conf/influxdb.py @@ -27,6 +27,9 @@ influxdb_opts = [ help='Default retention period in hours for new ' 'databases automatically created by the persister', default=0), + cfg.IntOpt('batch_size', + help='Maximum size of the batch to write to the database.', + default=10000), cfg.HostAddressOpt('ip_address', help='Valid IP address or hostname ' 'to InfluxDB instance'), diff --git a/monasca_persister/repositories/influxdb/abstract_repository.py b/monasca_persister/repositories/influxdb/abstract_repository.py index ccc69a66..90aace7e 100644 --- a/monasca_persister/repositories/influxdb/abstract_repository.py +++ b/monasca_persister/repositories/influxdb/abstract_repository.py @@ -52,9 +52,11 @@ class AbstractInfluxdbRepository(abstract_repository.AbstractRepository): # NOTE (brtknr): Loop twice to ensure database is created if missing. for retry in range(2): try: + batch_size = self.conf.influxdb.batch_size self._influxdb_client.write_points(data_points, 'ms', protocol='line', - database=database) + database=database, + batch_size=batch_size) break except influxdb.exceptions.InfluxDBClientError as ex: # When a databse is not found, the returned exception resolves diff --git a/releasenotes/notes/add_influxb_batch_size-01b7a476b6bd8a81.yaml b/releasenotes/notes/add_influxb_batch_size-01b7a476b6bd8a81.yaml new file mode 100644 index 00000000..8eeb5133 --- /dev/null +++ b/releasenotes/notes/add_influxb_batch_size-01b7a476b6bd8a81.yaml @@ -0,0 +1,6 @@ +--- +features: + - | + Configuration option `batch_size` for InfluxDB to control the maximum + size of batches written to the database. Default value set to 10 000 data + points.