From 015ddb6e379c89e57dbd4274505725c49e4985f8 Mon Sep 17 00:00:00 2001
From: Doug Szumski <doug@stackhpc.com>
Date: Wed, 19 Jun 2019 16:23:17 +0100
Subject: [PATCH] Enable InfluxDB TSI by default

The TSI is recommended for all users. Some of the key benefits are
a reduction in memory requirements and an increase in the maximum
number of time series. For more information see this link:

https://docs.influxdata.com/influxdb/v1.7/concepts/tsi-details/

Change-Id: I4b29eb5a4ae82f6c39059d0b6de41debdfd75508
---
 ansible/roles/influxdb/defaults/main.yml               |  8 ++++++++
 ansible/roles/influxdb/templates/influxdb.conf.j2      |  5 +++++
 .../notes/enable-influxdb-tsi-858cc95e99605107.yaml    | 10 ++++++++++
 3 files changed, 23 insertions(+)
 create mode 100644 releasenotes/notes/enable-influxdb-tsi-858cc95e99605107.yaml

diff --git a/ansible/roles/influxdb/defaults/main.yml b/ansible/roles/influxdb/defaults/main.yml
index f6e8596bbc..9d5d914f4a 100644
--- a/ansible/roles/influxdb/defaults/main.yml
+++ b/ansible/roles/influxdb/defaults/main.yml
@@ -25,6 +25,14 @@ influxdb_services:
         external: false
         port: "{{ influxdb_http_port }}"
 
+####################
+# InfluxDB
+####################
+
+# Enable the disk based time series index (recommended for all users). For
+# more information see here:
+# https://docs.influxdata.com/influxdb/v1.7/concepts/time-series-index/
+influxdb_enable_tsi: True
 
 ####################
 # Docker
diff --git a/ansible/roles/influxdb/templates/influxdb.conf.j2 b/ansible/roles/influxdb/templates/influxdb.conf.j2
index e372373267..93f5e82494 100644
--- a/ansible/roles/influxdb/templates/influxdb.conf.j2
+++ b/ansible/roles/influxdb/templates/influxdb.conf.j2
@@ -11,6 +11,11 @@ reporting-disabled = true
   wal-dir = "/var/lib/influxdb/wal"
   wal-logging-enabled = true
   data-logging-enabled = true
+{% if influxdb_enable_tsi | bool %}
+  index-version = "tsi1"
+{% else %}
+  index-version = "inmem"
+{% endif %}
 [coordinator]
   write-timeout = "10s"
   max-concurrent-queries = 0
diff --git a/releasenotes/notes/enable-influxdb-tsi-858cc95e99605107.yaml b/releasenotes/notes/enable-influxdb-tsi-858cc95e99605107.yaml
new file mode 100644
index 0000000000..5ae348c550
--- /dev/null
+++ b/releasenotes/notes/enable-influxdb-tsi-858cc95e99605107.yaml
@@ -0,0 +1,10 @@
+---
+upgrade:
+  - InfluxDB TSI has been enabled by default. It is recommended for all
+    customers by InfluxData. If you do not want to enable it you can set
+    the variable 'influxdb_enable_tsi' to 'False' in 'globals.yml'.
+    Instructions to migrate existing data to the new, disk based format
+    can be found at
+    https://docs.influxdata.com/influxdb/v1.7/administration/upgrading/
+    If you do not follow the migration proceedure, InfluxDB should continue
+    to work, but this is not recommended.