Set correct host name in metrics

This commit fixes a bug where hostnames were not correct in
metrics collected by Snap and Hindsight. It relies on
Kubernetes' downward API and the spec.nodeName field [1].
The latter is only supported by Kubernetes 1.4 and higher,
and the deployment of stacklight-collector pods will fail if
Kubernetes 1.3 or lower is used.

[1] <https://github.com/kubernetes/kubernetes/pull/27880>

Change-Id: I73cd35803a2201a09144bf925753156e47489cff
Depends-On: I293bb3aa113883c02f2e738f9d74291bf2f23d95
Partial-Bug: #1614484
This commit is contained in:
Éric Lemoine 2016-08-24 15:24:09 +02:00
parent 2d5bb26ebe
commit 78b13b7209
4 changed files with 13 additions and 7 deletions

View File

@ -105,10 +105,7 @@ end
-- if the message is invalid
local function create_line()
-- FIXME(elemoine) get hostname from Field[Hostname]
local tags = {
hostname = escape_string(read_message('Hostname'))
}
local tags = {}
local dimensions, dimensions_index = read_field('dimensions')
if dimensions then
local i = 0

View File

@ -6,8 +6,7 @@ analysis_lua_cpath = "/usr/lib/x86_64-linux-gnu/luasandbox/modules/?.so"
io_lua_path = analysis_lua_path .. ";/usr/lib/x86_64-linux-gnu/luasandbox/io_modules/?.lua"
io_lua_cpath = analysis_lua_cpath .. ";/usr/lib/x86_64-linux-gnu/luasandbox/io_modules/?.so"
-- FIXME(elemoine) set "hostname"
-- hostname =
hostname = "{{ CCP_HINDSIGHT_NODE_NAME }}"
input_defaults = {
-- output_limit = 64 * 1024

View File

@ -12,6 +12,11 @@
"proc_path": "/host-proc"
}
},
"tags": {
"/intel/procfs": {
"hostname": "{{ CCP_SNAP_NODE_NAME }}"
}
},
"metrics": {
"/intel/procfs/cpu/all/idle_percentage": {},
"/intel/procfs/cpu/all/iowait_percentage": {},

View File

@ -40,10 +40,15 @@ service:
type: host
path: /proc
mount-path: /host-proc
env:
- name: CCP_SNAP_NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
files:
hindsight.cfg:
path: /etc/hindsight/hindsight.cfg
content: hindsight.cfg
content: hindsight.cfg.j2
perm: "0600"
heka-tcp.cfg:
path: /var/lib/hindsight/run/input/heka_tcp.cfg