Merge pull request #20 from tcpcloud/stacklight

Stacklight
diff --git a/README.rst b/README.rst
index 8c49531..08bd72a 100644
--- a/README.rst
+++ b/README.rst
@@ -130,6 +130,36 @@
                   unit: days
                   unit_count: 2
 
+Client setup
+------------
+
+Client with host and port:
+
+.. code-block:: yaml
+
+    elasticsearch:
+      client:
+        enabled: true
+        server:
+          host: elasticsearch.host
+          port: 9200
+
+Client where you download an index template that is stored in the direcotry
+*files/*:
+
+.. code-block:: yaml
+
+    elasticsearch:
+      client:
+        enabled: true
+        server:
+          host: elasticsearch.host
+          port: 9200
+        index:
+          my_index:
+            enabled: true
+            template: elasticsearch/files/my_index_template.json
+
 Read more
 =========
 
diff --git a/elasticsearch/client.sls b/elasticsearch/client.sls
new file mode 100644
index 0000000..4c8246e
--- /dev/null
+++ b/elasticsearch/client.sls
@@ -0,0 +1,30 @@
+{%- from "elasticsearch/map.jinja" import client with context %}
+{%- if client.get('enabled', False) %}
+
+/etc/salt/minion.d/_elasticsearch.conf:
+  file.managed:
+  - source: salt://elasticsearch/files/_elasticsearch.conf
+  - template: jinja
+  - user: root
+  - group: root
+
+elasticsearch_client_packages:
+  pkg.installed:
+  - names: {{ client.pkgs }}
+
+{%- for index_name, index in client.get('index', {}).iteritems() %}
+elasticsearch_index_{{ index_name }}:
+  {%- if index.get('enabled', False) %}
+  elasticsearch_index_template.present:
+  {%- import_json index.template as definition %}
+  - name: {{ index_name }}
+  - definition: '{{ definition|json }}'
+  {%- else %}
+  elasticsearch_index_template.absent:
+  - name: {{ index_name }}
+  {%- endif %}
+  - require:
+    - pkg: elasticsearch_client_packages
+{%- endfor %}
+
+{%- endif %}
diff --git a/elasticsearch/files/_elasticsearch.conf b/elasticsearch/files/_elasticsearch.conf
new file mode 100644
index 0000000..0a555bc
--- /dev/null
+++ b/elasticsearch/files/_elasticsearch.conf
@@ -0,0 +1,4 @@
+{%- from "elasticsearch/map.jinja" import client with context %}
+
+elasticsearch:
+  host: {{client.server.host}}:{{client.server.port}}
diff --git a/elasticsearch/files/collectd_elasticsearch_cluster.conf b/elasticsearch/files/collectd_elasticsearch_cluster.conf
new file mode 100644
index 0000000..49ddb85
--- /dev/null
+++ b/elasticsearch/files/collectd_elasticsearch_cluster.conf
@@ -0,0 +1,6 @@
+Import "elasticsearch_cluster"
+
+<Module "elasticsearch_cluster">
+    Address "{{ plugin.address }}"
+    Port "{{ plugin.port }}"
+</Module>
diff --git a/elasticsearch/files/elasticsearch.yml b/elasticsearch/files/elasticsearch.yml
index df2cbc7..a51cf3c 100644
--- a/elasticsearch/files/elasticsearch.yml
+++ b/elasticsearch/files/elasticsearch.yml
@@ -95,6 +95,10 @@
 # to disable it, set the following:
 # node.max_local_storage_nodes: 1
 
+{%- if server.get('threadpool', {}).get('bulk', {}).queue_size is defined %}
+# For bulk operations. Thread pool type is fixed with a size of # of available processors.
+threadpool.bulk.queue_size: {{ server.threadpool.bulk.queue_size }}
+{%- endif %}
 
 #################################### Index ####################################
 
@@ -154,6 +158,9 @@
 # Path to directory where to store index data allocated for this node.
 #
 # path.data: /path/to/data
+{%- if server.get('path', {}).data is defined %}
+path.data = {{ server.path.data }}
+{%- endif %}
 #
 # Can optionally include more than one location, causing data to be striped across
 # the locations (a la RAID 0) on a file level, favouring locations with most free
@@ -168,6 +175,9 @@
 # Path to log files:
 #
 # path.logs: /path/to/logs
+{%- if server.get('path', {}).logs is defined %}
+path.logs = {{ server.path.logs }}
+{%- endif %}
 
 # Path to where plugins are installed:
 #
@@ -196,6 +206,9 @@
 # Set this property to true to lock the memory:
 #
 # bootstrap.mlockall: true
+{%- if server.mlockall is defined %}
+bootstrap.mlockall: {{ server.mlockall|lower }}
+{%- endif %}
 
 # Make sure that the ES_MIN_MEM and ES_MAX_MEM environment variables are set
 # to the same value, and that the machine has enough memory to allocate
@@ -212,22 +225,21 @@
 # communication. (the range means that if the port is busy, it will automatically
 # try the next port).
 
-# Set the bind address specifically (IPv4 or IPv6):
+# Set both 'bind_host' and 'publish_host':
 #
-#
-network.bind_host: {{ server.bind.address }}
-http.port: {{ server.bind.port }}
-http.enabled: true
-# Set the address other nodes will use to communicate with this node. If not
-# set, it is automatically derived. It must point to an actual IP address.
-#
+# network.host: 192.168.0.1
+
+{%- if server.get('bind', {}).address is defined %}
+network.host: {{ server.bind.address }}
+{%- endif %}
+
+# Set specifically the address other nodes will use to communicate with this
+# node. If not set, it is automatically derived. It must point to an actual
+# IP address.
 {%- if server.publish_host is defined %}
 network.publish_host: {{ server.publish_host }}
 {%- endif %}
 
-# Set both 'bind_host' and 'publish_host':
-#
-# network.host: 192.168.0.1
 
 # Set a custom port for the node to node communication (9300 by default):
 #
@@ -240,14 +252,28 @@
 # Set a custom port to listen for HTTP traffic:
 #
 # http.port: 9200
+{%- if server.get('bind', {}).port is defined %}
+http.port: {{ server.bind.port }}
+{%- endif %}
 
 # Set a custom allowed content length:
 #
 # http.max_content_length: 100mb
 
+# Enable or disable cross-origin resource sharing
+{%- if server.get('cors', {}).enabled is defined %}
+http.cors.enabled: {{ server.cors.enabled|lower }}
+{%- endif %}
+
+# Which origins to allow.
+{%- if server.get('cors', {}).allow_origin is defined %}
+http.cors.allow-origin: {{ server.cors.allow_origin }}
+{%- endif %}
+
 # Disable HTTP completely:
 #
 # http.enabled: false
+http.enabled: true
 
 
 ################################### Gateway ###################################
@@ -271,17 +297,26 @@
 # Allow recovery process after N nodes in a cluster are up:
 #
 # gateway.recover_after_nodes: 1
+{%- if server.get('gateway', {}).recover_after_nodes is defined %}
+gateway.recover_after_nodes: {{ server.gateway.recover_after_nodes }}
+{%- endif %}
 
 # Set the timeout to initiate the recovery process, once the N nodes
 # from previous setting are up (accepts time value):
 #
 # gateway.recover_after_time: 5m
+{%- if server.get('gateway', {}).recover_after_time is defined %}
+gateway.recover_after_time: {{ server.gateway.recover_after_time }}
+{%- endif %}
 
 # Set how many nodes are expected in this cluster. Once these N nodes
 # are up (and recover_after_nodes is met), begin recovery process immediately
 # (without waiting for recover_after_time to expire):
 #
 # gateway.expected_nodes: 2
+{%- if server.get('gateway', {}).expected_nodes is defined %}
+gateway.expected_nodes: {{ server.gateway.expected_nodes }}
+{%- endif %}
 
 
 ############################# Recovery Throttling #############################
diff --git a/elasticsearch/files/es_template_kibana4.json b/elasticsearch/files/es_template_kibana4.json
new file mode 100644
index 0000000..5a910a4
--- /dev/null
+++ b/elasticsearch/files/es_template_kibana4.json
@@ -0,0 +1,135 @@
+{
+    "mappings" : {
+      "index-pattern" : {
+        "properties" : {
+          "fieldFormatMap" : {
+            "type" : "string"
+          },
+          "fields" : {
+            "type" : "string"
+          },
+          "intervalName" : {
+            "type" : "string"
+          },
+          "notExpandable" : {
+            "type" : "boolean"
+          },
+          "timeFieldName" : {
+            "type" : "string"
+          },
+          "title" : {
+            "type" : "string"
+          }
+        }
+      },
+      "config" : {
+        "properties" : {
+          "buildNum" : {
+            "type" : "string",
+            "index" : "not_analyzed"
+          }
+        }
+      },
+      "search" : {
+        "properties" : {
+          "columns" : {
+            "type" : "string"
+          },
+          "description" : {
+            "type" : "string"
+          },
+          "hits" : {
+            "type" : "integer"
+          },
+          "kibanaSavedObjectMeta" : {
+            "properties" : {
+              "searchSourceJSON" : {
+                "type" : "string"
+              }
+            }
+          },
+          "sort" : {
+            "type" : "string"
+          },
+          "title" : {
+            "type" : "string"
+          },
+          "version" : {
+            "type" : "integer"
+          }
+        }
+      },
+      "visualization" : {
+        "properties" : {
+          "description" : {
+            "type" : "string"
+          },
+          "kibanaSavedObjectMeta" : {
+            "properties" : {
+              "searchSourceJSON" : {
+                "type" : "string"
+              }
+            }
+          },
+          "savedSearchId" : {
+            "type" : "string"
+          },
+          "title" : {
+            "type" : "string"
+          },
+          "uiStateJSON" : {
+            "type" : "string"
+          },
+          "version" : {
+            "type" : "integer"
+          },
+          "visState" : {
+            "type" : "string"
+          }
+        }
+      },
+      "dashboard" : {
+        "properties" : {
+          "description" : {
+            "type" : "string"
+          },
+          "hits" : {
+            "type" : "integer"
+          },
+          "kibanaSavedObjectMeta" : {
+            "properties" : {
+              "searchSourceJSON" : {
+                "type" : "string"
+              }
+            }
+          },
+          "optionsJSON" : {
+            "type" : "string"
+          },
+          "panelsJSON" : {
+            "type" : "string"
+          },
+          "timeFrom" : {
+            "type" : "string"
+          },
+          "timeRestore" : {
+            "type" : "boolean"
+          },
+          "timeTo" : {
+            "type" : "string"
+          },
+          "title" : {
+            "type" : "string"
+          },
+          "uiStateJSON" : {
+            "type" : "string"
+          },
+          "version" : {
+            "type" : "integer"
+          }
+        }
+      }
+    },
+    "template": ".kibana"
+}
+
diff --git a/elasticsearch/files/es_template_log.json b/elasticsearch/files/es_template_log.json
new file mode 100644
index 0000000..1c3e7fb
--- /dev/null
+++ b/elasticsearch/files/es_template_log.json
@@ -0,0 +1,112 @@
+{
+    "mappings": {
+        "message": {
+            "properties": {
+                "Logger": {
+                    "index": "not_analyzed",
+                    "type": "string"
+                },
+                "Hostname": {
+                    "index": "not_analyzed",
+                    "type": "string"
+                },
+                "Pid": {
+                    "index": "not_analyzed",
+                    "type": "long"
+                },
+                "Severity": {
+                    "index": "not_analyzed",
+                    "type": "long"
+                },
+                "Type": {
+                    "index": "not_analyzed",
+                    "type": "string"
+                },
+                "programname": {
+                    "index": "not_analyzed",
+                    "type": "string"
+                },
+                "python_module": {
+                    "index": "not_analyzed",
+                    "type": "string"
+                },
+                "severity_label": {
+                    "index": "not_analyzed",
+                    "type": "string"
+                },
+                "environment_label": {
+                    "index": "not_analyzed",
+                    "type": "string"
+                },
+                "openstack_roles": {
+                    "type": "string",
+                    "analyzer": "ost_roles"
+                },
+                "openstack_region": {
+                    "index": "not_analyzed",
+                    "type": "string"
+                },
+                "openstack_release": {
+                    "index": "not_analyzed",
+                    "type": "string"
+                },
+                "deployment_id": {
+                    "index": "not_analyzed",
+                    "type": "string"
+                },
+                "request_id": {
+                    "index": "not_analyzed",
+                    "type": "string"
+                },
+                "tenant_id": {
+                    "index": "not_analyzed",
+                    "type": "string"
+                },
+                "user_id": {
+                    "index": "not_analyzed",
+                    "type": "string"
+                },
+                "instance_id": {
+                    "index": "not_analyzed",
+                    "type": "string"
+                },
+                "http_response_time": {
+                    "type": "float"
+                },
+                "http_status": {
+                    "type": "integer"
+                },
+                "http_method": {
+                    "index": "not_analyzed",
+                    "type": "string"
+                },
+                "http_url": {
+                    "index": "not_analyzed",
+                    "type": "string"
+                },
+                "http_version": {
+                    "index": "not_analyzed",
+                    "type": "string"
+                }
+            }
+        }
+    },
+    "settings": {
+        "analysis": {
+            "tokenizer": {
+                 "comma" : {
+                     "type": "pattern",
+                     "pattern": ","
+                 }
+            },
+            "analyzer": {
+                 "ost_roles": {
+                     "type": "custom",
+                     "tokenizer": "comma",
+                     "filter": ["lowercase"]
+                 }
+            }
+        }
+    },
+    "template": "log-*"
+}
diff --git a/elasticsearch/files/es_template_notification.json b/elasticsearch/files/es_template_notification.json
new file mode 100644
index 0000000..e19c907
--- /dev/null
+++ b/elasticsearch/files/es_template_notification.json
@@ -0,0 +1,109 @@
+{
+    "mappings": {
+        "message": {
+            "properties": {
+                "event_type": {
+                    "index": "not_analyzed",
+                    "type": "string"
+                },
+                "Payload": {
+                    "type": "string"
+                },
+                "Logger": {
+                    "index": "not_analyzed",
+                    "type": "string"
+                },
+                "programname": {
+                    "index": "not_analyzed",
+                    "type": "string"
+                },
+                "Hostname": {
+                    "index": "not_analyzed",
+                    "type": "string"
+                },
+                "hostname": {
+                    "index": "not_analyzed",
+                    "type": "string"
+                },
+                "Pid": {
+                    "index": "not_analyzed",
+                    "type": "long"
+                },
+                "Severity": {
+                    "index": "not_analyzed",
+                    "type": "long"
+                },
+                "syslogfacility": {
+                    "index": "not_analyzed",
+                    "type": "long"
+                },
+                "Type": {
+                    "index": "not_analyzed",
+                    "type": "string"
+                },
+                "severity_label": {
+                    "index": "not_analyzed",
+                    "type": "string"
+                },
+                "environment_label": {
+                    "index": "not_analyzed",
+                    "type": "string"
+                },
+                "openstack_role": {
+                    "type": "string",
+                    "analyzer": "ost_roles"
+                },
+                "openstack_region": {
+                    "index": "not_analyzed",
+                    "type": "string"
+                },
+                "openstack_release": {
+                    "index": "not_analyzed",
+                    "type": "string"
+                },
+                "deployment_id": {
+                    "index": "not_analyzed",
+                    "type": "string"
+                },
+                "request_id": {
+                    "index": "not_analyzed",
+                    "type": "string"
+                },
+                "tenant_id": {
+                    "index": "not_analyzed",
+                    "type": "string"
+                },
+                "user_id": {
+                    "index": "not_analyzed",
+                    "type": "string"
+                },
+                "launched_at": {
+                    "type": "date",
+                    "format": "dateOptionalTime"
+                },
+                "created_at": {
+                    "type": "date",
+                    "format": "dateOptionalTime"
+                }
+            }
+        }
+    },
+    "settings": {
+        "analysis": {
+            "tokenizer": {
+                 "comma" : {
+                     "type": "pattern",
+                     "pattern": ","
+                 }
+            },
+            "analyzer": {
+                 "ost_roles": {
+                     "type": "custom",
+                     "tokenizer": "comma",
+                     "filter": ["lowercase"]
+                 }
+            }
+        }
+    },
+    "template": "notification-*"
+}
diff --git a/elasticsearch/files/grafana_dashboards/elasticsearch_influxdb.json b/elasticsearch/files/grafana_dashboards/elasticsearch_influxdb.json
new file mode 100644
index 0000000..9eec5af
--- /dev/null
+++ b/elasticsearch/files/grafana_dashboards/elasticsearch_influxdb.json
@@ -0,0 +1,1317 @@
+{
+  "annotations": {
+    "list": [
+      {
+        "datasource": "lma",
+        "enable": true,
+        "iconColor": "#C0C6BE",
+        "iconSize": 13,
+        "lineColor": "rgba(255, 96, 96, 0.592157)",
+        "name": "Status",
+        "query": "select title,tags,text from annotations where $timeFilter and cluster = 'elasticsearch'",
+        "showLine": true,
+        "tagsColumn": "tags",
+        "textColumn": "text",
+        "titleColumn": "title"
+      }
+    ]
+  },
+  "editable": true,
+  "gnetId": null,
+  "hideControls": false,
+  "id": null,
+  "links": [],
+  "refresh": "1m",
+  "rows": [
+    {
+      "collapse": false,
+      "editable": true,
+      "height": "250px",
+      "panels": [
+        {
+          "cacheTimeout": null,
+          "colorBackground": true,
+          "colorValue": false,
+          "colors": [
+            "rgba(71, 212, 59, 0.4)",
+            "rgba(241, 181, 37, 0.73)",
+            "rgba(225, 40, 40, 0.59)"
+          ],
+          "datasource": null,
+          "editable": true,
+          "error": false,
+          "format": "none",
+          "gauge": {
+            "maxValue": 100,
+            "minValue": 0,
+            "show": false,
+            "thresholdLabels": false,
+            "thresholdMarkers": true
+          },
+          "id": 59,
+          "interval": "> 60s",
+          "links": [],
+          "mappingType": 1,
+          "mappingTypes": [
+            {
+              "name": "value to text",
+              "value": 1
+            },
+            {
+              "name": "range to text",
+              "value": 2
+            }
+          ],
+          "maxDataPoints": 100,
+          "nullPointMode": "connected",
+          "nullText": null,
+          "postfix": "",
+          "postfixFontSize": "50%",
+          "prefix": "",
+          "prefixFontSize": "50%",
+          "rangeMaps": [
+            {
+              "from": "null",
+              "text": "N/A",
+              "to": "null"
+            }
+          ],
+          "span": 2,
+          "sparkline": {
+            "fillColor": "rgba(31, 118, 189, 0.18)",
+            "full": false,
+            "lineColor": "rgb(31, 120, 193)",
+            "show": false
+          },
+          "targets": [
+            {
+              "column": "value",
+              "condition": "",
+              "dsType": "influxdb",
+              "fill": "",
+              "function": "last",
+              "groupBy": [],
+              "groupby_field": "",
+              "interval": "",
+              "measurement": "cluster_status",
+              "policy": "default",
+              "query": "SELECT last(\"value\") FROM \"cluster_status\" WHERE \"cluster_name\" = 'elasticsearch' AND $timeFilter",
+              "rawQuery": false,
+              "refId": "A",
+              "resultFormat": "time_series",
+              "select": [
+                [
+                  {
+                    "params": [
+                      "value"
+                    ],
+                    "type": "field"
+                  },
+                  {
+                    "params": [],
+                    "type": "last"
+                  }
+                ]
+              ],
+              "tags": [
+                {
+                  "key": "environment_label",
+                  "operator": "=~",
+                  "value": "/^$environment$/"
+                },
+                {
+                  "condition": "AND",
+                  "key": "cluster_name",
+                  "operator": "=",
+                  "value": "elasticsearch"
+                }
+              ]
+            }
+          ],
+          "thresholds": "1,3",
+          "title": "",
+          "type": "singlestat",
+          "valueFontSize": "80%",
+          "valueMaps": [
+            {
+              "op": "=",
+              "text": "no data",
+              "value": "null"
+            },
+            {
+              "op": "=",
+              "text": "OKAY",
+              "value": "0"
+            },
+            {
+              "op": "=",
+              "text": "WARN",
+              "value": "1"
+            },
+            {
+              "op": "=",
+              "text": "UNKW",
+              "value": "2"
+            },
+            {
+              "op": "=",
+              "text": "CRIT",
+              "value": "3"
+            },
+            {
+              "op": "=",
+              "text": "DOWN",
+              "value": "4"
+            }
+          ],
+          "valueName": "current"
+        },
+        {
+          "cacheTimeout": null,
+          "colorBackground": false,
+          "colorValue": false,
+          "colors": [
+            "rgba(245, 54, 54, 0.9)",
+            "rgba(237, 129, 40, 0.89)",
+            "rgba(50, 172, 45, 0.97)"
+          ],
+          "datasource": null,
+          "editable": true,
+          "error": false,
+          "format": "none",
+          "gauge": {
+            "maxValue": 100,
+            "minValue": 0,
+            "show": false,
+            "thresholdLabels": false,
+            "thresholdMarkers": true
+          },
+          "hideTimeOverride": false,
+          "id": 61,
+          "interval": ">60s",
+          "links": [],
+          "mappingType": 1,
+          "mappingTypes": [
+            {
+              "name": "value to text",
+              "value": 1
+            },
+            {
+              "name": "range to text",
+              "value": 2
+            }
+          ],
+          "maxDataPoints": 100,
+          "nullPointMode": "connected",
+          "nullText": null,
+          "postfix": "",
+          "postfixFontSize": "50%",
+          "prefix": "",
+          "prefixFontSize": "50%",
+          "rangeMaps": [
+            {
+              "from": "null",
+              "text": "N/A",
+              "to": "null"
+            }
+          ],
+          "span": 2,
+          "sparkline": {
+            "fillColor": "rgba(31, 118, 189, 0.18)",
+            "full": false,
+            "lineColor": "rgb(31, 120, 193)",
+            "show": false
+          },
+          "targets": [
+            {
+              "alias": "number",
+              "dsType": "influxdb",
+              "groupBy": [],
+              "measurement": "elasticsearch_cluster_number_of_nodes",
+              "policy": "default",
+              "query": "SELECT last(\"value\") FROM \"elasticsearch_cluster_number_of_nodes\" WHERE $timeFilter",
+              "rawQuery": false,
+              "refId": "A",
+              "resultFormat": "time_series",
+              "select": [
+                [
+                  {
+                    "params": [
+                      "value"
+                    ],
+                    "type": "field"
+                  },
+                  {
+                    "params": [],
+                    "type": "last"
+                  }
+                ]
+              ],
+              "tags": [
+                {
+                  "key": "environment_label",
+                  "operator": "=~",
+                  "value": "/^$environment$/"
+                }
+              ]
+            }
+          ],
+          "thresholds": "",
+          "timeFrom": null,
+          "timeShift": null,
+          "title": "Number of nodes",
+          "type": "singlestat",
+          "valueFontSize": "80%",
+          "valueMaps": [
+            {
+              "op": "=",
+              "text": "N/A",
+              "value": "null"
+            }
+          ],
+          "valueName": "current"
+        },
+        {
+          "aliasColors": {},
+          "bars": false,
+          "datasource": null,
+          "editable": true,
+          "error": false,
+          "fill": 0,
+          "grid": {
+            "threshold1": null,
+            "threshold1Color": "rgba(216, 200, 27, 0.27)",
+            "threshold2": null,
+            "threshold2Color": "rgba(234, 112, 112, 0.22)"
+          },
+          "id": 60,
+          "interval": ">60s",
+          "legend": {
+            "avg": false,
+            "current": false,
+            "max": false,
+            "min": false,
+            "show": true,
+            "total": false,
+            "values": false
+          },
+          "lines": true,
+          "linewidth": 2,
+          "links": [],
+          "nullPointMode": "connected",
+          "percentage": false,
+          "pointradius": 5,
+          "points": false,
+          "renderer": "flot",
+          "seriesOverrides": [],
+          "span": 4,
+          "stack": false,
+          "steppedLine": false,
+          "targets": [
+            {
+              "alias": "active primary",
+              "dsType": "influxdb",
+              "groupBy": [
+                {
+                  "params": [
+                    "auto"
+                  ],
+                  "type": "time"
+                }
+              ],
+              "measurement": "elasticsearch_cluster_active_primary_shards",
+              "policy": "default",
+              "query": "SELECT last(\"value\") FROM \"elasticsearch_cluster_active_primary_shards\" WHERE $timeFilter GROUP BY time($interval)",
+              "rawQuery": false,
+              "refId": "A",
+              "resultFormat": "time_series",
+              "select": [
+                [
+                  {
+                    "params": [
+                      "value"
+                    ],
+                    "type": "field"
+                  },
+                  {
+                    "params": [],
+                    "type": "last"
+                  }
+                ]
+              ],
+              "tags": [
+                {
+                  "key": "environment_label",
+                  "operator": "=",
+                  "value": "$environment"
+                }
+              ]
+            },
+            {
+              "alias": "active",
+              "dsType": "influxdb",
+              "groupBy": [
+                {
+                  "params": [
+                    "auto"
+                  ],
+                  "type": "time"
+                }
+              ],
+              "measurement": "elasticsearch_cluster_active_shards",
+              "policy": "default",
+              "query": "SELECT last(\"value\") FROM \"elasticsearch_cluster_active_shards\" WHERE $timeFilter GROUP BY time($interval)",
+              "rawQuery": false,
+              "refId": "B",
+              "resultFormat": "time_series",
+              "select": [
+                [
+                  {
+                    "params": [
+                      "value"
+                    ],
+                    "type": "field"
+                  },
+                  {
+                    "params": [],
+                    "type": "last"
+                  }
+                ]
+              ],
+              "tags": [
+                {
+                  "key": "environment_label",
+                  "operator": "=",
+                  "value": "$environment"
+                }
+              ]
+            },
+            {
+              "alias": "relocating",
+              "dsType": "influxdb",
+              "groupBy": [
+                {
+                  "params": [
+                    "auto"
+                  ],
+                  "type": "time"
+                }
+              ],
+              "measurement": "elasticsearch_cluster_relocating_shards",
+              "policy": "default",
+              "query": "SELECT last(\"value\") FROM \"elasticsearch_cluster_relocating_shards\" WHERE $timeFilter GROUP BY time($interval)",
+              "rawQuery": false,
+              "refId": "C",
+              "resultFormat": "time_series",
+              "select": [
+                [
+                  {
+                    "params": [
+                      "value"
+                    ],
+                    "type": "field"
+                  },
+                  {
+                    "params": [],
+                    "type": "last"
+                  }
+                ]
+              ],
+              "tags": [
+                {
+                  "key": "environment_label",
+                  "operator": "=",
+                  "value": "$environment"
+                }
+              ]
+            },
+            {
+              "alias": "unassigned",
+              "dsType": "influxdb",
+              "groupBy": [
+                {
+                  "params": [
+                    "auto"
+                  ],
+                  "type": "time"
+                }
+              ],
+              "measurement": "elasticsearch_cluster_unassigned_shards",
+              "policy": "default",
+              "query": "SELECT last(\"value\") FROM \"elasticsearch_cluster_unassigned_shards\" WHERE $timeFilter GROUP BY time($interval)",
+              "rawQuery": false,
+              "refId": "E",
+              "resultFormat": "time_series",
+              "select": [
+                [
+                  {
+                    "params": [
+                      "value"
+                    ],
+                    "type": "field"
+                  },
+                  {
+                    "params": [],
+                    "type": "last"
+                  }
+                ]
+              ],
+              "tags": [
+                {
+                  "key": "environment_label",
+                  "operator": "=",
+                  "value": "$environment"
+                }
+              ]
+            },
+            {
+              "alias": "initializing",
+              "dsType": "influxdb",
+              "groupBy": [
+                {
+                  "params": [
+                    "auto"
+                  ],
+                  "type": "time"
+                }
+              ],
+              "measurement": "elasticsearch_cluster_initializing_shards",
+              "policy": "default",
+              "query": "SELECT last(\"value\") FROM \"elasticsearch_cluster_initializing_shards\" WHERE $timeFilter GROUP BY time($interval)",
+              "rawQuery": false,
+              "refId": "D",
+              "resultFormat": "time_series",
+              "select": [
+                [
+                  {
+                    "params": [
+                      "value"
+                    ],
+                    "type": "field"
+                  },
+                  {
+                    "params": [],
+                    "type": "last"
+                  }
+                ]
+              ],
+              "tags": [
+                {
+                  "key": "environment_label",
+                  "operator": "=",
+                  "value": "$environment"
+                }
+              ]
+            }
+          ],
+          "timeFrom": null,
+          "timeShift": null,
+          "title": "Shards",
+          "tooltip": {
+            "msResolution": false,
+            "shared": true,
+            "sort": 0,
+            "value_type": "cumulative"
+          },
+          "type": "graph",
+          "xaxis": {
+            "show": true
+          },
+          "yaxes": [
+            {
+              "format": "short",
+              "label": "shards",
+              "logBase": 1,
+              "max": null,
+              "min": 0,
+              "show": true
+            },
+            {
+              "format": "short",
+              "logBase": 1,
+              "max": null,
+              "min": null,
+              "show": true
+            }
+          ]
+        },
+        {
+          "aliasColors": {},
+          "bars": false,
+          "datasource": null,
+          "editable": true,
+          "error": false,
+          "fill": 0,
+          "grid": {
+            "threshold1": null,
+            "threshold1Color": "rgba(216, 200, 27, 0.27)",
+            "threshold2": 10,
+            "threshold2Color": "rgba(234, 112, 112, 0.22)"
+          },
+          "id": 62,
+          "interval": ">60s",
+          "legend": {
+            "avg": false,
+            "current": false,
+            "hideEmpty": false,
+            "max": false,
+            "min": false,
+            "show": false,
+            "total": false,
+            "values": false
+          },
+          "lines": true,
+          "linewidth": 2,
+          "links": [],
+          "nullPointMode": "connected",
+          "percentage": false,
+          "pointradius": 5,
+          "points": false,
+          "renderer": "flot",
+          "seriesOverrides": [],
+          "span": 4,
+          "stack": false,
+          "steppedLine": false,
+          "targets": [
+            {
+              "alias": "tasks",
+              "dsType": "influxdb",
+              "groupBy": [
+                {
+                  "params": [
+                    "auto"
+                  ],
+                  "type": "time"
+                }
+              ],
+              "measurement": "elasticsearch_cluster_number_of_pending_tasks",
+              "policy": "default",
+              "query": "SELECT last(\"value\") FROM \"elasticsearch_cluster_number_of_pending_tasks\" WHERE $timeFilter GROUP BY time($interval)",
+              "rawQuery": false,
+              "refId": "A",
+              "resultFormat": "time_series",
+              "select": [
+                [
+                  {
+                    "params": [
+                      "value"
+                    ],
+                    "type": "field"
+                  },
+                  {
+                    "params": [],
+                    "type": "last"
+                  }
+                ]
+              ],
+              "tags": [
+                {
+                  "key": "environment_label",
+                  "operator": "=",
+                  "value": "$environment"
+                }
+              ]
+            }
+          ],
+          "timeFrom": null,
+          "timeShift": null,
+          "title": "Pending tasks",
+          "tooltip": {
+            "msResolution": false,
+            "shared": true,
+            "sort": 0,
+            "value_type": "cumulative"
+          },
+          "type": "graph",
+          "xaxis": {
+            "show": true
+          },
+          "yaxes": [
+            {
+              "format": "short",
+              "label": "tasks",
+              "logBase": 1,
+              "max": null,
+              "min": 0,
+              "show": true
+            },
+            {
+              "format": "short",
+              "logBase": 1,
+              "max": null,
+              "min": null,
+              "show": true
+            }
+          ]
+        }
+      ],
+      "showTitle": true,
+      "title": "Cluster"
+    },
+    {
+      "collapse": false,
+      "editable": true,
+      "height": "200px",
+      "panels": [
+        {
+          "cacheTimeout": null,
+          "colorBackground": false,
+          "colorValue": false,
+          "colors": [
+            "rgba(245, 54, 54, 0.9)",
+            "rgba(237, 129, 40, 0.89)",
+            "rgba(50, 172, 45, 0.97)"
+          ],
+          "datasource": null,
+          "editable": true,
+          "error": false,
+          "format": "none",
+          "gauge": {
+            "maxValue": 100,
+            "minValue": 0,
+            "show": false,
+            "thresholdLabels": false,
+            "thresholdMarkers": true
+          },
+          "id": 32,
+          "interval": "> 60s",
+          "links": [],
+          "mappingType": 1,
+          "mappingTypes": [
+            {
+              "name": "value to text",
+              "value": 1
+            },
+            {
+              "name": "range to text",
+              "value": 2
+            }
+          ],
+          "maxDataPoints": 100,
+          "nullPointMode": "connected",
+          "nullText": null,
+          "postfix": "",
+          "postfixFontSize": "50%",
+          "prefix": "",
+          "prefixFontSize": "50%",
+          "rangeMaps": [
+            {
+              "from": "null",
+              "text": "N/A",
+              "to": "null"
+            }
+          ],
+          "span": 2,
+          "sparkline": {
+            "fillColor": "rgba(31, 118, 189, 0.18)",
+            "full": false,
+            "lineColor": "rgb(31, 120, 193)",
+            "show": true
+          },
+          "targets": [
+            {
+              "column": "value",
+              "dsType": "influxdb",
+              "function": "last",
+              "groupBy": [],
+              "measurement": "lma_components_threads",
+              "policy": "default",
+              "query": "SELECT last(\"value\") FROM \"lma_components_threads\" WHERE \"service\" = 'elasticsearch' AND \"hostname\" =~ /^$server$/ AND $timeFilter",
+              "rawQuery": false,
+              "refId": "A",
+              "resultFormat": "time_series",
+              "select": [
+                [
+                  {
+                    "params": [
+                      "value"
+                    ],
+                    "type": "field"
+                  },
+                  {
+                    "params": [],
+                    "type": "last"
+                  }
+                ]
+              ],
+              "tags": [
+                {
+                  "key": "service",
+                  "operator": "=",
+                  "value": "elasticsearch"
+                },
+                {
+                  "condition": "AND",
+                  "key": "hostname",
+                  "operator": "=~",
+                  "value": "/^$server$/"
+                }
+              ]
+            }
+          ],
+          "thresholds": "",
+          "title": "Threads",
+          "type": "singlestat",
+          "valueFontSize": "80%",
+          "valueMaps": [
+            {
+              "op": "=",
+              "text": "N/A",
+              "value": "null"
+            }
+          ],
+          "valueName": "current"
+        },
+        {
+          "aliasColors": {},
+          "bars": false,
+          "datasource": null,
+          "editable": true,
+          "error": false,
+          "fill": 0,
+          "grid": {
+            "threshold1": null,
+            "threshold1Color": "rgba(216, 200, 27, 0.27)",
+            "threshold2": null,
+            "threshold2Color": "rgba(234, 112, 112, 0.22)"
+          },
+          "id": 31,
+          "interval": "> 60s",
+          "legend": {
+            "alignAsTable": false,
+            "avg": false,
+            "current": true,
+            "max": true,
+            "min": true,
+            "show": false,
+            "total": false,
+            "values": false
+          },
+          "lines": true,
+          "linewidth": 1,
+          "links": [],
+          "nullPointMode": "connected",
+          "percentage": false,
+          "pointradius": 5,
+          "points": false,
+          "renderer": "flot",
+          "seriesOverrides": [],
+          "span": 3,
+          "stack": false,
+          "steppedLine": false,
+          "targets": [
+            {
+              "alias": "rss",
+              "column": "value",
+              "dsType": "influxdb",
+              "function": "mean",
+              "groupBy": [
+                {
+                  "params": [
+                    "auto"
+                  ],
+                  "type": "time"
+                },
+                {
+                  "params": [
+                    "previous"
+                  ],
+                  "type": "fill"
+                }
+              ],
+              "measurement": "lma_components_memory_rss",
+              "policy": "default",
+              "query": "SELECT mean(\"value\") FROM \"lma_components_memory_rss\" WHERE \"service\" = 'elasticsearch' AND \"hostname\" =~ /^$server$/ AND $timeFilter GROUP BY time($interval) fill(previous)",
+              "rawQuery": false,
+              "refId": "A",
+              "resultFormat": "time_series",
+              "select": [
+                [
+                  {
+                    "params": [
+                      "value"
+                    ],
+                    "type": "field"
+                  },
+                  {
+                    "params": [],
+                    "type": "mean"
+                  }
+                ]
+              ],
+              "tags": [
+                {
+                  "key": "service",
+                  "operator": "=",
+                  "value": "elasticsearch"
+                },
+                {
+                  "condition": "AND",
+                  "key": "hostname",
+                  "operator": "=",
+                  "value": "$server"
+                }
+              ]
+            }
+          ],
+          "timeFrom": null,
+          "timeShift": null,
+          "title": "Resident Set Size",
+          "tooltip": {
+            "msResolution": false,
+            "shared": true,
+            "sort": 0,
+            "value_type": "cumulative"
+          },
+          "type": "graph",
+          "xaxis": {
+            "show": true
+          },
+          "yaxes": [
+            {
+              "format": "bytes",
+              "logBase": 1,
+              "max": null,
+              "min": 0,
+              "show": true
+            },
+            {
+              "format": "short",
+              "logBase": 1,
+              "max": null,
+              "min": null,
+              "show": true
+            }
+          ]
+        },
+        {
+          "aliasColors": {},
+          "bars": false,
+          "datasource": null,
+          "editable": true,
+          "error": false,
+          "fill": 0,
+          "grid": {
+            "threshold1": null,
+            "threshold1Color": "rgba(216, 200, 27, 0.27)",
+            "threshold2": null,
+            "threshold2Color": "rgba(234, 112, 112, 0.22)"
+          },
+          "id": 33,
+          "interval": "> 60s",
+          "legend": {
+            "alignAsTable": false,
+            "avg": false,
+            "current": true,
+            "max": true,
+            "min": true,
+            "show": true,
+            "total": false,
+            "values": false
+          },
+          "lines": true,
+          "linewidth": 1,
+          "links": [],
+          "nullPointMode": "connected",
+          "percentage": false,
+          "pointradius": 5,
+          "points": false,
+          "renderer": "flot",
+          "seriesOverrides": [],
+          "span": 3,
+          "stack": false,
+          "steppedLine": false,
+          "targets": [
+            {
+              "alias": "read",
+              "column": "value",
+              "dsType": "influxdb",
+              "function": "mean",
+              "groupBy": [
+                {
+                  "params": [
+                    "auto"
+                  ],
+                  "type": "time"
+                },
+                {
+                  "params": [
+                    "0"
+                  ],
+                  "type": "fill"
+                }
+              ],
+              "measurement": "lma_components_disk_bytes_read",
+              "policy": "default",
+              "query": "SELECT mean(\"value\") FROM \"lma_components_disk_bytes_read\" WHERE \"service\" = 'elasticsearch' AND \"hostname\" =~ /^$server$/ AND $timeFilter GROUP BY time($interval) fill(0)",
+              "rawQuery": false,
+              "refId": "A",
+              "resultFormat": "time_series",
+              "select": [
+                [
+                  {
+                    "params": [
+                      "value"
+                    ],
+                    "type": "field"
+                  },
+                  {
+                    "params": [],
+                    "type": "mean"
+                  }
+                ]
+              ],
+              "tags": [
+                {
+                  "key": "service",
+                  "operator": "=",
+                  "value": "elasticsearch"
+                },
+                {
+                  "condition": "AND",
+                  "key": "hostname",
+                  "operator": "=",
+                  "value": "$server"
+                }
+              ]
+            },
+            {
+              "alias": "write",
+              "column": "value",
+              "dsType": "influxdb",
+              "function": "mean",
+              "groupBy": [
+                {
+                  "params": [
+                    "auto"
+                  ],
+                  "type": "time"
+                },
+                {
+                  "params": [
+                    "0"
+                  ],
+                  "type": "fill"
+                }
+              ],
+              "measurement": "lma_components_disk_bytes_write",
+              "policy": "default",
+              "query": "SELECT mean(\"value\") FROM \"lma_components_disk_bytes_write\" WHERE \"service\" = 'elasticsearch' AND \"hostname\" =~ /^$server$/ AND $timeFilter GROUP BY time($interval) fill(0)",
+              "rawQuery": false,
+              "refId": "B",
+              "resultFormat": "time_series",
+              "select": [
+                [
+                  {
+                    "params": [
+                      "value"
+                    ],
+                    "type": "field"
+                  },
+                  {
+                    "params": [],
+                    "type": "mean"
+                  }
+                ]
+              ],
+              "tags": [
+                {
+                  "key": "service",
+                  "operator": "=",
+                  "value": "elasticsearch"
+                },
+                {
+                  "condition": "AND",
+                  "key": "hostname",
+                  "operator": "=",
+                  "value": "$server"
+                }
+              ]
+            }
+          ],
+          "timeFrom": null,
+          "timeShift": null,
+          "title": "Disk I/O",
+          "tooltip": {
+            "msResolution": false,
+            "shared": true,
+            "sort": 0,
+            "value_type": "cumulative"
+          },
+          "type": "graph",
+          "xaxis": {
+            "show": true
+          },
+          "yaxes": [
+            {
+              "format": "bytes",
+              "label": "bytes/sec",
+              "logBase": 1,
+              "max": null,
+              "min": 0,
+              "show": true
+            },
+            {
+              "format": "short",
+              "logBase": 1,
+              "max": null,
+              "min": null,
+              "show": true
+            }
+          ]
+        },
+        {
+          "aliasColors": {},
+          "bars": false,
+          "datasource": null,
+          "editable": true,
+          "error": false,
+          "fill": 1,
+          "grid": {
+            "threshold1": null,
+            "threshold1Color": "rgba(216, 200, 27, 0.27)",
+            "threshold2": null,
+            "threshold2Color": "rgba(234, 112, 112, 0.22)"
+          },
+          "id": 36,
+          "interval": "> 60s",
+          "legend": {
+            "avg": false,
+            "current": false,
+            "max": false,
+            "min": false,
+            "show": true,
+            "total": false,
+            "values": false
+          },
+          "lines": true,
+          "linewidth": 1,
+          "links": [],
+          "nullPointMode": "connected",
+          "percentage": false,
+          "pointradius": 5,
+          "points": false,
+          "renderer": "flot",
+          "seriesOverrides": [],
+          "span": 4,
+          "stack": true,
+          "steppedLine": false,
+          "targets": [
+            {
+              "alias": "system",
+              "column": "value",
+              "dsType": "influxdb",
+              "function": "mean",
+              "groupBy": [
+                {
+                  "params": [
+                    "auto"
+                  ],
+                  "type": "time"
+                },
+                {
+                  "params": [
+                    "0"
+                  ],
+                  "type": "fill"
+                }
+              ],
+              "measurement": "lma_components_cputime_syst",
+              "policy": "default",
+              "query": "SELECT mean(\"value\") FROM \"lma_components_cputime_syst\" WHERE \"service\" = 'elasticsearch' AND \"hostname\" =~ /^$server$/ AND $timeFilter GROUP BY time($interval) fill(0)",
+              "rawQuery": false,
+              "refId": "A",
+              "resultFormat": "time_series",
+              "select": [
+                [
+                  {
+                    "params": [
+                      "value"
+                    ],
+                    "type": "field"
+                  },
+                  {
+                    "params": [],
+                    "type": "mean"
+                  }
+                ]
+              ],
+              "tags": [
+                {
+                  "key": "service",
+                  "operator": "=",
+                  "value": "elasticsearch"
+                },
+                {
+                  "condition": "AND",
+                  "key": "hostname",
+                  "operator": "=",
+                  "value": "$server"
+                }
+              ]
+            },
+            {
+              "alias": "user",
+              "column": "value",
+              "dsType": "influxdb",
+              "function": "mean",
+              "groupBy": [
+                {
+                  "params": [
+                    "auto"
+                  ],
+                  "type": "time"
+                },
+                {
+                  "params": [
+                    "0"
+                  ],
+                  "type": "fill"
+                }
+              ],
+              "measurement": "lma_components_cputime_user",
+              "policy": "default",
+              "query": "SELECT mean(\"value\") FROM \"lma_components_cputime_user\" WHERE \"service\" = 'elasticsearch' AND \"hostname\" =~ /^$server$/ AND $timeFilter GROUP BY time($interval) fill(0)",
+              "rawQuery": false,
+              "refId": "B",
+              "resultFormat": "time_series",
+              "select": [
+                [
+                  {
+                    "params": [
+                      "value"
+                    ],
+                    "type": "field"
+                  },
+                  {
+                    "params": [],
+                    "type": "mean"
+                  }
+                ]
+              ],
+              "tags": [
+                {
+                  "key": "service",
+                  "operator": "=",
+                  "value": "elasticsearch"
+                },
+                {
+                  "condition": "AND",
+                  "key": "hostname",
+                  "operator": "=",
+                  "value": "$server"
+                }
+              ]
+            }
+          ],
+          "timeFrom": null,
+          "timeShift": null,
+          "title": "CPU usage",
+          "tooltip": {
+            "msResolution": false,
+            "shared": true,
+            "sort": 0,
+            "value_type": "individual"
+          },
+          "type": "graph",
+          "xaxis": {
+            "show": true
+          },
+          "yaxes": [
+            {
+              "format": "percent",
+              "logBase": 1,
+              "max": null,
+              "min": 0,
+              "show": true
+            },
+            {
+              "format": "short",
+              "logBase": 1,
+              "max": null,
+              "min": null,
+              "show": true
+            }
+          ]
+        }
+      ],
+      "showTitle": true,
+      "title": "Instance $server"
+    }
+  ],
+  "schemaVersion": 12,
+  "sharedCrosshair": true,
+  "style": "dark",
+  "tags": [],
+  "templating": {
+    "enable": true,
+    "list": [
+      {
+        "allFormat": "regex values",
+        "current": {},
+        "datasource": null,
+        "hide": 0,
+        "includeAll": false,
+        "name": "environment",
+        "options": [],
+        "query": "show tag values from cpu_idle with key = environment_label",
+        "refresh": 1,
+        "refresh_on_load": true,
+        "regex": "",
+        "type": "query"
+      },
+      {
+        "allFormat": "glob",
+        "current": {},
+        "datasource": null,
+        "hide": 0,
+        "includeAll": false,
+        "name": "server",
+        "options": [],
+        "query": "show tag values from elasticsearch_cluster_health with key = \"hostname\" where environment_label =~ /^$environment$/",
+        "refresh": 1,
+        "refresh_on_load": true,
+        "regex": "",
+        "type": "query"
+      }
+    ]
+  },
+  "time": {
+    "from": "now-1h",
+    "to": "now"
+  },
+  "timepicker": {
+    "collapse": false,
+    "enable": true,
+    "notice": false,
+    "now": true,
+    "refresh_intervals": [
+      "5s",
+      "10s",
+      "30s",
+      "1m",
+      "5m",
+      "15m",
+      "30m",
+      "1h",
+      "2h",
+      "1d"
+    ],
+    "status": "Stable",
+    "time_options": [
+      "5m",
+      "15m",
+      "1h",
+      "6h",
+      "12h",
+      "24h",
+      "2d",
+      "7d",
+      "30d"
+    ],
+    "type": "timepicker"
+  },
+  "timezone": "browser",
+  "title": "Elasticsearch",
+  "version": 4
+}
diff --git a/elasticsearch/init.sls b/elasticsearch/init.sls
index fadf2bf..d6078be 100644
--- a/elasticsearch/init.sls
+++ b/elasticsearch/init.sls
@@ -1,5 +1,10 @@
 
-{% if pillar.elasticsearch.server is defined %}
+{%- if pillar.elasticsearch is defined %}
 include:
+{%- if pillar.elasticsearch.server is defined %}
 - elasticsearch.server
-{% endif %}
+{%- endif %}
+{%- if pillar.elasticsearch.client is defined %}
+- elasticsearch.client
+{%- endif %}
+{%- endif %}
diff --git a/elasticsearch/map.jinja b/elasticsearch/map.jinja
index 000a1f4..36dd674 100644
--- a/elasticsearch/map.jinja
+++ b/elasticsearch/map.jinja
@@ -18,3 +18,20 @@
 {%- endload %}
 
 {%- set server = salt['grains.filter_by'](base_defaults, merge=salt['pillar.get']('elasticsearch:server')) %}
+
+{%- load_yaml as client_defaults %}
+Debian:
+  pkgs:
+  - python-elasticsearch
+  server:
+    host: 127.0.0.1
+    port: 9200
+RedHat:
+  pkgs:
+  - python-elasticsearch
+  server:
+    host: 127.0.0.1
+    port: 9200
+{%- endload %}
+
+{%- set client = salt['grains.filter_by'](client_defaults, merge=salt['pillar.get']('elasticsearch:client')) %}
diff --git a/elasticsearch/meta/collectd.yml b/elasticsearch/meta/collectd.yml
new file mode 100644
index 0000000..9da665f
--- /dev/null
+++ b/elasticsearch/meta/collectd.yml
@@ -0,0 +1,16 @@
+{%- if pillar.elasticsearch.server is defined %}
+{%- from "elasticsearch/map.jinja" import server with context %}
+
+{%- if server.get('enabled', False) %}
+local_plugin:
+  elasticsearch_cluster:
+    plugin: python
+    template: elasticsearch/files/collectd_elasticsearch_cluster.conf
+    address: {{ server.get('bind', {}).get('address', '127.0.0.1') }}
+    port: {{ server.get('bind', {}).get('port', 9200) }}
+  collectd_processes:
+    process:
+      elasticsearch:
+        match: 'java.*elasticsearch'
+{%- endif %}
+{%- endif %}
diff --git a/elasticsearch/meta/grafana.yml b/elasticsearch/meta/grafana.yml
new file mode 100644
index 0000000..366db70
--- /dev/null
+++ b/elasticsearch/meta/grafana.yml
@@ -0,0 +1,4 @@
+dashboard:
+  elasticsearch:
+    format: json
+    template: elasticsearch/files/grafana_dashboards/elasticsearch_influxdb.json
diff --git a/elasticsearch/meta/heka.yml b/elasticsearch/meta/heka.yml
new file mode 100644
index 0000000..90b3ae7
--- /dev/null
+++ b/elasticsearch/meta/heka.yml
@@ -0,0 +1,80 @@
+{%- if pillar.elasticsearch.server is defined %}
+metric_collector:
+  trigger:
+    elasticsearch_check:
+      description: 'Elasticsearch cannot be checked'
+      severity: down
+      rules:
+      - metric: elasticsearch_check
+        relational_operator: '=='
+        threshold: 0
+        window: 60
+        periods: 0
+        function: last
+    elasticsearch_health_critical:
+      description: 'Elasticsearch cluster health is critical'
+      severity: critical
+      rules:
+      - metric: elasticsearch_cluster_health
+        relational_operator: '=='
+        threshold: 3 # red
+        window: 60
+        function: min
+    elasticsearch_health_warning:
+      description: 'Elasticsearch cluster health is warning'
+      severity: warning
+      rules:
+      - metric: elasticsearch_cluster_health
+        relational_operator: '=='
+        threshold: 2 # yellow
+        window: 60
+        function: min
+  alarm:
+    elasticsearch_check:
+      alerting: enabled
+      triggers:
+      - elasticsearch_check
+      dimension:
+        service: elasticsearch
+    elasticsearch_health:
+      alerting: enabled
+      triggers:
+      - elasticsearch_health_critical
+      - elasticsearch_health_warning
+      dimension:
+        cluster: elasticsearch
+aggregator:
+  alarm_cluster:
+    elasticsearch_service:
+      policy: majority_of_members
+      alerting: enabled
+      group_by: hostname
+      match:
+        service: elasticsearch
+      members:
+      - elasticsearch_check
+      dimension:
+        service: elasticsearch-cluster
+        nagios_host: 01-service-clusters
+    elasticsearch_cluster:
+      policy: highest_severity
+      alerting: enabled
+      match:
+        cluster: elasticsearch
+      members:
+      - elasticsearch_health
+      dimension:
+        service: elasticsearch-cluster
+        nagios_host: 01-service-clusters
+    elasticsearch:
+      policy: highest_severity
+      alerting: enabled_with_notification
+      match:
+        service: elasticsearch-cluster
+      members:
+      - elasticsearch_service
+      - elasticsearch_cluster
+      dimension:
+        cluster_name: elasticsearch
+        nagios_host: 00-top-clusters
+{%- endif %}
diff --git a/metadata/service/client.yml b/metadata/service/client.yml
new file mode 100644
index 0000000..fc57c7c
--- /dev/null
+++ b/metadata/service/client.yml
@@ -0,0 +1,16 @@
+applications:
+- elasticsearch.client
+parameters:
+  elasticsearch:
+    client:
+      enabled: true
+      index:
+        log:
+          enabled: true
+          template: elasticsearch/files/es_template_log.json
+        notification:
+          enabled: true
+          template: elasticsearch/files/es_template_notification.json
+        kibana4:
+          enabled: true
+          template: elasticsearch/files/es_template_kibana4.json
diff --git a/metadata/service/server/local.yml b/metadata/service/server/local.yml
index e3572ea..259f468 100644
--- a/metadata/service/server/local.yml
+++ b/metadata/service/server/local.yml
@@ -10,7 +10,6 @@
         address: 127.0.0.1
         port: 9200
       index:
-        shards: 1
         replicas: 0
       cluster:
         multicast: false
diff --git a/metadata/service/server/single.yml b/metadata/service/server/single.yml
index a77268e..264186c 100644
--- a/metadata/service/server/single.yml
+++ b/metadata/service/server/single.yml
@@ -10,7 +10,6 @@
         address: 0.0.0.0
         port: 9200
       index:
-        shards: 1
         replicas: 0
       cluster:
         multicast: false
diff --git a/metadata/service/support.yml b/metadata/service/support.yml
index b851c62..1ee587a 100644
--- a/metadata/service/support.yml
+++ b/metadata/service/support.yml
@@ -2,10 +2,12 @@
   elasticsearch:
     _support:
       collectd:
-        enabled: false
+        enabled: true
       heka:
         enabled: true
       sensu:
         enabled: true
       sphinx:
         enabled: true
+      grafana:
+        enabled: true