Merge pull request #19 from tcpcloud/stacklight
Stacklight
diff --git a/metadata/service/support.yml b/metadata/service/support.yml
index 54d08d7..d9b8ab1 100644
--- a/metadata/service/support.yml
+++ b/metadata/service/support.yml
@@ -9,3 +9,5 @@
enabled: true
sphinx:
enabled: true
+ grafana:
+ enabled: true
diff --git a/nginx/files/collectd_nginx.conf b/nginx/files/collectd_nginx.conf
index 2a98127..2c55706 100644
--- a/nginx/files/collectd_nginx.conf
+++ b/nginx/files/collectd_nginx.conf
@@ -1,13 +1,7 @@
-{%- from "nginx/map.jinja" import server with context %}
-
<LoadPlugin nginx>
Globals false
</LoadPlugin>
-{%- if server.site.nginx_stats_server is defined %}
-
<Plugin nginx>
- URL "http://localhost:{{ server.site.nginx_stats_server.host.port }}"
+ URL "{{ plugin.url }}"
</Plugin>
-
-{%- endif %}
diff --git a/nginx/files/collectd_nginx_check.conf b/nginx/files/collectd_nginx_check.conf
new file mode 100644
index 0000000..325c5e4
--- /dev/null
+++ b/nginx/files/collectd_nginx_check.conf
@@ -0,0 +1,6 @@
+Import "collectd_nginx_check"
+
+<Module "collectd_nginx_check">
+ Url "{{ plugin.url }}"
+</Module>
+
diff --git a/nginx/files/grafana_influxdb.json b/nginx/files/grafana_influxdb.json
new file mode 100644
index 0000000..62c4781
--- /dev/null
+++ b/nginx/files/grafana_influxdb.json
@@ -0,0 +1,158 @@
+{
+ "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": null,
+ "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"
+ }
+ ],
+ "refresh": "1m",
+ "sharedCrosshair": true,
+ "span": 3,
+ "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": [
+ {
+ "params": [
+ "$interval"
+ ],
+ "type": "time"
+ },
+ {
+ "params": [
+ "null"
+ ],
+ "type": "fill"
+ }
+ ],
+ "groupByTags": [],
+ "groupby_field": "",
+ "interval": "",
+ "measurement": "cluster_status",
+ "policy": "default",
+ "query": "SELECT last(\"value\") FROM \"cluster_status\" WHERE \"environment_label\" =~ /^$environment$/ AND \"cluster_name\" = 'memcached' AND $timeFilter GROUP BY time($interval) fill(null)",
+ "rawQuery": false,
+ "refId": "A",
+ "resultFormat": "time_series",
+ "select": [
+ [
+ {
+ "params": [
+ "value"
+ ],
+ "type": "field"
+ },
+ {
+ "params": [],
+ "type": "last"
+ }
+ ]
+ ],
+ "tags": [
+ {
+ "key": "environment_label",
+ "operator": "=",
+ "value": "$environment"
+ },
+ {
+ "key": "cluster_name",
+ "operator": "=",
+ "value": "memcached"
+ }
+ ]
+ }
+ ],
+ "thresholds": "1,3",
+ "time": {
+ "from": "now-1h",
+ "to": "now"
+ },
+ "title": "",
+ "type": "singlestat",
+ "valueFontSize": "80%",
+ "valueMaps": [
+ {
+ "op": "=",
+ "text": "no data",
+ "value": "null"
+ },
+ {
+ "op": "=",
+ "text": "OKAY",
+ "value": "0"
+ },
+ {
+ "op": "=",
+ "text": "WARN",
+ "value": "1"
+ },
+ {
+ "op": "=",
+ "text": "UNKN",
+ "value": "2"
+ },
+ {
+ "op": "=",
+ "text": "CRIT",
+ "value": "3"
+ },
+ {
+ "op": "=",
+ "text": "DOWN",
+ "value": "4"
+ }
+ ],
+ "valueName": "current",
+ "version": 2
+}
\ No newline at end of file
diff --git a/nginx/meta/collectd.yml b/nginx/meta/collectd.yml
index c859306..3a9af83 100644
--- a/nginx/meta/collectd.yml
+++ b/nginx/meta/collectd.yml
@@ -1,6 +1,15 @@
+{%- if pillar.nginx.server is defined %}
+{%- from "nginx/map.jinja" import server with context %}
-plugin:
- nginx_server_status:
+{%- if server.get('enabled', False) and server.get('site', {}).nginx_stats_server is defined %}
+local_plugin:
+ collectd_nginx:
plugin: nginx
- execution: local
template: nginx/files/collectd_nginx.conf
+ url: http://localhost:{{ server.site.nginx_stats_server.host.port }}
+ collectd_nginx_check:
+ plugin: python
+ template: nginx/files/collectd_nginx_check.conf
+ url: http://localhost:{{ server.site.nginx_stats_server.host.port }}
+{%- endif %}
+{%- endif %}
diff --git a/nginx/meta/grafana.yml b/nginx/meta/grafana.yml
new file mode 100644
index 0000000..a03677a
--- /dev/null
+++ b/nginx/meta/grafana.yml
@@ -0,0 +1,4 @@
+dashboard:
+ nginx:
+ format: json
+ template: nginx/files/grafana_influxdb.json
diff --git a/nginx/meta/heka.yml b/nginx/meta/heka.yml
index e69de29..d3c4f63 100644
--- a/nginx/meta/heka.yml
+++ b/nginx/meta/heka.yml
@@ -0,0 +1,35 @@
+{%- from "nginx/map.jinja" import server with context %}
+{%- if server.get('enabled', False) and server.get('site', {}).nginx_stats_server is defined %}
+metric_collector:
+ trigger:
+ nginx_check:
+ description: 'nginx cannot be checked'
+ severity: down
+ rules:
+ - metric: nginx_check
+ relational_operator: '=='
+ threshold: 0
+ window: 60
+ periods: 0
+ function: last
+ alarm:
+ nginx_check:
+ alerting: enabled
+ triggers:
+ - nginx_check
+ dimension:
+ service: nginx
+aggregator:
+ alarm_cluster:
+ nginx_check:
+ policy: majority_of_members
+ alerting: enabled_with_notification
+ match:
+ service: nginx
+ group_by: hostname
+ members:
+ - nginx_check
+ dimension:
+ cluster_name: nginx
+ nagios_host: 00-top-clusters
+{%- endif %}