Create data directory for am and prometheus

Change-Id: Ie89009480c06cafb15bb06ded263e49ef194dfc9
This commit is contained in:
Bartosz Kupidura 2017-05-17 16:00:52 +02:00
parent e9dc06012c
commit abec256072
8 changed files with 45 additions and 16 deletions

View file

@ -4,6 +4,9 @@ parameters:
prometheus: prometheus:
alertmanager: alertmanager:
enabled: true enabled: true
dir:
config: /srv/volumes/prometheus/alertmanager
data: /srv/volumes/local/prometheus/alertmanager
bind: bind:
address: 0.0.0.0 address: 0.0.0.0
port: 9093 port: 9093

View file

@ -6,6 +6,9 @@ parameters:
prometheus: prometheus:
server: server:
enabled: true enabled: true
dir:
config: /srv/volumes/prometheus/server
data: /srv/volumes/local/prometheus/server
bind: bind:
port: 9090 port: 9090
address: 0.0.0.0 address: 0.0.0.0

View file

@ -3,11 +3,24 @@
{%- if pillar.docker is defined and pillar.docker.host is defined %} {%- if pillar.docker is defined and pillar.docker.host is defined %}
{{alertmanager.dir.config}}:
file.directory:
- makedirs: True
# prometheus user is available inside docker container not on docker host
# in dockerfile for alertmanager we ensure that it will have 999 uid
{{alertmanager.dir.data}}:
file.directory:
- makedirs: True
- mode: 755
- user: {{alertmanager.user}}
{{alertmanager.dir.config}}/alertmanager.yml: {{alertmanager.dir.config}}/alertmanager.yml:
file.managed: file.managed:
- source: salt://prometheus/files/alertmanager.yml - source: salt://prometheus/files/alertmanager.yml
- template: jinja - template: jinja
- makedirs: True - require:
- file: {{alertmanager.dir.config}}
{%- endif %} {%- endif %}
{%- endif %} {%- endif %}

View file

@ -6,7 +6,7 @@ global:
{%- endif %} {%- endif %}
rule_files: rule_files:
- {{ server.dir.config_in_container }}/alerts.yml - alerts.yml
{%- set static_target = {} %} {%- set static_target = {} %}
{%- for node_name, node_grains in salt['mine.get']('*', 'grains.items').iteritems() %} {%- for node_name, node_grains in salt['mine.get']('*', 'grains.items').iteritems() %}

View file

@ -1,16 +1,11 @@
{% set server = salt['grains.filter_by']({ {% set server = salt['grains.filter_by']({
'default': { 'default': {
'dir': { 'user': '999',
'config': '/srv/volumes/prometheus',
'config_in_container': '/opt/prometheus/config'
},
}, },
}, merge=salt['pillar.get']('prometheus:server')) %} }, merge=salt['pillar.get']('prometheus:server')) %}
{% set alertmanager = salt['grains.filter_by']({ {% set alertmanager = salt['grains.filter_by']({
'default': { 'default': {
'dir': { 'user': '999',
'config': '/srv/volumes/prometheus',
},
}, },
}, merge=salt['pillar.get']('prometheus:alertmanager')) %} }, merge=salt['pillar.get']('prometheus:alertmanager')) %}

View file

@ -3,17 +3,31 @@
{%- if pillar.docker is defined and pillar.docker.host is defined %} {%- if pillar.docker is defined and pillar.docker.host is defined %}
{{server.dir.config}}:
file.directory:
- makedirs: True
# prometheus user is available inside docker container not on docker host
# in dockerfile for prometheus we ensure that it will have 999 uid
{{server.dir.data}}:
file.directory:
- makedirs: True
- mode: 755
- user: {{server.user}}
{{server.dir.config}}/prometheus.yml: {{server.dir.config}}/prometheus.yml:
file.managed: file.managed:
- source: salt://prometheus/files/prometheus.yml - source: salt://prometheus/files/prometheus.yml
- template: jinja - template: jinja
- makedirs: True - require:
- file: {{server.dir.config}}
{{server.dir.config}}/alerts.yml: {{server.dir.config}}/alerts.yml:
file.managed: file.managed:
- source: salt://prometheus/files/alerts.yml - source: salt://prometheus/files/alerts.yml
- template: jinja - template: jinja
- makedirs: True - require:
- file: {{server.dir.config}}
{%- endif %} {%- endif %}
{%- endif %} {%- endif %}

View file

@ -2,7 +2,8 @@ prometheus:
alertmanager: alertmanager:
enabled: true enabled: true
dir: dir:
config: /srv/volumes/prometheus config: /srv/volumes/prometheus/alertmanager
data: /srv/volumes/local/prometheus/alertmanager
bind: bind:
address: 0.0.0.0 address: 0.0.0.0
port: 9093 port: 9093

View file

@ -2,8 +2,8 @@ prometheus:
server: server:
enabled: true enabled: true
dir: dir:
config: /srv/volumes/prometheus config: /srv/volumes/prometheus/server
config_in_container: /opt/prometheus/config data: /srv/volumes/local/prometheus/server
bind: bind:
port: 9090 port: 9090
address: 0.0.0.0 address: 0.0.0.0