Skip to content

Commit

Permalink
Added support for passing retention policies to the plugin
Browse files Browse the repository at this point in the history
Updated copy for retention policy settings

Removed an extra parenthesis

Cleanup

Additional copy cleanup

Copy cleanup
  • Loading branch information
Bailey Dickens committed Oct 10, 2020
1 parent bb0facf commit 27c011d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
5 changes: 3 additions & 2 deletions octoprint_influxdb/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ def add_arg_if_exists(kwargsname, path, getter=self._settings.get):
if self.influx_db:
self.influx_kwargs = kwargs
self.influx_prefix = self._settings.get(['prefix']) or ''
self.influx_retention_policy = self._settings.get(['retention_policy']) or None

# start a new timer
if self.influx_db:
Expand Down Expand Up @@ -208,7 +209,7 @@ def influx_emit(self, measurement, fields, extra_tags={}):
'fields': fields,
}
try:
self.influx_db.write_points([point])
self.influx_db.write_points([point], retention_policy=self.influx_retention_policy)
except Exception:
# we were dropped! try to reconnect
self.influx_flash_exception("Disconnected from InfluxDB. Attempting to reconnect.")
Expand Down Expand Up @@ -320,7 +321,7 @@ def get_settings_defaults(self):
hostcustom='octoprint',
username=None,
password=None,

retention_policy=None,
interval=1,
)

Expand Down
12 changes: 11 additions & 1 deletion octoprint_influxdb/templates/influxdb_settings.jinja2
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,24 @@

<br>

<label class="control-label">{{ _('Retention Policy') }}</label>
<div class="controls">
<input type="text" class="input-medium" placeholder="None" data-bind="value: settings.plugins.influxdb.retention_policy">
<span class="help-block">
{{ _('If not specified the default policy of None will be used. The retention policy must be created on the database before setting this value.') }}
</span>
</div>

<br>

<label class="control-label">{{ _('Prefix') }}</label>
<div class="controls">
<input type="text" class="input-medium" placeholder="(no prefix)" data-bind="value: settings.plugins.influxdb.prefix">
<span class="help-block">
{{ _('Measurement names will be prefixed by this string. Helpful when sharing a database.') }}
</span>
</div>

<label class="control-label">{{ _('%(host)s Tag', host='<tt>host</tt>') }}</label>
<div class="controls">
<label class="radio">
Expand Down

0 comments on commit 27c011d

Please sign in to comment.