Generate 'route' config entry with macro

Change-Id: Id258bea57281e761fdeab10c30edcf32e695163e
diff --git a/metadata/service/alertmanager/container.yml b/metadata/service/alertmanager/container.yml
index f74687c..e69e37c 100644
--- a/metadata/service/alertmanager/container.yml
+++ b/metadata/service/alertmanager/container.yml
@@ -18,7 +18,7 @@
           group_wait: 60s
           group_interval: 5m
           repeat_interval: 3h
-          receiver: HTTP-notification
+          receiver: default
         inhibit_rule:
           InhibitCriticalWhenDown:
             enabled: true
@@ -42,9 +42,5 @@
               severity: 'warning'
             equal: ['region', 'service']
         receiver:
-          HTTP-notification:
+          default:
             enabled: true
-            webhook_configs:
-              localhost:
-                url: http://127.0.0.1
-                send_resolved: true
diff --git a/prometheus/files/alertmanager.yml b/prometheus/files/alertmanager.yml
index 793733b..7139d48 100644
--- a/prometheus/files/alertmanager.yml
+++ b/prometheus/files/alertmanager.yml
@@ -1,4 +1,31 @@
 {% from "prometheus/map.jinja" import alertmanager with context %}
+{%- macro route_entry(route={}) -%}
+{%- if route.receiver is defined -%}
+receiver: {{ route.receiver }}
+{%- endif -%}
+{%- if route.group_by is defined %}
+group_by:
+  {%- for group_by in route.group_by %}
+- {{ group_by }}
+  {%- endfor %}
+{%- endif %}
+{%- if route.group_interval is defined %}
+group_interval: {{ route.group_interval }}
+{%- endif %}
+{%- if route.group_wait is defined %}
+group_wait: {{ route.group_wait }}
+{%- endif %}
+{%- if route.repeat_interval is defined %}
+repeat_interval: {{ route.repeat_interval }}
+{%- endif %}
+{%- if route.match_re is defined %}
+match_re:
+  {%- for match_re in route.match_re %}
+  {{ match_re.label }}: {{ match_re.value }}
+  {%- endfor %}
+{%- endif %}
+{%- endmacro -%}
+
 global:
 {%- if alertmanager.config.global is defined %}
   {%- if alertmanager.config.global.resolve_timeout is defined %}
@@ -7,8 +34,14 @@
 {%- endif %}
 
 route:
-{%- if alertmanager.config.route is defined %}
-{{ alertmanager.config.route | yaml(False) | indent(2, true) }}
+{%- set config_route = alertmanager.config.get('route', {}) %}
+  {{ route_entry(config_route) | indent(2) }}
+  {%- if config_route.get('routes', {}) %}
+  routes:
+  {%- for route_name, route in config_route.get('routes', {}).iteritems() %}
+  # {{ route_name }}
+  - {{ route_entry(route) | indent(4) }}
+  {%- endfor %}
 {%- endif %}
 
 inhibit_rules: