added sensu filter for slack

Change-Id: I405e1eda426bde2e80272c856d7c8b088c7639f2
diff --git a/sensu/files/filter.json b/sensu/files/filter.json
new file mode 100644
index 0000000..2d39dd1
--- /dev/null
+++ b/sensu/files/filter.json
@@ -0,0 +1,13 @@
+{%- set filter = pillar.sensu.server.filter[filter_name] %}
+{
+  "filters": {
+    "{{ filter_name }}": {
+      "attributes": {
+      {%- if filter.attributes.occurrences is defined %}
+        "occurrences": "{{ filter.attributes.occurrences }}"
+      {%- endif %}
+      },
+      "negate": {{ filter.get("negate", "false") | lower }}
+    }
+  }
+}
\ No newline at end of file
diff --git a/sensu/files/handlers/slack.json b/sensu/files/handlers/slack.json
index c12adfb..9098f9b 100644
--- a/sensu/files/handlers/slack.json
+++ b/sensu/files/handlers/slack.json
@@ -7,6 +7,9 @@
       {%- if handler.mutator is defined %}
       "mutator": "{{ handler.mutator }}",
       {%- endif %}
+      {%- if handler.filter is defined %}
+      "filter": "{{ handler.filter }}",
+      {%- endif %}
       "command": "/etc/sensu/handlers/slack.rb",
       "severities": [
         "ok",
diff --git a/sensu/server.sls b/sensu/server.sls
index 2e38e9f..9162950 100644
--- a/sensu/server.sls
+++ b/sensu/server.sls
@@ -75,7 +75,7 @@
     mutator_name: "{{ mutator.name }}"
   - require:
     - file: /etc/sensu/config.json
-    - pkg: sensu_packages
+    - pkg: sensu_server_packages
   - require_in:
     - file: sensu_conf_dir_clean
   - watch_in:
@@ -84,6 +84,22 @@
 
 {%- endfor %}
 
+{%- for filter_name, filter in server.get('filter', {}).iteritems() %}
+
+/etc/sensu/conf.d/filter_{{ filter_name }}.json:
+  file.managed:
+  - source: salt://sensu/files/filter.json
+  - template: jinja
+  - defaults:
+    filter_name: "{{ filter_name }}"
+  - require:
+    - pkg: sensu_server_packages
+  - watch_in:
+    - service: service_sensu_server
+    - service: service_sensu_api
+
+{%- endfor %}
+
 {%- for handler_name, handler in server.get('handler', {}).iteritems() %}
 
 {%- if handler.get('enabled', True) and handler_name in ['default', 'flapjack', 'mail', 'sccd', 'stdout', 'statsd', 'slack', 'pipe', 'sfdc', 'pagerduty', 'hipchat'] %}