From de4c8341de7235d14da6a79e76d9b8bdb3639390 Mon Sep 17 00:00:00 2001 From: Andrew Cholakian Date: Mon, 19 Nov 2018 12:06:12 -0600 Subject: [PATCH] Enable heartbeat telemetry This commit allows heartbeat telemetry data to be sent through kibana. The change to beats was introduced in https://github.com/elastic/beats/pull/8621 --- .../telemetry/monitoring/get_beats_stats.js | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/x-pack/plugins/xpack_main/server/lib/telemetry/monitoring/get_beats_stats.js b/x-pack/plugins/xpack_main/server/lib/telemetry/monitoring/get_beats_stats.js index ff0ddadac40f1..e316acff49d84 100644 --- a/x-pack/plugins/xpack_main/server/lib/telemetry/monitoring/get_beats_stats.js +++ b/x-pack/plugins/xpack_main/server/lib/telemetry/monitoring/get_beats_stats.js @@ -103,6 +103,34 @@ export function processResults(results = [], { clusters, clusterHostSets, cluste clusters[clusterUuid].module.count += stateModule.count; } + const heartbeatState = get(hit, '_source.beats_state.state.heartbeat'); + if (heartbeatState !== undefined) { + if (!("heartbeat" in clusters[clusterUuid])) { + clusters[clusterUuid].heartbeat = { + monitors: 0, + endpoints: 0 + } + } + var clusterHb = clusters[clusterUuid].heartbeat + + clusterHb.monitors += heartbeatState.monitors + clusterHb.endpoints += heartbeatState.endpoints + for (var proto in heartbeatState) { + if (!heartbeatState.hasOwnProperty(proto)) continue; + let val = heartbeatState[proto] + if (typeof(val) !== "object") continue; + + if (!(proto in clusters[clusterUuid])) { + clusterHb[proto] = { + monitors: 0, + endpoints: 0 + } + } + clusterHb[proto].monitors += val.monitors + clusterHb[proto].endpoints += val.endpoints + } + } + const stateHost = get(hit, '_source.beats_state.state.host'); if (stateHost !== undefined) { const hostMap = clusterArchitectureMaps[clusterUuid]; @@ -161,6 +189,7 @@ async function fetchBeatsByType(server, callCluster, clusterUuids, start, end, { 'hits.hits._source.beats_state.state.input', 'hits.hits._source.beats_state.state.module', 'hits.hits._source.beats_state.state.host', + 'hits.hits._source.beats_state.state.heartbeat', ], body: { query: createQuery({