Merge pull request #39 from SwannCroiset/nagios-alarm
Add Nagios outputs
diff --git a/heka/_service.sls b/heka/_service.sls
index c1c85ed..8a09ea7 100644
--- a/heka/_service.sls
+++ b/heka/_service.sls
@@ -78,8 +78,6 @@
'decoder': {},
'input': {},
'trigger': {},
- 'alarm': {},
- 'alarm_cluster': {},
'filter': {},
'splitter': {},
'encoder': {},
@@ -90,7 +88,6 @@
'input': {},
'trigger': {},
'alarm': {},
- 'alarm_cluster': {},
'filter': {},
'splitter': {},
'encoder': {},
@@ -101,7 +98,6 @@
'input': {},
'trigger': {},
'alarm': {},
- 'alarm_cluster': {},
'filter': {},
'splitter': {},
'encoder': {},
@@ -111,7 +107,6 @@
'decoder': {},
'input': {},
'trigger': {},
- 'alarm': {},
'alarm_cluster': {},
'filter': {},
'splitter': {},
diff --git a/heka/files/gse_policies.lua b/heka/files/gse_policies.lua
index 8ec9c06..8de8175 100644
--- a/heka/files/gse_policies.lua
+++ b/heka/files/gse_policies.lua
@@ -29,15 +29,17 @@
logical_operator = '{{ _trigger["logical_operator"] }}',
rules = {
{%- for _rule in _trigger["rules"] %}
- ['function'] = '{{ _rule["function"] }}',
+ {
+ ['function'] = '{{ _rule["function"] }}',
{%- set comma = joiner(",") %}
- ['arguments'] = {
+ ['arguments'] = {
{%- for _argument in _rule["arguments"]|sort -%}
- {{ comma() }}'{{ _argument }}'
+ {{ comma() }}'{{ _argument }}'
{%- endfor -%}
+ },
+ ['relational_operator'] = '{{ _rule["relational_operator"] }}',
+ ['threshold'] = {{ _rule["threshold"] }},
},
- ['relational_operator'] = '{{ _rule["relational_operator"] }}',
- ['threshold'] = {{ _rule["threshold"] }},
{%- endfor %}
},
},
diff --git a/heka/files/lua/decoders/collectd.lua b/heka/files/lua/decoders/collectd.lua
index f94a0e8..0befcf0 100644
--- a/heka/files/lua/decoders/collectd.lua
+++ b/heka/files/lua/decoders/collectd.lua
@@ -216,6 +216,14 @@
else
msg['Fields']['name'] = metric_name
end
+ elseif metric_source == 'ntpd' then
+ if sample['type_instance'] == 'error' or sample['type_instance'] == 'loop' then
+ msg['Fields']['name'] = 'ntp' .. sep .. sample['type'] .. sep .. sample['type_instance']
+ else
+ msg['Fields']['name'] = 'ntp' .. sep .. sample['type'] .. sep .. 'peer'
+ msg['Fields']['server'] = sample['type_instance']
+ table.insert(msg['Fields']['tag_fields'], 'server')
+ end
elseif metric_source == 'check_openstack_api' then
-- For OpenStack API metrics, plugin_instance = <service name>
msg['Fields']['name'] = 'openstack_check_api'
@@ -420,7 +428,31 @@
msg['Fields']['service'] = sample['type_instance']
table.insert(msg['Fields']['tag_fields'], 'service')
else
- msg['Fields']['name'] = replace_dot_by_sep(metric_name)
+ -- generic metric name translation for 3rd-party sources
+ msg['Fields']['name'] = sample['plugin']
+ if sample['plugin_instance'] ~= "" then
+ msg['Fields']['name'] = msg['Fields']['name'] .. sep .. sample['plugin_instance']
+ end
+ if sample['type'] ~= 'gauge' and sample['type'] ~= 'derive' and
+ sample['type'] ~= 'counter' and sample['type'] ~= 'absolute' then
+ -- only for custom DS types
+ msg['Fields']['name'] = msg['Fields']['name'] .. sep .. sample['type']
+ end
+ if sample['type_instance'] ~= "" then
+ msg['Fields']['name'] = msg['Fields']['name'] .. sep .. sample['type_instance']
+ end
+ if sample['dsnames'][i] ~= "value" then
+ msg['Fields']['name'] = msg['Fields']['name'] .. sep .. sample['dsnames'][i]
+ end
+ msg['Fields']['name'] = replace_dot_by_sep(msg['Fields']['name'])
+
+ -- add meta fields as tag_fields
+ for k, v in pairs(sample['meta'] or {}) do
+ if tostring(k) ~= '0' then
+ msg['Fields'][k] = v
+ table.insert(msg['Fields']['tag_fields'], k)
+ end
+ end
end
if not skip_it then