Merge pull request #48 from elemoine/stacklight-mine
Send only alarm-related data to mine
diff --git a/_modules/heka_alarming.py b/_modules/heka_alarming.py
index b12fa23..4212565 100644
--- a/_modules/heka_alarming.py
+++ b/_modules/heka_alarming.py
@@ -73,3 +73,24 @@
raise Exception(
'Dimension value {} includes disallowed chars'.format(value))
return dimensions
+
+
+def grains_for_mine(grains):
+ """
+ Return grains that need to be sent to Salt Mine. Only the alarm
+ and alarm cluster data is to be sent to Mine.
+ """
+ filtered_grains = {}
+ for service_name, service_data in grains.items():
+ alarm = service_data.get('alarm')
+ if alarm:
+ filtered_grains[service_name] = {'alarm': alarm}
+ alarm_cluster = service_data.get('alarm_cluster')
+ if alarm_cluster:
+ if service_name in filtered_grains:
+ filtered_grains[service_name].update(
+ {'alarm_cluster': alarm_cluster})
+ else:
+ filtered_grains[service_name] = \
+ {'alarm_cluster': alarm_cluster}
+ return filtered_grains
diff --git a/heka/_service.sls b/heka/_service.sls
index 8a09ea7..93e543f 100644
--- a/heka/_service.sls
+++ b/heka/_service.sls
@@ -179,7 +179,7 @@
- mode: 600
- defaults:
service_grains:
- heka: {{ service_grains|yaml }}
+ heka: {{ salt['heka_alarming.grains_for_mine'](service_grains)|yaml }}
- require:
- file: heka_grains_dir