Skip to content

Commit

Permalink
[8.6] changed agent versions to agents per version telemetry (#147164) (
Browse files Browse the repository at this point in the history
#147169)

# Backport

This will backport the following commits from `main` to `8.6`:
- [changed agent versions to agents per version telemetry
(#147164)](#147164)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Julia
Bardi","email":"90178898+juliaElastic@users.noreply.github.com"},"sourceCommit":{"committedDate":"2022-12-07T11:23:30Z","message":"changed
agent versions to agents per version telemetry (#147164)\n\n##
Summary\r\n\r\nChanged the list of agent versions to agent count per
version in\r\nfleet-usages telemetry as
requested\r\n[here](https://github.com/elastic/kibana/pull/145353#issuecomment-1331783758).\r\n\r\n\r\n###
Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios","sha":"e771fc8e9fa5f551d8692fc8558e5d7e2cbfef79","branchLabelMapping":{"^v8.7.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Fleet","v8.7.0","v8.6.1"],"number":147164,"url":"https://github.com/elastic/kibana/pull/147164","mergeCommit":{"message":"changed
agent versions to agents per version telemetry (#147164)\n\n##
Summary\r\n\r\nChanged the list of agent versions to agent count per
version in\r\nfleet-usages telemetry as
requested\r\n[here](https://github.com/elastic/kibana/pull/145353#issuecomment-1331783758).\r\n\r\n\r\n###
Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios","sha":"e771fc8e9fa5f551d8692fc8558e5d7e2cbfef79"}},"sourceBranch":"main","suggestedTargetBranches":["8.6"],"targetPullRequestStates":[{"branch":"main","label":"v8.7.0","labelRegex":"^v8.7.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/147164","number":147164,"mergeCommit":{"message":"changed
agent versions to agents per version telemetry (#147164)\n\n##
Summary\r\n\r\nChanged the list of agent versions to agent count per
version in\r\nfleet-usages telemetry as
requested\r\n[here](https://github.com/elastic/kibana/pull/145353#issuecomment-1331783758).\r\n\r\n\r\n###
Checklist\r\n\r\n- [x] [Unit or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common
scenarios","sha":"e771fc8e9fa5f551d8692fc8558e5d7e2cbfef79"}},{"branch":"8.6","label":"v8.6.1","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Julia Bardi <90178898+juliaElastic@users.noreply.github.com>
Co-authored-by: Julia Bardi <julia.bardi@elastic.co>
  • Loading branch information
3 people authored Dec 7, 2022
1 parent 11cde5b commit b91dfc9
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 11 deletions.
4 changes: 2 additions & 2 deletions x-pack/plugins/fleet/cypress/e2e/integrations_real.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,10 @@ describe('Add Integration - Real API', () => {
setupIntegrations();
cy.getBySel(getIntegrationCategories('aws')).click();
cy.getBySel(INTEGRATIONS_SEARCHBAR.BADGE).contains('AWS').should('exist');
cy.getBySel(INTEGRATION_LIST).find('.euiCard').should('have.length', 28);
cy.getBySel(INTEGRATION_LIST).find('.euiCard').should('have.length.greaterThan', 28);

cy.getBySel(INTEGRATIONS_SEARCHBAR.INPUT).clear().type('Cloud');
cy.getBySel(INTEGRATION_LIST).find('.euiCard').should('have.length', 3);
cy.getBySel(INTEGRATION_LIST).find('.euiCard').should('have.length.greaterThan', 2);
cy.getBySel(INTEGRATIONS_SEARCHBAR.REMOVE_BADGE_BUTTON).click();
cy.getBySel(INTEGRATIONS_SEARCHBAR.BADGE).should('not.exist');
});
Expand Down
13 changes: 8 additions & 5 deletions x-pack/plugins/fleet/server/collectors/agent_collectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ export const getAgentUsage = async (
};

export interface AgentData {
agent_versions: string[];
agents_per_version: Array<{
version: string;
count: number;
}>;
agent_checkin_status: {
error: number;
degraded: number;
Expand All @@ -58,9 +61,9 @@ export interface AgentData {
}

const DEFAULT_AGENT_DATA = {
agent_versions: [],
agent_checkin_status: { error: 0, degraded: 0 },
agents_per_policy: [],
agents_per_version: [],
};

export const getAgentData = async (
Expand Down Expand Up @@ -105,8 +108,8 @@ export const getAgentData = async (
},
{ signal: abortController.signal }
);
const versions = ((response?.aggregations?.versions as any).buckets ?? []).map(
(bucket: any) => bucket.key
const agentsPerVersion = ((response?.aggregations?.versions as any).buckets ?? []).map(
(bucket: any) => ({ version: bucket.key, count: bucket.doc_count })
);
const statuses = transformLastCheckinStatusBuckets(response);

Expand All @@ -115,9 +118,9 @@ export const getAgentData = async (
);

return {
agent_versions: versions,
agent_checkin_status: statuses,
agents_per_policy: agentsPerPolicy,
agents_per_version: agentsPerVersion,
};
} catch (error) {
if (error.statusCode === 404) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,10 @@ describe('fleet usage telemetry', () => {
num_host_urls: 0,
},
packages: [],
agent_versions: ['8.5.1', '8.6.0'],
agents_per_version: [
{ version: '8.5.1', count: 1 },
{ version: '8.6.0', count: 1 },
],
agent_checkin_status: { error: 1, degraded: 1 },
agents_per_policy: [2],
fleet_server_config: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,13 @@ export const fleetUsagesSchema: RootSchema<any> = {
},
},
},
agent_versions: {
agents_per_version: {
type: 'array',
items: {
type: 'keyword',
_meta: { description: 'The agent versions enrolled in this deployment.' },
properties: {
version: { type: 'keyword' },
count: { type: 'long' },
},
},
},
agents_per_policy: {
Expand Down

0 comments on commit b91dfc9

Please sign in to comment.