Merge pull request #9 from thouveng/fix-dash-name

Fix the name of the Grafana dashboard
diff --git a/haproxy/files/collectd_haproxy.conf b/haproxy/files/collectd_haproxy.conf
index 8c08f18..e14eb7a 100644
--- a/haproxy/files/collectd_haproxy.conf
+++ b/haproxy/files/collectd_haproxy.conf
@@ -1,29 +1,13 @@
+{%- from "haproxy/map.jinja" import proxy with context %}
+{%- if proxy.enabled and proxy.listen is defined and proxy.listen|length > 0 %}
+
 Import "haproxy"
 
 <Module "haproxy">
-    Mapping "contrail_analytics" "contrail-analytics"
-    Mapping "contrail_api" "contrail-api"
-    Mapping "contrail_discovery" "contrail-discovery"
-
-    Mapping "mysql_cluster" "mysql"
-
-    Mapping "cinder_api" "cinder-api"
-    Mapping "glance_api" "glance-api"
-    Mapping "glance_registry" "glance-registry-api"
-    Mapping "heat_api" "heat-api"
-    Mapping "heat_api_cfn" "heat-cfn-api"
-    Mapping "heat_api_cloudwatch" "heat-cloudwatch-api"
-    Mapping "horizon_web" "horizon-web"
-    Mapping "keystone_admin" "keystone-admin-api"
-    Mapping "keystone_auth" "keystone-public-api"
-    Mapping "nova_metadata" "nova-metadata-api"
-    Mapping "nova_ec2_api" "nova-ec2-api"
-    Mapping "nova_openstack_api" "nova-api"
-    Mapping "neutron_api" "neutron-api"
-
-    ProxyIgnore "rabbitmq_cluster"
-    ProxyIgnore "contrail_collector_stats"
-    ProxyIgnore "contrail_config_stats"
-
-    Socket "{{ plugin.socket }}"
+{%- for listen_name, listen in proxy.listen.iteritems() if not listen.get('check', True) %}
+  ProxyIgnore "{{ listen_name }}"
+{%- endfor %}
+  Socket "{{ plugin.socket }}"
 </Module>
+
+{%- endif %}
diff --git a/haproxy/meta/heka.yml b/haproxy/meta/heka.yml
new file mode 100644
index 0000000..7128769
--- /dev/null
+++ b/haproxy/meta/heka.yml
@@ -0,0 +1,106 @@
+{%- from "haproxy/map.jinja" import proxy with context %}
+{%- if proxy.enabled and proxy.listen is defined and proxy.listen|length > 0 %}
+
+metric_collector:
+  trigger:
+    haproxy_check:
+      description: 'HAProxy cannot be checked'
+      severity: down
+      rules:
+      - metric: haproxy_check
+        relational_operator: '=='
+        threshold: 0
+        window: 60
+        periods: 0
+        function: last
+{%- for listen_name, listen in proxy.listen.iteritems() if listen.get('check', True) %}
+    {{ listen_name }}_backends_all_down:
+      description: 'All API backends are down for {{ listen_name }}'
+      severity: down
+      rules:
+      - metric: haproxy_backend_servers
+        field:
+          backend: {{ listen_name }}
+          state: up
+        relational_operator: '=='
+        threshold: 0
+        window: 60
+        periods: 0
+        function: last
+    {{ listen_name }}_backends_majority_down:
+      description: 'Less than 50% of backends are up for {{ listen_name }}'
+      severity: critical
+      rules:
+      - metric: haproxy_backend_servers_percent
+        field:
+          backend: {{ listen_name }}
+          state: up
+        relational_operator: '<='
+        threshold: 50
+        window: 60
+        periods: 0
+        function: last
+    {{ listen_name }}_backends_one_down:
+      description: 'At least one API backend is down for {{ listen_name }}'
+      severity: warning
+      rules:
+      - metric: haproxy_backend_servers
+        field:
+          backend: {{ listen_name }}
+          state: down
+        relational_operator: '>'
+        threshold: 0
+        window: 60
+        periods: 0
+        function: last
+{%- if listen.get('type', None) == 'openstack-service' %}
+    {{ listen_name }}_http_errors:
+      description: 'Too many 5xx HTTP errors have been detected on {{ listen_name }}'
+      severity: warning
+      rules:
+      - metric: haproxy_backend_response_5xx
+        field:
+          backend: {{ listen_name }}
+        relational_operator: '>'
+        threshold: 0
+        window: 60
+        periods: 1
+        function: diff
+{%- endif %}
+{%- endfor %}
+  alarm:
+{%- for listen_name, listen in proxy.listen.iteritems() if listen.get('check', True) %}
+    {{ listen_name }}_backends:
+      triggers:
+      - {{ listen_name }}_backends_all_down
+      - {{ listen_name }}_backends_majority_down
+      - {{ listen_name }}_backends_one_down
+      dimension:
+        service: {{ listen_name }}
+{%- if listen.get('type', None) == 'openstack-service' %}
+    {{ listen_name }}_http_errors:
+      triggers:
+      - {{ listen_name }}_http_errors
+      dimension:
+        service: {{ listen_name }}
+{%- endif %}
+{%- else %}
+    {}
+{%- endfor %}
+aggregator:
+  alarm_cluster:
+{%- for listen_name, listen in proxy.listen.iteritems() if listen.get('check', True) %}
+    {{ listen_name }}:
+      policy: highest_severity
+      match:
+        service: {{ listen_name }}
+      members:
+      - {{ listen_name }}_backends
+{%- if listen.get('type', None) == 'openstack-service' %}
+      - {{ listen_name }}_http_errors
+{%- endif %}
+{%- else %}
+    {}
+{%- endfor %}
+
+{%- endif %}
diff --git a/metadata/service/support.yml b/metadata/service/support.yml
index 2d10c66..11b9d49 100644
--- a/metadata/service/support.yml
+++ b/metadata/service/support.yml
@@ -4,7 +4,7 @@
       collectd:
         enabled: true
       heka:
-        enabled: false
+        enabled: true
       sensu:
         enabled: true
       sphinx: