Petr Michalec | 5fc2058 | 2017-12-11 15:00:38 +0100 | [diff] [blame] | 1 | {%- from "influxdb/map.jinja" import client with context %} |
| 2 | |
| 3 | {%- if client.get('enabled') %} |
| 4 | {# CUSTOM QUERIES, intended to be called by salt_id #} |
| 5 | |
| 6 | {%- set mconf = pillar.salt.minion.get('config', {}).get('influxdb') %} |
| 7 | |
| 8 | {%- for db_name,db in client.get('database', {}).iteritems() %} |
| 9 | {%- set db_name = db.get('name', db_name) %} |
| 10 | {%- for qr_name,qr in db.get('query', {}).iteritems() %} |
| 11 | |
| 12 | {%- if qr is string %} |
| 13 | {%- set query = { 'query': qr } %} |
| 14 | {%- endif %} |
| 15 | |
| 16 | influxdb_query_{{ db_name }}_{{ qr_name }}: |
| 17 | module.run: |
| 18 | influxdb.query: |
| 19 | - database: {{ db_name }} |
| 20 | - query: {{ query }} |
Petr Michalec | 5e2d4d0 | 2017-12-12 16:43:34 +0100 | [diff] [blame] | 21 | - host: {{ mconf.host }} |
| 22 | - port: {{ mconf.port }} |
| 23 | {%- if qr.user is defined OR mconf.password is defined %} |
| 24 | - user: {{ qr.get('user', mconf.user) }} |
| 25 | {%- endif %} |
| 26 | {%- if qr.password is defined OR mconf.password is defined %} |
| 27 | - password: {{ qr.get('password', mconf.password) }} |
Petr Michalec | 5fc2058 | 2017-12-11 15:00:38 +0100 | [diff] [blame] | 28 | {%- endif %} |
| 29 | {%- endfor %} |
| 30 | {%- endfor %} |
| 31 | |