blob: a24e2fa4c190cb97e1290a05aa12ee968700ddc4 [file] [log] [blame]
Petr Michalec5fc20582017-12-11 15:00:38 +01001{%- 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
16influxdb_query_{{ db_name }}_{{ qr_name }}:
17 module.run:
18 influxdb.query:
19 - database: {{ db_name }}
20 - query: {{ query }}
21 {%- if grains.saltversion >= "2017.7" %}
22 - client_args:
23 host: {{ mconf.host }}
24 port: {{ mconf.port }}
25 {%- if qr.user is defined OR mconf.password is defined %}
26 user: {{ qr.get('user', mconf.user) }}
27 {%- endif %}
28 {%- if qr.password is defined OR mconf.password is defined %}
29 password: {{ qr.get('password', mconf.password) }}
30 {%- endif %}
31 {%- endif %}
32{%- endfor %}
33{%- endfor %}
34