mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[Fleet] Add agents per OS telemetry (#163039)
## Summary Querying agent operating system to add to telemetry. How to test locally: - enroll a few different agents running on different operating system - wait up to 1h to see the telemetry task triggered - check debug logs to see that the agents per version telemetry contains the status information
This commit is contained in:
parent
b6d94d7883
commit
b9dae73789
4 changed files with 78 additions and 1 deletions
|
@ -70,12 +70,18 @@ export interface AgentData {
|
|||
degraded: number;
|
||||
};
|
||||
agents_per_policy: number[];
|
||||
agents_per_os: Array<{
|
||||
name: string;
|
||||
version: string;
|
||||
count: number;
|
||||
}>;
|
||||
}
|
||||
|
||||
const DEFAULT_AGENT_DATA = {
|
||||
agent_checkin_status: { error: 0, degraded: 0 },
|
||||
agents_per_policy: [],
|
||||
agents_per_version: [],
|
||||
agents_per_os: [],
|
||||
};
|
||||
|
||||
export const getAgentData = async (
|
||||
|
@ -117,6 +123,18 @@ export const getAgentData = async (
|
|||
policies: {
|
||||
terms: { field: 'policy_id' },
|
||||
},
|
||||
os: {
|
||||
multi_terms: {
|
||||
terms: [
|
||||
{
|
||||
field: 'local_metadata.os.name.keyword',
|
||||
},
|
||||
{
|
||||
field: 'local_metadata.os.version.keyword',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{ signal: abortController.signal }
|
||||
|
@ -166,10 +184,17 @@ export const getAgentData = async (
|
|||
(bucket: any) => bucket.doc_count
|
||||
);
|
||||
|
||||
const agentsPerOS = ((response?.aggregations?.os as any).buckets ?? []).map((bucket: any) => ({
|
||||
name: bucket.key[0],
|
||||
version: bucket.key[1],
|
||||
count: bucket.doc_count,
|
||||
}));
|
||||
|
||||
return {
|
||||
agent_checkin_status: statuses,
|
||||
agents_per_policy: agentsPerPolicy,
|
||||
agents_per_version: agentsPerVersion,
|
||||
agents_per_os: agentsPerOS,
|
||||
};
|
||||
} catch (error) {
|
||||
if (error.statusCode === 404) {
|
||||
|
|
|
@ -130,6 +130,12 @@ describe('fleet usage telemetry', () => {
|
|||
last_checkin: '2022-11-21T12:26:24Z',
|
||||
active: true,
|
||||
policy_id: 'policy1',
|
||||
local_metadata: {
|
||||
os: {
|
||||
name: 'Ubuntu',
|
||||
version: '22.04.2 LTS (Jammy Jellyfish)',
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
create: {
|
||||
|
@ -144,6 +150,12 @@ describe('fleet usage telemetry', () => {
|
|||
last_checkin: '2022-11-21T12:27:24Z',
|
||||
active: true,
|
||||
policy_id: 'policy1',
|
||||
local_metadata: {
|
||||
os: {
|
||||
name: 'Ubuntu',
|
||||
version: '20.04.5 LTS (Focal Fossa)',
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
create: {
|
||||
|
@ -158,6 +170,12 @@ describe('fleet usage telemetry', () => {
|
|||
last_checkin: '2021-11-21T12:27:24Z',
|
||||
active: false,
|
||||
policy_id: 'policy1',
|
||||
local_metadata: {
|
||||
os: {
|
||||
name: 'Ubuntu',
|
||||
version: '20.04.5 LTS (Focal Fossa)',
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
refresh: 'wait_for',
|
||||
|
@ -374,6 +392,18 @@ describe('fleet usage telemetry', () => {
|
|||
],
|
||||
agent_checkin_status: { error: 1, degraded: 1 },
|
||||
agents_per_policy: [2],
|
||||
agents_per_os: [
|
||||
{
|
||||
name: 'Ubuntu',
|
||||
version: '20.04.5 LTS (Focal Fossa)',
|
||||
count: 1,
|
||||
},
|
||||
{
|
||||
name: 'Ubuntu',
|
||||
version: '22.04.2 LTS (Jammy Jellyfish)',
|
||||
count: 1,
|
||||
},
|
||||
],
|
||||
fleet_server_config: {
|
||||
policies: [
|
||||
{
|
||||
|
|
|
@ -24,7 +24,7 @@ const FLEET_AGENTS_EVENT_TYPE = 'fleet_agents';
|
|||
|
||||
export class FleetUsageSender {
|
||||
private taskManager?: TaskManagerStartContract;
|
||||
private taskVersion = '1.1.0';
|
||||
private taskVersion = '1.1.1';
|
||||
private taskType = 'Fleet-Usage-Sender';
|
||||
private wasStarted: boolean = false;
|
||||
private interval = '1h';
|
||||
|
|
|
@ -261,4 +261,26 @@ export const fleetUsagesSchema: RootSchema<any> = {
|
|||
_meta: { description: 'Top messages from fleet server error logs' },
|
||||
},
|
||||
},
|
||||
agents_per_os: {
|
||||
properties: {
|
||||
name: {
|
||||
type: 'keyword',
|
||||
_meta: {
|
||||
description: 'Agent OS enrolled to this kibana',
|
||||
},
|
||||
},
|
||||
version: {
|
||||
type: 'keyword',
|
||||
_meta: {
|
||||
description: 'Agent OS version enrolled to this kibana',
|
||||
},
|
||||
},
|
||||
count: {
|
||||
type: 'long',
|
||||
_meta: {
|
||||
description: 'Number of agents enrolled that use this OS',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue