Filip Pytloun | d6fa6ab | 2016-08-03 15:59:49 +0200 | [diff] [blame] | 1 | |
| 2 | ======== |
| 3 | InfluxDB |
| 4 | ======== |
| 5 | |
| 6 | InfluxData is based on the TICK stack, the first open source platform for managing IoT time-series data at scale. |
| 7 | |
| 8 | Sample pillars |
| 9 | ============== |
| 10 | |
| 11 | Single-node influxdb, enabled http frontend and admin web interface: |
| 12 | |
| 13 | .. code-block:: yaml |
| 14 | |
| 15 | influxdb: |
| 16 | server: |
| 17 | enabled: true |
| 18 | http: |
| 19 | enabled: true |
| 20 | bind: |
| 21 | address: 0.0.0.0 |
| 22 | port: 8086 |
| 23 | admin: |
| 24 | enabled: true |
| 25 | bind: |
| 26 | address: 0.0.0.0 |
| 27 | port: 8083 |
| 28 | |
| 29 | Single-node influxdb, SSL for http frontend: |
| 30 | |
| 31 | .. code-block:: yaml |
| 32 | |
| 33 | influxdb: |
| 34 | server: |
| 35 | enabled: true |
| 36 | http: |
| 37 | bind: |
| 38 | ssl: |
| 39 | enabled: true |
| 40 | key_file: /etc/influxdb/ssl/key.pem |
| 41 | cert_file: /etc/influxdb/ssl/cert.pem |
| 42 | |
abednarik | 61b864c | 2017-09-19 08:08:25 -0300 | [diff] [blame] | 43 | Single-node influxdb where you specify paths for data and metastore directories. Custom |
| 44 | directories are created by this formula: |
Guillaume Thouvenin | 1091d46 | 2016-11-14 11:53:10 +0100 | [diff] [blame] | 45 | |
| 46 | .. code-block:: yaml |
| 47 | |
| 48 | influxdb: |
| 49 | server: |
| 50 | enabled: true |
| 51 | data: |
| 52 | dir: '/opt/influxdb/data' |
| 53 | wal_dir: '/opt/influxdb/wal' |
| 54 | meta: |
| 55 | dir: '/opt/influxdb/meta' |
| 56 | |
Simon Pasquier | 8fa8f71 | 2017-06-22 12:04:05 +0200 | [diff] [blame] | 57 | InfluxDB server with customized parameters for the data service: |
| 58 | |
| 59 | .. code-block:: yaml |
| 60 | |
| 61 | influxdb: |
| 62 | server: |
| 63 | enabled: true |
| 64 | data: |
| 65 | max_series_per_database: 20000000 |
Simon Pasquier | 9ae08ff | 2017-06-22 12:28:29 +0200 | [diff] [blame] | 66 | cache_max_memory_size: 524288000 |
| 67 | cache_snapshot_memory_size: 26214400 |
| 68 | cache_snapshot_write_cold_duration: "5m" |
| 69 | compact_full_write_cold_duration: "2h"2h" |
| 70 | max_values_per_tag: 5000 |
Simon Pasquier | 8fa8f71 | 2017-06-22 12:04:05 +0200 | [diff] [blame] | 71 | |
Guillaume Thouvenin | 071a93e | 2016-10-24 17:22:23 +0200 | [diff] [blame] | 72 | Single-node influxdb with an admin user: |
| 73 | |
| 74 | .. code-block:: yaml |
| 75 | |
| 76 | influxdb: |
| 77 | server: |
| 78 | enabled: true |
| 79 | http: |
| 80 | enabled: true |
| 81 | bind: |
| 82 | address: 0.0.0.0 |
| 83 | port: 8086 |
| 84 | admin: |
| 85 | enabled: true |
| 86 | bind: |
| 87 | address: 0.0.0.0 |
| 88 | port: 8083 |
| 89 | user: |
| 90 | enabled: true |
| 91 | name: root |
| 92 | password: secret |
| 93 | |
| 94 | Single-node influxdb with new users: |
| 95 | |
| 96 | .. code-block:: yaml |
| 97 | |
| 98 | influxdb: |
| 99 | server: |
| 100 | user: |
| 101 | user1: |
| 102 | enabled: true |
| 103 | admin: true |
| 104 | name: username1 |
| 105 | password: keepsecret1 |
| 106 | user2: |
| 107 | enabled: true |
| 108 | admin: false |
| 109 | name: username2 |
| 110 | password: keepsecret2 |
| 111 | |
| 112 | Single-node influxdb with new databases: |
| 113 | |
| 114 | .. code-block:: yaml |
| 115 | |
| 116 | influxdb: |
| 117 | server: |
| 118 | database: |
| 119 | mydb1: |
| 120 | enabled: true |
| 121 | name: mydb1 |
| 122 | mydb2: |
| 123 | enabled: true |
| 124 | name: mydb2 |
| 125 | |
Swann Croiset | 1eaf361 | 2016-12-02 14:42:48 +0100 | [diff] [blame] | 126 | Manage the retention policies for a database: |
| 127 | |
| 128 | .. code-block:: yaml |
| 129 | |
| 130 | influxdb: |
| 131 | server: |
| 132 | database: |
| 133 | mydb1: |
| 134 | enabled: true |
| 135 | name: mydb1 |
| 136 | retention_policy: |
| 137 | - name: rp_db1 |
| 138 | duration: 30d |
| 139 | replication: 1 |
| 140 | is_default: true |
| 141 | |
| 142 | Where default values are: |
| 143 | |
| 144 | * name = autogen |
| 145 | * duration = INF |
| 146 | * replication = 1 |
| 147 | * is_default: false |
| 148 | |
| 149 | |
Guillaume Thouvenin | 071a93e | 2016-10-24 17:22:23 +0200 | [diff] [blame] | 150 | Here is how to manage grants on database: |
| 151 | |
| 152 | .. code-block:: yaml |
| 153 | |
| 154 | influxdb: |
| 155 | server: |
| 156 | grant: |
| 157 | username1_mydb1: |
| 158 | enabled: true |
| 159 | user: username1 |
| 160 | database: mydb1 |
| 161 | privilege: all |
| 162 | username2_mydb1: |
| 163 | enabled: true |
| 164 | user: username2 |
| 165 | database: mydb1 |
| 166 | privilege: read |
| 167 | username2_mydb2: |
| 168 | enabled: true |
| 169 | user: username2 |
| 170 | database: mydb2 |
| 171 | privilege: write |
| 172 | |
Filip Pytloun | d6fa6ab | 2016-08-03 15:59:49 +0200 | [diff] [blame] | 173 | InfluxDB relay: |
| 174 | |
| 175 | .. code-block:: yaml |
| 176 | |
| 177 | influxdb: |
| 178 | server: |
| 179 | enabled: true |
| 180 | http: |
| 181 | enabled: true |
| 182 | output: |
| 183 | idb01: |
| 184 | location: http://idb01.local:8086/write |
| 185 | timeout: 10 |
| 186 | idb02: |
| 187 | location: http://idb02.local:8086/write |
| 188 | timeout: 10 |
| 189 | udp: |
| 190 | enabled: true |
| 191 | output: |
| 192 | idb01: |
| 193 | location: idb01.local:9096 |
| 194 | idb02: |
| 195 | location: idb02.local:9096 |
| 196 | |
Filip Pytloun | e93852a | 2016-08-03 16:42:42 +0200 | [diff] [blame] | 197 | InfluxDB cluster: |
| 198 | |
| 199 | .. code-block:: yaml |
| 200 | |
| 201 | influxdb: |
| 202 | server: |
| 203 | enabled: true |
| 204 | meta: |
| 205 | bind: |
| 206 | address: 0.0.0.0 |
| 207 | port: 8088 |
| 208 | http_address: 0.0.0.0 |
| 209 | http_port: 8091 |
| 210 | cluster: |
| 211 | members: |
| 212 | - host: idb01.local |
| 213 | port: 8091 |
| 214 | - host: idb02.local |
| 215 | port: 8091 |
| 216 | - host: idb03.local |
| 217 | port: 8091 |
| 218 | |
Filip Pytloun | d6fa6ab | 2016-08-03 15:59:49 +0200 | [diff] [blame] | 219 | Deploy influxdb apt repository (using linux formula): |
| 220 | |
| 221 | .. code-block:: yaml |
| 222 | |
| 223 | linux: |
| 224 | system: |
| 225 | os: ubuntu |
| 226 | dist: xenial |
Guillaume Thouvenin | fa42e98 | 2016-10-21 12:23:23 +0200 | [diff] [blame] | 227 | repo: |
| 228 | influxdb: |
| 229 | enabled: true |
| 230 | source: 'deb https://repos.influxdata.com/${linux:system:os} ${linux:system:dist} stable' |
| 231 | key_url: 'https://repos.influxdata.com/influxdb.key' |
Filip Pytloun | d6fa6ab | 2016-08-03 15:59:49 +0200 | [diff] [blame] | 232 | |
Simon Pasquier | f616965 | 2017-07-17 14:04:19 +0200 | [diff] [blame] | 233 | InfluxDB client for configuring databases, users and retention policies: |
| 234 | |
| 235 | .. code-block:: yaml |
| 236 | |
| 237 | influxdb: |
| 238 | client: |
| 239 | enabled: true |
| 240 | server: |
| 241 | protocol: http |
| 242 | host: 127.0.0.1 |
| 243 | port: 8086 |
| 244 | user: admin |
| 245 | password: foobar |
| 246 | user: |
| 247 | user1: |
| 248 | enabled: true |
| 249 | admin: true |
| 250 | name: username1 |
| 251 | database: |
| 252 | mydb1: |
| 253 | enabled: true |
| 254 | name: mydb1 |
| 255 | retention_policy: |
| 256 | - name: rp_db1 |
| 257 | duration: 30d |
| 258 | replication: 1 |
| 259 | is_default: true |
| 260 | grant: |
| 261 | username1_mydb1: |
| 262 | enabled: true |
| 263 | user: username1 |
| 264 | database: mydb1 |
| 265 | privilege: all |
| 266 | |
Petr Michalec | 81e6bc5 | 2018-01-09 16:48:03 +0100 | [diff] [blame] | 267 | InfluxDB client state's that uses curl can be forced to retry query if curl call fails: |
| 268 | |
| 269 | .. code-block:: yaml |
| 270 | |
| 271 | influxdb: |
| 272 | client: |
| 273 | enabled: true |
| 274 | retry: |
| 275 | count: 3 |
| 276 | delay: 3 |
Petr Michalec | a20e499 | 2017-12-06 13:32:13 +0100 | [diff] [blame] | 277 | |
| 278 | Create an continuous queries: |
| 279 | |
| 280 | .. code-block:: yaml |
| 281 | |
| 282 | influxdb: |
| 283 | client: |
| 284 | database: |
| 285 | mydb1: |
Petr Michalec | 5fc2058 | 2017-12-11 15:00:38 +0100 | [diff] [blame] | 286 | continuous_query: |
Petr Michalec | a20e499 | 2017-12-06 13:32:13 +0100 | [diff] [blame] | 287 | cq_avg_bus_passengers: >- |
| 288 | SELECT mean("passengers") INTO "transportation"."three_weeks"."average_passengers" FROM "bus_data" GROUP BY time(1h) |
| 289 | |
Petr Michalec | b4cb8ab | 2018-02-22 16:43:14 +0100 | [diff] [blame] | 290 | |
Marek Knappe | d133489 | 2018-05-21 18:56:39 +1000 | [diff] [blame] | 291 | Example how to add options to http/udp/data/admin that are not supported by the formula yet: |
| 292 | |
| 293 | .. code-block:: yaml |
| 294 | |
| 295 | influxdb: |
| 296 | server: |
| 297 | enabled: true |
| 298 | http: |
| 299 | enabled: true |
| 300 | raw_rules: |
| 301 | - 'max-row-limit = 20000' |
| 302 | udp: |
| 303 | enabled: true |
| 304 | raw_rules: |
| 305 | - 'max-row-limit = 20000' |
| 306 | data: |
| 307 | enabled: true |
| 308 | raw_rules: |
| 309 | - 'something_else = 10' |
| 310 | admin: |
| 311 | raw_rules: |
| 312 | - 'something_here = 55' |
| 313 | |
| 314 | |
Petr Michalec | b4cb8ab | 2018-02-22 16:43:14 +0100 | [diff] [blame] | 315 | Rich example for RP and CQ for Telegraf vmstats collected: |
| 316 | |
| 317 | .. code-block:: yaml |
| 318 | |
| 319 | influxdb: |
| 320 | client: |
| 321 | database: |
| 322 | vmstats: |
| 323 | enabled: true |
| 324 | name: vmstats |
| 325 | retention_policy: |
| 326 | - name: a_week |
| 327 | duration: 10d |
| 328 | replication: 1 |
| 329 | - name: a_month |
| 330 | duration: 30d |
| 331 | replication: 1 |
| 332 | - name: a_quater |
| 333 | duration: 15w |
| 334 | replication: 1 |
| 335 | is_default: true |
| 336 | - name: a_year |
| 337 | duration: 52w |
| 338 | replication: 1 |
| 339 | - name: a_decade |
| 340 | duration: 520w |
| 341 | replication: 1 |
| 342 | continuous_query: |
| 343 | cq_ds_all_1m: >- |
| 344 | SELECT sum(*) as sum_1m, count(*) as count_1m, median(*) as median_1m, mode(*) as mode_1m, mean(*) as mean_1m, max(*) as max_1m, min(*) as min_1m INTO "vmstats"."a_week".:MEASUREMENT FRO |
| 345 | cq_ds_all_10m: >- |
| 346 | SELECT sum(*) as sum_10m, count(*) as count_10m, median(*) as median_10m, mode(*) as mode_10m, mean(*) as mean_10m, max(*) as max_10m, min(*) as min_10m INTO "vmstats"."a_month".:MEASURE |
| 347 | cq_ds_all_h: >- |
| 348 | SELECT sum(*) as sum_h, count(*) as count_h, median(*) as median_h, mode(*) as mode_h, mean(*) as mean_h, max(*) as max_h, min(*) as min_h INTO "vmstats"."a_month".:MEASUREMENT FROM /.*/ |
| 349 | cq_ds_all_d: >- |
| 350 | SELECT sum(*) as sum_d, count(*) as count_d, median(*) as median_d, mode(*) as mode_d, mean(*) as mean_d, max(*) as max_d, min(*) as min_d INTO "vmstats"."a_year".:MEASUREMENT FROM /.*/ |
| 351 | cq_ds_all_w: >- |
| 352 | SELECT sum(*) as sum_w, count(*) as count_w, median(*) as median_w, mode(*) as mode_w, mean(*) as mean_w, max(*) as max_w, min(*) as min_w INTO "vmstats"."a_year".:MEASUREMENT FROM /.*/ |
| 353 | cq_ds_all_m: >- |
| 354 | SELECT sum(*) as sum_m, count(*) as count_m, median(*) as median_m, mode(*) as mode_m, mean(*) as mean_m, max(*) as max_m, min(*) as min_m INTO "vmstats"."a_decade".:MEASUREMENT FROM /.* |
| 355 | cq_ds_all_y: >- |
| 356 | SELECT sum(*) as sum_y, count(*) as count_y, median(*) as median_y, mode(*) as mode_y, mean(*) as mean_y, max(*) as max_y, min(*) as min_y INTO "vmstats"."a_decade".:MEASUREMENT FROM /.* |
| 357 | |
| 358 | |
Petr Michalec | 5fc2058 | 2017-12-11 15:00:38 +0100 | [diff] [blame] | 359 | Prunning data and data management: |
| 360 | |
| 361 | Intended to use in scheduled jobs, executed to maintain data life cycle above retention policy. These states are executed by |
| 362 | ``query.sls`` and you are expected to trigger ``sls_id`` individually. |
| 363 | |
| 364 | .. code-block:: yaml |
| 365 | |
| 366 | influxdb: |
| 367 | client: |
| 368 | database: |
| 369 | mydb1: |
| 370 | query: |
| 371 | drop_measurement_h2o: >- |
| 372 | DROP MEASUREMENT h2o_quality |
| 373 | drop_shard_h2o: >- |
| 374 | DROP SHARD h2o_quality |
| 375 | drop_series_h2o_feet: >- |
| 376 | DROP SERIES FROM "h2o_feet" |
| 377 | drop_series_h2o_feet_loc_smonica: >- |
| 378 | DROP SERIES FROM "h2o_feet" WHERE "location" = 'santa_monica' |
| 379 | delete_h2o_quality_rt3: >- |
| 380 | DELETE FROM "h2o_quality" WHERE "randtag" = '3' |
| 381 | delete_h2o_quality: >- |
| 382 | DELETE FROM "h2o_quality" |
| 383 | |
| 384 | |
| 385 | .. code-block:: shell |
| 386 | |
| 387 | salt \* state.sls_id influxdb_query_delete_h2o_quality influxdb.query |
| 388 | |
Petr Michalec | a20e499 | 2017-12-06 13:32:13 +0100 | [diff] [blame] | 389 | |
Simon Pasquier | 6f51556 | 2017-08-29 11:55:02 +0200 | [diff] [blame] | 390 | InfluxDB relay with HTTP outputs: |
| 391 | |
| 392 | .. code-block:: yaml |
| 393 | |
| 394 | influxdb: |
| 395 | relay: |
| 396 | enabled: true |
Simon Pasquier | 9178266 | 2017-09-08 11:36:06 +0200 | [diff] [blame] | 397 | telemetry: |
| 398 | enabled: true |
| 399 | bind: |
| 400 | address: 127.0.0.1 |
| 401 | port: 9196 |
Simon Pasquier | 6f51556 | 2017-08-29 11:55:02 +0200 | [diff] [blame] | 402 | listen: |
| 403 | http_backend: |
| 404 | type: http |
| 405 | bind: |
| 406 | address: 127.0.0.1 |
| 407 | port: 9096 |
| 408 | output: |
| 409 | server1: |
| 410 | location: http://server1:8086/write |
| 411 | timeout: 20s |
| 412 | buffer_size_mb: 512 |
| 413 | max_batch_kb: 1024 |
| 414 | max_delay_interval: 30s |
| 415 | server2: |
| 416 | location: http://server2:8086/write |
Pavel Cizinsky | 2a70e41 | 2018-12-12 12:02:00 +0100 | [diff] [blame] | 417 | |
Filip Pytloun | d6fa6ab | 2016-08-03 15:59:49 +0200 | [diff] [blame] | 418 | Read more |
| 419 | ========= |
| 420 | |
| 421 | * https://influxdata.com/time-series-platform/influxdb/ |