Suffix Nagios host with the environment_label dimension
diff --git a/heka/files/lua/encoders/status_nagios.lua b/heka/files/lua/encoders/status_nagios.lua
index 9957f70..dd4d73e 100644
--- a/heka/files/lua/encoders/status_nagios.lua
+++ b/heka/files/lua/encoders/status_nagios.lua
@@ -19,6 +19,11 @@
local lma = require 'lma_utils'
local interp = require "msg_interpolate"
+local host_suffix_dimension_field
+if read_config('host_suffix_dimension_key') then
+ host_suffix_dimension_field = string.format('Fields[%s]', read_config('host_suffix_dimension_key'))
+end
+
-- 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')
@@ -64,12 +69,21 @@
return -1
end
+ local host
if host_dimension_key then
- data['host'] = read_message(string.format('Fields[%s]', host_dimension_key)) or default_host
+ host = read_message(string.format('Fields[%s]', host_dimension_key)) or default_host
else
- data['host'] = read_message('Fields[hostname]') or read_message('Hostname')
+ host = read_message('Fields[hostname]') or read_message('Hostname')
end
+ if host_suffix_dimension_field then
+ local suffix = read_message(host_suffix_dimension_field)
+ if suffix then
+ host = host .. '.' .. suffix
+ end
+ end
+ data['host'] = host
+
data['service'] = service_name
data['plugin_state'] = nagios_state_map[status]
diff --git a/heka/meta/heka.yml b/heka/meta/heka.yml
index d9df152..c37929c 100644
--- a/heka/meta/heka.yml
+++ b/heka/meta/heka.yml
@@ -103,7 +103,8 @@
engine: sandbox
module_file: /usr/share/lma_collector/encoders/status_nagios.lua
module_dir: /usr/share/lma_collector/common;/usr/share/heka/lua_modules
- {%- endif %}
+ config:
+ host_suffix_dimension_key: environment_label
{%- endif %}
{%- if metric_collector.influxdb_host is defined or metric_collector.aggregator_host is defined or metric_collector.nagios_host is defined %}
output:
@@ -439,6 +440,7 @@
module_file: /usr/share/lma_collector/encoders/status_nagios.lua
module_dir: /usr/share/lma_collector/common;/usr/share/heka/lua_modules
config:
+ host_suffix_dimension_key: environment_label
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 }}"