Skip to content

Commit

Permalink
Aggregate queue types being used by Beats (#59850)
Browse files Browse the repository at this point in the history
* Aggregate queue types being used by Beats

* Making tests pass again

* Updating fixture + tests for queue type

* Adding queue field to BeatsBaseStats type

* Add undefined guard

* Adding queue field to source fields list

* Fixing type error
  • Loading branch information
ycombinator authored Mar 12, 2020
1 parent 410019a commit d46f848
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
"functions": {
"count": 1
}
},
"queue": {
"name": "mem"
}
}
}
Expand All @@ -27,6 +30,9 @@
"functions": {
"count": 3
}
},
"queue": {
"name": "mem"
}
}
}
Expand All @@ -53,6 +59,9 @@
"endpoints" : 1
},
"monitors" : 2
},
"queue": {
"name": "spool"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ describe('Get Beats Stats', () => {
count: 0,
names: [],
},
queue: {
mem: 0,
spool: 0,
},
architecture: {
count: 0,
architectures: [],
Expand Down Expand Up @@ -142,6 +146,10 @@ describe('Get Beats Stats', () => {
count: 1,
names: ['firehose'],
},
queue: {
mem: 2,
spool: 1,
},
architecture: {
count: 1,
architectures: [
Expand Down Expand Up @@ -198,6 +206,10 @@ describe('Get Beats Stats', () => {
count: 0,
names: [],
},
queue: {
mem: 0,
spool: 0,
},
architecture: {
count: 0,
architectures: [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ const getBaseStats = () => ({
count: 0,
names: [],
},
queue: {
mem: 0,
spool: 0,
},
architecture: {
count: 0,
architectures: [],
Expand Down Expand Up @@ -69,6 +73,9 @@ export interface BeatsStats {
names: string[];
count: number;
};
queue?: {
name?: string;
};
heartbeat?: HeartbeatBase;
functionbeat?: {
functions?: {
Expand Down Expand Up @@ -107,6 +114,9 @@ export interface BeatsBaseStats {
count: number;
names: string[];
};
queue: {
[queueType: string]: number;
};
architecture: {
count: number;
architectures: BeatsArchitecture[];
Expand Down Expand Up @@ -215,6 +225,11 @@ export function processResults(
clusters[clusterUuid].module.count += stateModule.count;
}

const stateQueue = hit._source.beats_state?.state?.queue?.name;
if (stateQueue !== undefined) {
clusters[clusterUuid].queue[stateQueue] += 1;
}

const heartbeatState = hit._source.beats_state?.state?.heartbeat;
if (heartbeatState !== undefined) {
if (!clusters[clusterUuid].hasOwnProperty('heartbeat')) {
Expand Down Expand Up @@ -325,6 +340,7 @@ async function fetchBeatsByType(
'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.queue',
'hits.hits._source.beats_state.state.host',
'hits.hits._source.beats_state.state.heartbeat',
'hits.hits._source.beats_state.beat.type',
Expand Down

0 comments on commit d46f848

Please sign in to comment.