Skip to content

Commit

Permalink
Enable heartbeat telemetry (elastic#25886)
Browse files Browse the repository at this point in the history
This commit allows heartbeat telemetry data to be sent through kibana.

The change to beats was introduced in elastic/beats#8621
  • Loading branch information
andrewvc committed Dec 7, 2018
1 parent 7f9cde7 commit 043ea3b
Show file tree
Hide file tree
Showing 3 changed files with 118 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,58 @@
{
"hits": {
"hits": [
{
"_source" : {
"cluster_uuid": "W7hppdX7R229Oy3KQbZrTw",
"type": "beats_state",
"beats_state" : {
"state" : {
"heartbeat" : {
"endpoints" : 2,
"http" : {
"endpoints" : 1,
"monitors" : 1
},
"icmp" : {
"monitors" : 0,
"endpoints" : 0
},
"tcp" : {
"monitors" : 1,
"endpoints" : 1
},
"monitors" : 2
}
}
}
}
},
{
"_source" : {
"cluster_uuid": "W7hppdX7R229Oy3KQbZrTw",
"type": "beats_state",
"beats_state" : {
"state" : {
"heartbeat" : {
"endpoints" : 2,
"http" : {
"endpoints" : 0,
"monitors" : 0
},
"icmp" : {
"monitors" : 0,
"endpoints" : 0
},
"tcp" : {
"monitors" : 1,
"endpoints" : 2
},
"monitors" : 1
}
}
}
}
},
{
"_source": {
"type": "beats_state",
Expand Down Expand Up @@ -74,6 +126,26 @@
"published": 1038
}
}
},
"heartbeat" : {
"http" : {
"endpoint_starts" : 1,
"endpoint_stops" : 0,
"monitor_starts" : 1,
"monitor_stops" : 0
},
"icmp" : {
"endpoint_starts" : 0,
"endpoint_stops" : 0,
"monitor_starts" : 0,
"monitor_stops" : 0
},
"tcp" : {
"endpoint_starts" : 1,
"endpoint_stops" : 0,
"monitor_starts" : 1,
"monitor_stops" : 0
}
}
}
}
Expand Down Expand Up @@ -11531,5 +11603,6 @@
]
}
},

{}
]
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,22 @@ describe('Get Beats Stats', () => {
name: 'darwin'
}
]
},
heartbeat: {
endpoints: 4,
http: {
endpoints: 1,
monitors: 1
},
icmp: {
monitors: 0,
endpoints: 0
},
tcp: {
monitors: 2,
endpoints: 3
},
monitors: 3
}
},
FlV4ckTxQ0a78hmBkzzc9A: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 (!clusters[clusterUuid].hasOwnProperty('heartbeat')) {
clusters[clusterUuid].heartbeat = {
monitors: 0,
endpoints: 0
};
}
const clusterHb = clusters[clusterUuid].heartbeat;

clusterHb.monitors += heartbeatState.monitors;
clusterHb.endpoints += heartbeatState.endpoints;
for (const proto in heartbeatState) {
if (!heartbeatState.hasOwnProperty(proto)) continue;
const val = heartbeatState[proto];
if (typeof val !== "object") continue;

if (!clusterHb.hasOwnProperty(proto)) {
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];
Expand Down Expand Up @@ -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({
Expand Down

0 comments on commit 043ea3b

Please sign in to comment.