diff --git a/metadata/service/pushgateway/container.yml b/metadata/service/pushgateway/container.yml index 8d2e60e..0fff6f5 100644 --- a/metadata/service/pushgateway/container.yml +++ b/metadata/service/pushgateway/container.yml @@ -7,3 +7,5 @@ parameters: bind: address: 0.0.0.0 port: 9091 + dir: + data: /srv/volumes/local/pushgateway diff --git a/prometheus/init.sls b/prometheus/init.sls index 0e6cdad..79e77c1 100644 --- a/prometheus/init.sls +++ b/prometheus/init.sls @@ -1,6 +1,7 @@ {%- if pillar.prometheus.get('server', {}).get('enabled', False) or pillar.prometheus.get('relay', {}).get('enabled', False) or pillar.prometheus.get('alerta', {}).get('enabled', False) or + pillar.prometheus.get('pushgateway', {}).get('enabled', False) or pillar.prometheus.alertmanager is defined or pillar.prometheus.exporters is defined %} include: @@ -13,6 +14,9 @@ include: {%- if pillar.prometheus.get('alerta', {}).get('enabled', False) %} - prometheus.alerta {%- endif %} + {%- if pillar.prometheus.get('pushgateway', {}).get('enabled', False) %} + - prometheus.pushgateway + {%- endif %} {%- if pillar.prometheus.alertmanager is defined %} - prometheus.alertmanager {%- endif %} diff --git a/prometheus/map.jinja b/prometheus/map.jinja index a8f0378..1581615 100644 --- a/prometheus/map.jinja +++ b/prometheus/map.jinja @@ -26,6 +26,15 @@ }, merge=salt['pillar.get']('prometheus:exporters')) %} {%- do salt['defaults.merge'](exporters, grains.get('prometheus', {}).get('exporters', {})) %} +{% set pushgateway = salt['grains.filter_by']({ + 'default': { + 'enabled': True, + 'dir': { + 'data': '/srv/volumes/local/pushgateway', + } + }, +}, merge=salt['pillar.get']('prometheus:pushgateway')) %} + {%- set monitoring = salt['grains.filter_by']({ 'default': { 'remote_storage_adapter': { diff --git a/prometheus/pushgateway.sls b/prometheus/pushgateway.sls new file mode 100644 index 0000000..a9023d9 --- /dev/null +++ b/prometheus/pushgateway.sls @@ -0,0 +1,12 @@ +{% from "prometheus/map.jinja" import pushgateway with context %} +{%- if pushgateway.enabled %} + +{%- if pillar.docker is defined and pillar.docker.host is defined %} + +{{pushgateway.dir.data}}: + file.directory: + - makedirs: True + - mode: 755 + +{%- endif %} +{%- endif %} diff --git a/tests/pillar/pushgateway.sls b/tests/pillar/pushgateway.sls index 583fcde..27211d3 100644 --- a/tests/pillar/pushgateway.sls +++ b/tests/pillar/pushgateway.sls @@ -5,3 +5,5 @@ prometheus: address: 0.0.0.0 port: 9091 external_port: 15012 + dir: + data: /opt/pushgateway/data