Enable heartbeat telemetry (#25886) (#26824)

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
This commit is contained in:
Andrew Cholakian 2018-12-07 13:51:11 -06:00 committed by GitHub
parent 3ae84bbd19
commit 52bb10511b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 118 additions and 0 deletions

View file

@ -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",
@ -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
}
}
}
}
@ -11531,5 +11603,6 @@
]
}
},
{}
]

View file

@ -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: {

View file

@ -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];
@ -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({