Use a dimension key for the Nagios host displaying alarm clusters
diff --git a/heka/files/lua/encoders/status_nagios.lua b/heka/files/lua/encoders/status_nagios.lua
index 0507a10..9957f70 100644
--- a/heka/files/lua/encoders/status_nagios.lua
+++ b/heka/files/lua/encoders/status_nagios.lua
@@ -19,7 +19,10 @@
local lma = require 'lma_utils'
local interp = require "msg_interpolate"
-local host = read_config('nagios_host')
+-- These 2 configurations are used only to encode GSE messages
+local default_host = read_config('default_nagios_host')
+local host_dimension_key = read_config('nagios_host_dimension_key')
+
-- Nagios CGI cannot accept 'plugin_output' parameter greater than 1024 bytes
-- See bug #1517917 for details.
-- With the 'cmd.cgi' re-implementation for the command PROCESS_SERVICE_CHECK_RESULT,
@@ -61,11 +64,12 @@
return -1
end
- if host then
- data['host'] = host
+ if host_dimension_key then
+ data['host'] = read_message(string.format('Fields[%s]', host_dimension_key)) or default_host
else
data['host'] = read_message('Fields[hostname]') or read_message('Hostname')
end
+
data['service'] = service_name
data['plugin_state'] = nagios_state_map[status]
diff --git a/heka/map.jinja b/heka/map.jinja
index 8b74f9d..7658623 100644
--- a/heka/map.jinja
+++ b/heka/map.jinja
@@ -72,7 +72,7 @@
'influxdb_time_precision': default_influxdb_time_precision,
'influxdb_timeout': default_influxdb_timeout,
'nagios_port': default_nagios_port,
- 'nagios_host_alarm_clusters': default_nagios_host_alarm_clusters,
+ 'nagios_default_host_alarm_clusters': default_nagios_host_alarm_clusters,
'poolsize': 100,
}
}, merge=salt['pillar.get']('heka:aggregator')) %}
diff --git a/heka/meta/heka.yml b/heka/meta/heka.yml
index 090cb96..a1f2992 100644
--- a/heka/meta/heka.yml
+++ b/heka/meta/heka.yml
@@ -396,7 +396,10 @@
module_file: /usr/share/lma_collector/encoders/status_nagios.lua
module_dir: /usr/share/lma_collector/common;/usr/share/heka/lua_modules
config:
- nagios_host: "{{ aggregator.nagios_host_alarm_clusters }}"
+ default_nagios_host: "{{ aggregator.nagios_default_host_alarm_clusters }}"
+ {%- if aggregator.nagios_host_dimension_key is defined %}
+ nagios_host_dimension_key: "{{ aggregator.nagios_host_dimension_key }}"
+ {%- endif %}
{%- endif %}
output:
{%- if aggregator.influxdb_host is defined %}
diff --git a/metadata/service/aggregator/single.yml b/metadata/service/aggregator/single.yml
index 7e814c5..476536c 100644
--- a/metadata/service/aggregator/single.yml
+++ b/metadata/service/aggregator/single.yml
@@ -5,8 +5,10 @@
parameters:
_param:
aggregator_poolsize: 100
+ nagios_host_dimension_key: nagios_host
heka:
aggregator:
enabled: true
influxdb_time_precision: ms
poolsize: ${_param:aggregator_poolsize}
+ nagios_host_dimension_key: ${_param:nagios_host_dimension_key}
diff --git a/metadata/service/metric_collector/single.yml b/metadata/service/metric_collector/single.yml
index ad183a2..2e4a442 100644
--- a/metadata/service/metric_collector/single.yml
+++ b/metadata/service/metric_collector/single.yml
@@ -5,8 +5,10 @@
parameters:
_param:
metric_collector_poolsize: 100
+ nagios_host_dimension_key: nagios_host
heka:
metric_collector:
enabled: true
influxdb_time_precision: ms
poolsize: ${_param:metric_collector_poolsize}
+ nagios_host_dimension_key: ${_param:nagios_host_dimension_key}