Rename no_alerting field

This patch uses a boolean to enable or disable alerting instead of using
a variable no_alerting that is not very obvious and adds unneeded
complexity.

Change-Id: I42feeb2858aaadd9c1b4aaf5217dfe34aae35059
diff --git a/_modules/heka_alarming.py b/_modules/heka_alarming.py
index efbd091..83a6445 100644
--- a/_modules/heka_alarming.py
+++ b/_modules/heka_alarming.py
@@ -4,7 +4,7 @@
 
 _valid_dimension_re = re.compile(r'^[a-z0-9_/-]+$')
 _disallowed_dimensions = ('name', 'value', 'hostname', 'member',
-                          'no_alerting', 'tag_fields')
+                          'alerting_enabled', 'tag_fields')
 
 
 def alarm_message_matcher(alarm, triggers):
diff --git a/heka/files/lua/common/afd.lua b/heka/files/lua/common/afd.lua
index 2d47040..520c007 100644
--- a/heka/files/lua/common/afd.lua
+++ b/heka/files/lua/common/afd.lua
@@ -129,7 +129,7 @@
 end
 
 -- inject an AFD event into the Heka pipeline
-function inject_afd_metric(value, hostname, afd_name, dimensions, to_alerting)
+function inject_afd_metric(value, hostname, afd_name, dimensions, alerting_enabled)
     local payload
 
     if #alarms > 0 then
@@ -143,11 +143,6 @@
         payload = '{"alarms":[]}'
     end
 
-    local no_alerting
-    if to_alerting ~= nil and to_alerting == false then
-        no_alerting = true
-    end
-
     local msg = {
         Type = 'afd_metric',
         Payload = payload,
@@ -156,7 +151,7 @@
             value = value,
             hostname = hostname,
             member = afd_name,
-            no_alerting = no_alerting,
+            alerting_enabled = alerting_enabled,
             tag_fields = {'hostname', 'member'}
         }
     }
diff --git a/heka/files/lua/common/gse.lua b/heka/files/lua/common/gse.lua
index 3e6948e..0f71eab 100644
--- a/heka/files/lua/common/gse.lua
+++ b/heka/files/lua/common/gse.lua
@@ -133,7 +133,7 @@
 
 -- compute the cluster metric and inject it into the Heka pipeline
 -- the metric's value is computed using the status of its members
-function inject_cluster_metric(cluster_name, dimensions, to_alerting)
+function inject_cluster_metric(cluster_name, dimensions, alerting_enabled)
     local payload
     local status, alarms = resolve_status(cluster_name)
 
@@ -147,11 +147,6 @@
         payload = '{"alarms":[]}'
     end
 
-    local no_alerting
-    if to_alerting ~= nil and to_alerting == false then
-        no_alerting = true
-    end
-
     local msg = {
         Type = 'gse_metric',
         Payload = payload,
@@ -159,8 +154,8 @@
             name = 'cluster_status',
             value = status,
             member = cluster_name,
+            alerting_enabled = alerting_enabled,
             tag_fields = {'member'},
-            no_alerting = no_alerting,
         }
     }
 
diff --git a/heka/meta/heka.yml b/heka/meta/heka.yml
index 1b2a3ca..7d90df0 100644
--- a/heka/meta/heka.yml
+++ b/heka/meta/heka.yml
@@ -207,7 +207,7 @@
     nagios_alarm:
       engine: http
       address: "http://{{ metric_collector.nagios_host }}:{{metric_collector.nagios_port }}/status"
-      message_matcher: "Type == 'heka.sandbox.afd_metric' && Fields[no_alerting] == NIL"
+      message_matcher: "Type == 'heka.sandbox.afd_metric' && Fields[alerting_enabled] == TRUE"
       encoder: nagios_encoder
       {%- if metric_collector.nagios_username is defined and metric_collector.nagios_password is defined %}
       username: {{ metric_collector.get('nagios_username') }}
@@ -602,7 +602,7 @@
     nagios_alarm_cluster:
       engine: http
       address: "http://{{ aggregator.nagios_host }}:{{aggregator.nagios_port }}/status"
-      message_matcher: "Type == 'heka.sandbox.gse_metric' && Fields[no_alerting] == NIL"
+      message_matcher: "Type == 'heka.sandbox.gse_metric' && Fields[alerting_enabled] == TRUE"
       encoder: nagios_encoder
       {%- if aggregator.nagios_username is defined and aggregator.nagios_password is defined %}
       username: {{ aggregator.get('nagios_username') }}
@@ -617,7 +617,7 @@
       engine: udp
       host: "{{ aggregator.sensu_host }}"
       port: "{{ aggregator.sensu_port|default(3030) }}"
-      message_matcher: "Type == 'heka.sandbox.watchdog' || ((Type == 'heka.sandbox.gse_metric' || Type == 'heka.sandbox.afd_metric') && Fields[no_alerting] == NIL)"
+      message_matcher: "Type == 'heka.sandbox.watchdog' || ((Type == 'heka.sandbox.gse_metric' || Type == 'heka.sandbox.afd_metric') && Fields[alerting_enabled] == TRUE)"
       encoder: sensu_encoder
       use_buffering: false
   {%- endif %}