-
Notifications
You must be signed in to change notification settings - Fork 8.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Telemetry] Add beats architecture stats to telemetry #21227
Changes from 3 commits
abf23a5
10fc342
8eaf963
83dd16c
8597b4a
4b1c447
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,10 @@ const getBaseStats = () => ({ | |
count: 0, | ||
names: [] | ||
}, | ||
architecture: { | ||
count: 0, | ||
names: [] | ||
} | ||
}); | ||
|
||
|
||
|
@@ -37,7 +41,7 @@ const getBaseStats = () => ({ | |
* @param {Object} clusterHostSets - the object keyed by cluster UUIDs to count the unique hosts | ||
* @param {Object} clusterModuleSets - the object keyed by cluster UUIDs to count the unique modules | ||
*/ | ||
export function processResults(results = [], { clusters, clusterHostSets, clusterInputSets, clusterModuleSets }) { | ||
export function processResults(results = [], { clusters, clusterHostSets, clusterInputSets, clusterModuleSets, clusterArchitectureSets }) { | ||
const currHits = get(results, 'hits.hits', []); | ||
currHits.forEach(hit => { | ||
const clusterUuid = get(hit, '_source.cluster_uuid'); | ||
|
@@ -46,6 +50,7 @@ export function processResults(results = [], { clusters, clusterHostSets, cluste | |
clusterHostSets[clusterUuid] = new Set(); | ||
clusterInputSets[clusterUuid] = new Set(); | ||
clusterModuleSets[clusterUuid] = new Set(); | ||
clusterArchitectureSets[clusterUuid] = new Set(); | ||
} | ||
|
||
const processBeatsStatsResults = () => { | ||
|
@@ -97,6 +102,15 @@ export function processResults(results = [], { clusters, clusterHostSets, cluste | |
clusters[clusterUuid].module.names = Array.from(moduleSet); | ||
clusters[clusterUuid].module.count += stateModule.count; | ||
} | ||
|
||
const stateHost = get(hit, '_source.beats_state.state.host'); | ||
if (stateHost !== undefined) { | ||
const hostSet = clusterArchitectureSets[clusterUuid]; | ||
const hostArchPlatform = `${stateHost.architecture}/${stateHost.os.platform}`; | ||
hostSet.add(hostArchPlatform); | ||
clusters[clusterUuid].architecture.names = Array.from(hostSet); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @pickypg So we'd store There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, I'm not sure I'm following your recommendation here. Can you provide some psuedo code? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. // set up top
const clusterArchitectureMaps = new Map();
// looping across hosts
if (stateHost !== undefined) {
const hostMap = clusterArchitectureMaps[clusterUuid];
const hostKey = `${stateHost.architecture}/${stateHost.os.platform}`;
let os = hostMap.get(hostKey);
if (!os) { // undefined if new
os = { name: stateHost.os.platform, architecture: stateHost.architecture, count: 0 };
hostMap.set(hostKey, os);
}
// total per os/arch
os.count += 1;
// overall total (which should be the same number as the sum of all os.count values)
clusters[clusterUuid].architecture.count += 1;
} I feel like the serialization of the map should happen only at the end to avoid repeating that effort for every step of the loop. (This is currently where you're doing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we still want to report by |
||
clusters[clusterUuid].architecture.count += 1; | ||
} | ||
}; | ||
|
||
if (get(hit, '_source.type') === 'beats_stats') { | ||
|
@@ -136,6 +150,7 @@ async function fetchBeatsByType(server, callCluster, clusterUuids, start, end, { | |
'hits.hits._source.beats_stats.metrics.libbeat.output.type', | ||
'hits.hits._source.beats_state.state.input', | ||
'hits.hits._source.beats_state.state.module', | ||
'hits.hits._source.beats_state.state.host', | ||
], | ||
body: { | ||
query: createQuery({ | ||
|
@@ -194,7 +209,8 @@ export async function getBeatsStats(server, callCluster, clusterUuids, start, en | |
clusters: {}, // the result object to be built up | ||
clusterHostSets: {}, // passed to processResults for tracking state in the results generation | ||
clusterInputSets: {}, // passed to processResults for tracking state in the results generation | ||
clusterModuleSets: {} // passed to processResults for tracking state in the results generation | ||
clusterModuleSets: {}, // passed to processResults for tracking state in the results generation | ||
clusterArchitectureSets: {} // passed to processResults for tracking state in the results generation | ||
}; | ||
|
||
await Promise.all([ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any reason you didn't just add two fields? (You could use a
Map
to store them by this same key, but then store an object)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't recall exactly - I think it was a suggestion from @ruflin or @ycombinator (or I made it up). Which would you recommend?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that they represent different details, I feel like having them separate would be more useful especially as ARM is presumably going to grow in server-side usage.