Merge "Allow to deploy prometheus as standalone service"
diff --git a/.kitchen.yml b/.kitchen.yml
index c8edb38..d5424a6 100644
--- a/.kitchen.yml
+++ b/.kitchen.yml
@@ -30,9 +30,9 @@
 
 
 platforms:
-  - name: <%=ENV['PLATFORM'] || 'ubuntu-xenial'%>
+  - name: <%=ENV['PLATFORM'] ||  'saltstack-ubuntu-xenial-salt-stable' %>
     driver_config:
-      image: <%=ENV['PLATFORM'] || 'trevorj/salty-whales:xenial'%>
+      image: <%=ENV['PLATFORM'] || 'epcim/salt-formulas:saltstack-ubuntu-xenial-salt-stable'%>
       platform: ubuntu
 
 suites:
diff --git a/.travis.yml b/.travis.yml
index 34fdc99..0764388 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -17,10 +17,12 @@
   - bundle install
 
 env:
-  - PLATFORM=trevorj/salty-whales:trusty SUITE=alertmanager
-  - PLATFORM=trevorj/salty-whales:xenial SUITE=alertmanager
-  - PLATFORM=trevorj/salty-whales:trusty SUITE=server
-  - PLATFORM=trevorj/salty-whales:xenial SUITE=server
+  - PLATFORM=epcim/salt-formulas:saltstack-ubuntu-xenial-salt-2016.3 SUITE=alertmanager
+  - PLATFORM=epcim/salt-formulas:saltstack-ubuntu-xenial-salt-2016.3 SUITE=server
+  - PLATFORM=epcim/salt-formulas:saltstack-ubuntu-xenial-salt-2017.7 SUITE=alertmanager
+  - PLATFORM=epcim/salt-formulas:saltstack-ubuntu-xenial-salt-2017.7 SUITE=server
+  # - PLATFORM=epcim/salt-formulas:saltstack-ubuntu-bionic-salt-2017.7 SUITE=alertmanager
+  # - PLATFORM=epcim/salt-formulas:saltstack-ubuntu-bionic-salt-2017.7 SUITE=server
 
 before_script:
   - set -o pipefail
diff --git a/Makefile b/Makefile
index 1043fbe..d166862 100644
--- a/Makefile
+++ b/Makefile
@@ -27,6 +27,7 @@
 
 all:
 	@echo "make install - Install into DESTDIR"
+	@echo "make lint    - Run lint tests"
 	@echo "make test    - Run tests"
 	@echo "make kitchen - Run Kitchen CI tests (create, converge, verify)"
 	@echo "make clean   - Cleanup after tests run"
@@ -45,6 +46,9 @@
 	[ -d $(DESTDIR)/$(RECLASSDIR)/service/$(FORMULANAME) ] || mkdir -p $(DESTDIR)/$(RECLASSDIR)/service/$(FORMULANAME)
 	cp -a metadata/service/* $(DESTDIR)/$(RECLASSDIR)/service/$(FORMULANAME)
 
+lint:
+	[ ! -d tests ] || (cd tests; ./run_tests.sh lint)
+
 test:
 	[ ! -d tests ] || (cd tests; ./run_tests.sh)
 
@@ -65,7 +69,7 @@
 	[ ! -f debian/changelog ] || dch -v $(VERSION_MAJOR).$(NEW_MINOR_VERSION) -m --force-distribution -D `dpkg-parsechangelog -S Distribution` "New version"
 	make genchangelog-$(VERSION_MAJOR).$(NEW_MINOR_VERSION)
 	(git add -u; git commit -m "Version $(VERSION_MAJOR).$(NEW_MINOR_VERSION)")
-	git tag -s -m $(NEW_MAJOR_VERSION) $(VERSION_MAJOR).$(NEW_MINOR_VERSION)
+	git tag -s -m $(VERSION_MAJOR).$(NEW_MINOR_VERSION) $(VERSION_MAJOR).$(NEW_MINOR_VERSION)
 
 check-changes:
 	@git log --pretty=oneline --decorate $(VERSION)..HEAD | grep -Eqc '.*' || (echo "No new changes since version $(VERSION)"; exit 1)
diff --git a/prometheus/files/alertmanager.yml b/prometheus/files/alertmanager.yml
index c99956a..348e507 100644
--- a/prometheus/files/alertmanager.yml
+++ b/prometheus/files/alertmanager.yml
@@ -3,6 +3,9 @@
 {%- if route.receiver is defined -%}
 receiver: {{ route.receiver }}
 {%- endif -%}
+{%- if route.continue is defined %}
+continue: {{ route.continue }}
+{%- endif -%}
 {%- if route.group_by is defined %}
 group_by:
   {%- for group_by in route.group_by %}
@@ -115,6 +118,15 @@
       {%- if email.send_resolved is defined %}
       send_resolved: {{ email.send_resolved | lower }}
       {%- endif %}
+      {%- if email.html is defined %}
+      html: '{{ email.html }}'
+      {%- endif %}
+      {%- if email.headers is defined %}
+      headers:
+        {%- for header, value in email.headers.iteritems() %}
+        {{ header }}: {{ value }}
+        {%- endfor %}
+      {%- endif %}
     {%- endfor %}
   {%- endif %}
 {%- endif %}
diff --git a/prometheus/files/server/prometheus.yml b/prometheus/files/server/prometheus.yml
index 57c3bee..250235e 100644
--- a/prometheus/files/server/prometheus.yml
+++ b/prometheus/files/server/prometheus.yml
@@ -106,16 +106,25 @@
     {%- if job.get('metric_relabel') %}
     metric_relabel_configs:
       {%- for label in job.get('metric_relabel', []) %}
-        {%- if label.source_labels is string %}
-          {%- set label_list = label.source_labels.split(',') %}
-        {%- elif label.source_labels is list %}
-          {%- set label_list = label.source_labels %}
+      - action: {{ label.get('action', 'replace') }}
+        {%- if label.get('source_labels') %}
+          {%- if label.source_labels is string %}
+            {%- set label_list = label.source_labels.split(',') %}
+          {%- elif label.source_labels is list %}
+            {%- set label_list = label.source_labels %}
+          {%- endif %}
+          {%- if label_list is defined %}
+        source_labels: {{ label_list }}
+          {%- endif %}
         {%- endif %}
-        {%- if label_list is defined %}
-      - source_labels: {{ label_list }}
+        {%- if label.get('regex') %}
         regex: "{{ label.regex }}"
+        {%- endif %}
+        {%- if label.get('target_label') %}
         target_label: "{{ label.target_label }}"
-        replacement: {{ label.replacement }}
+        {%- endif %}
+        {%- if label.get('replacement') %}
+        replacement: "{{ label.replacement }}"
         {%- endif %}
       {%- endfor %}
     {%- endif %}