Alarms
diff --git a/heka/_service.sls b/heka/_service.sls
index e228165..9b0bbae 100644
--- a/heka/_service.sls
+++ b/heka/_service.sls
@@ -76,6 +76,9 @@
'log_collector': {
'decoder': {},
'input': {},
+ 'trigger': {},
+ 'alarm': {},
+ 'alarm_cluster': {},
'filter': {},
'splitter': {},
'encoder': {},
@@ -84,6 +87,9 @@
'metric_collector': {
'decoder': {},
'input': {},
+ 'trigger': {},
+ 'alarm': {},
+ 'alarm_cluster': {},
'filter': {},
'splitter': {},
'encoder': {},
@@ -92,6 +98,9 @@
'remote_collector': {
'decoder': {},
'input': {},
+ 'trigger': {},
+ 'alarm': {},
+ 'alarm_cluster': {},
'filter': {},
'splitter': {},
'encoder': {},
@@ -100,6 +109,9 @@
'aggregator': {
'decoder': {},
'input': {},
+ 'trigger': {},
+ 'alarm': {},
+ 'alarm_cluster': {},
'filter': {},
'splitter': {},
'encoder': {},
@@ -130,7 +142,7 @@
{# Loading the other services' support metadata from salt-mine #}
-{%- if service_name in ['remote_collector', 'aggregator'] %}
+{%- if service_name in ['remote_collector'] %}
{%- for node_name, node_grains in salt['mine.get']('*', 'grains.items').iteritems() %}
{%- if node_grains.heka is defined %}
@@ -143,7 +155,7 @@
{%- endif %}
-{# Overriding aggregated metadata from user-space pillar data #}
+{# Replacing aggregated metadata from user-space pillar data #}
{%- for service_grain_name, service_grain in service_grains.iteritems() %}
{% if salt['pillar.get']('heka:'+service_grain_name) %}
@@ -151,9 +163,6 @@
{%- for service_action_name, service_action in service_grain.iteritems() %}
{%- if salt['pillar.get']('heka:'+service_grain_name).get(service_action_name, False) is mapping %}
{%- set grain_action_meta = salt['pillar.get']('heka:'+service_grain_name+':'+service_action_name) %}
-{#
-{%- set service_grains.get(service_grain_name).get(service_action_name) = salt['grains.filter_by']({'default': service_grains}, merge=grain_action_meta) %}
-#}
{%- endif %}
{%- endfor %}
@@ -231,6 +240,42 @@
{%- endfor %}
+{%- for alarm_name, alarm in service_metadata.get('alarm', {}).iteritems() %}
+
+/etc/{{ service_name }}/filter_afd_{{ alarm_name }}.toml:
+ file.managed:
+ - source: salt://heka/files/toml/filter/afd_alarm.toml
+ - template: jinja
+ - mode: 640
+ - group: heka
+ - require:
+ - file: heka_{{ service_name }}_conf_dir
+ - require_in:
+ - file: heka_{{ service_name }}_conf_dir_clean
+ - watch_in:
+ - service: heka_{{ service_name }}_service
+ - defaults:
+ alarm_name: {{ alarm_name }}
+ alarm: {{ alarm|yaml }}
+
+/usr/share/lma_collector_modules/lma_{{ alarm_name }}.lua:
+ file.managed:
+ - source: salt://heka/files/toml/filter/lma_alarm.lua
+ - template: jinja
+ - mode: 640
+ - group: heka
+ - require:
+ - file: heka_{{ service_name }}_conf_dir
+ - require_in:
+ - file: heka_{{ service_name }}_conf_dir_clean
+ - watch_in:
+ - service: heka_{{ service_name }}_service
+ - defaults:
+ alarm_name: {{ alarm_name }}
+ alarm: {{ alarm|yaml }}
+
+{%- endfor %}
+
{%- for filter_name, filter in service_metadata.get('filter', {}).iteritems() %}
/etc/{{ service_name }}/filter_{{ filter_name }}.toml:
diff --git a/heka/files/toml/filter/afd_alarm.toml b/heka/files/toml/filter/afd_alarm.toml
new file mode 100644
index 0000000..df83cb7
--- /dev/null
+++ b/heka/files/toml/filter/afd_alarm.toml
@@ -0,0 +1,21 @@
+[afd_{{ alarm_name }}_filter]
+type = "SandboxFilter"
+filename = "/usr/share/lma_collector/filters/afd.lua"
+{%- if alarm.preserve_data is defined %}
+preserve_data = {{ alarm.preserve_data|lower }}
+{%- else %}
+preserve_data = false
+{%- endif %}
+message_matcher = "(Type == 'metric' || Type == 'heka.sandbox.metric') && (Fields[name] == 'openstack_check_api')"
+module_directory = "/usr/share/lma_collector_modules;/usr/share/heka/lua_modules"
+
+ticker_interval = 10
+
+[afd_{{ alarm_name }}_filter.config]
+hostname = '{{ grains.host }}'
+afd_type = 'service'
+afd_file = 'lma_{{ alarm_name }}'
+afd_cluster_name = 'cinder-api-check'
+afd_logical_name = 'vip'
+activate_alerting = true
+enable_notification = false
diff --git a/heka/files/toml/filter/lma_alarm.lua b/heka/files/toml/filter/lma_alarm.lua
new file mode 100644
index 0000000..cbf4a70
--- /dev/null
+++ b/heka/files/toml/filter/lma_alarm.lua
@@ -0,0 +1,44 @@
+local M = {}
+setfenv(1, M) -- Remove external access to contain everything in the module
+
+local alarms = {
+{%- for trigger_name, trigger in alarm.triggers.iteritems() %}
+{%- if trigger.get('enabled', True) %}
+ {
+ ['name'] = '{{ alarm_name }}',
+ ['description'] = '{{ alarm.get("description", "").replace("'", "\\'") }}',
+ ['severity'] = '{{ alarm.severity }}',
+ {%- if alarm.no_data_policy is defined %}
+ ['no_data_policy'] = '{{ alarm.no_data_policy }}',
+ {%- endif %}
+ ['trigger'] = {
+ ['logical_operator'] = '{{ alarm.get("logical_operator", "or") }}',
+ ['rules'] = {
+ {%- for rule in trigger.rules %}
+ {
+ ['metric'] = '{{ rule.metric }}',
+ ['fields'] = {
+ {%- for dimension_name, dimension_value in rule.dimension.iteritems() %}
+ ['{{ dimension_name }}'] = '{{ dimension_value }}',
+ {%- endfor %}
+ },
+ ['relational_operator'] = '{{ rule.relational_operator }}',
+ ['threshold'] = '{{ rule.threshold }}',
+ ['window'] = '{{ rule.window }}',
+ ['periods'] = '{{ rule.get('periods', 0) }}',
+ ['function'] = '{{ rule.function }}',
+ ['group_by'] = {
+ {%- for group_by in rule.group_by %}
+ {{ group_by }},
+ {%- endfor %}
+ },
+ },
+ {%- endfor %}
+ },
+ },
+ },
+{%- endif %}
+{%- endfor %}
+}
+
+return alarms
\ No newline at end of file
diff --git a/heka/meta/heka.yml b/heka/meta/heka.yml
index 1d5c8fe..4c4ac6b 100644
--- a/heka/meta/heka.yml
+++ b/heka/meta/heka.yml
@@ -95,10 +95,3 @@
host: 127.0.0.1
port: 4354
ticker_interval: 30
-aggregator:
- decoder: {}
- input: {}
- filter: {}
- output: {}
- splitter: {}
- encoder: {}
diff --git a/heka/untitled b/heka/untitled
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/heka/untitled