Skip to content

Commit a058312

Browse files
Supplementingelasticmachinekibanamachine
authored
[Fleet] Return audit unenroll reason (#205542)
## Summary Closes #194884 Returns the `audit_unenrolled_reason` in the response body when getting agents within Kibana ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [ ] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md) - [ ] [Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html) was added for features that require explanation or tutorials - [ ] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [ ] If a plugin configuration key changed, check if it needs to be allowlisted in the cloud and added to the [docker list](https://github.com/elastic/kibana/blob/main/src/dev/build/tasks/os_packages/docker_generator/resources/base/bin/kibana-docker) - [ ] This was checked for breaking HTTP API changes, and any breaking changes have been approved by the breaking-change committee. The `release_note:breaking` label should be applied in these situations. - [ ] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - [ ] The PR description includes the appropriate Release Notes section, and the correct `release_note:*` label is applied per the [guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) ### Identify risks N/A --------- Co-authored-by: Elastic Machine <[email protected]> Co-authored-by: kibanamachine <[email protected]>
1 parent a82a02e commit a058312

File tree

8 files changed

+37
-3
lines changed

8 files changed

+37
-3
lines changed

oas_docs/bundle.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15715,6 +15715,9 @@
1571515715
],
1571615716
"type": "object"
1571715717
},
15718+
"audit_unenrolled_reason": {
15719+
"type": "string"
15720+
},
1571815721
"components": {
1571915722
"items": {
1572015723
"additionalProperties": false,
@@ -17725,6 +17728,9 @@
1772517728
],
1772617729
"type": "object"
1772717730
},
17731+
"audit_unenrolled_reason": {
17732+
"type": "string"
17733+
},
1772817734
"components": {
1772917735
"items": {
1773017736
"additionalProperties": false,
@@ -18202,6 +18208,9 @@
1820218208
],
1820318209
"type": "object"
1820418210
},
18211+
"audit_unenrolled_reason": {
18212+
"type": "string"
18213+
},
1820518214
"components": {
1820618215
"items": {
1820718216
"additionalProperties": false,

oas_docs/bundle.serverless.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15715,6 +15715,9 @@
1571515715
],
1571615716
"type": "object"
1571715717
},
15718+
"audit_unenrolled_reason": {
15719+
"type": "string"
15720+
},
1571815721
"components": {
1571915722
"items": {
1572015723
"additionalProperties": false,
@@ -17725,6 +17728,9 @@
1772517728
],
1772617729
"type": "object"
1772717730
},
17731+
"audit_unenrolled_reason": {
17732+
"type": "string"
17733+
},
1772817734
"components": {
1772917735
"items": {
1773017736
"additionalProperties": false,
@@ -18202,6 +18208,9 @@
1820218208
],
1820318209
"type": "object"
1820418210
},
18211+
"audit_unenrolled_reason": {
18212+
"type": "string"
18213+
},
1820518214
"components": {
1820618215
"items": {
1820718216
"additionalProperties": false,

oas_docs/output/kibana.serverless.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16084,6 +16084,8 @@ paths:
1608416084
required:
1608516085
- id
1608616086
- version
16087+
audit_unenrolled_reason:
16088+
type: string
1608716089
components:
1608816090
items:
1608916091
additionalProperties: false
@@ -16529,6 +16531,8 @@ paths:
1652916531
required:
1653016532
- id
1653116533
- version
16534+
audit_unenrolled_reason:
16535+
type: string
1653216536
components:
1653316537
items:
1653416538
additionalProperties: false
@@ -16866,6 +16870,8 @@ paths:
1686616870
required:
1686716871
- id
1686816872
- version
16873+
audit_unenrolled_reason:
16874+
type: string
1686916875
components:
1687016876
items:
1687116877
additionalProperties: false

oas_docs/output/kibana.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18213,6 +18213,8 @@ paths:
1821318213
required:
1821418214
- id
1821518215
- version
18216+
audit_unenrolled_reason:
18217+
type: string
1821618218
components:
1821718219
items:
1821818220
additionalProperties: false
@@ -18655,6 +18657,8 @@ paths:
1865518657
required:
1865618658
- id
1865718659
- version
18660+
audit_unenrolled_reason:
18661+
type: string
1865818662
components:
1865918663
items:
1866018664
additionalProperties: false
@@ -18991,6 +18995,8 @@ paths:
1899118995
required:
1899218996
- id
1899318997
- version
18998+
audit_unenrolled_reason:
18999+
type: string
1899419000
components:
1899519001
items:
1899619002
additionalProperties: false

x-pack/platform/plugins/shared/fleet/common/types/models/agent.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ interface AgentBase {
9292
enrolled_at: string;
9393
unenrolled_at?: string;
9494
unenrollment_started_at?: string;
95+
audit_unenrolled_reason?: string;
9596
upgraded_at?: string | null;
9697
upgrade_started_at?: string | null;
9798
upgrade_details?: AgentUpgradeDetails;
@@ -255,6 +256,10 @@ export interface FleetServerAgent {
255256
/**
256257
* Date/time the Elastic Agent was last upgraded
257258
*/
259+
audit_unenrolled_reason?: string;
260+
/**
261+
* Reason for agent unenrollment
262+
*/
258263
upgraded_at?: string | null;
259264
/**
260265
* Date/time the Elastic Agent started the current upgrade

x-pack/platform/plugins/shared/fleet/server/services/agents/crud.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ export async function getAgents(
112112
} else {
113113
throw new FleetError('Either options.agentIds or options.kuery are required to get agents');
114114
}
115-
116115
return agents;
117116
}
118117

@@ -490,7 +489,6 @@ async function _filterAgents(
490489
appContextService.getLogger().error(`Error querying agents: ${JSON.stringify(err)}`);
491490
throw err;
492491
}
493-
494492
const agents = res.hits.hits.map(searchHitToAgent);
495493
const total = res.hits.total as number;
496494

x-pack/platform/plugins/shared/fleet/server/services/agents/helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ export function searchHitToAgent(
6565
enrolled_at: hit._source?.enrolled_at!,
6666
unenrolled_at: hit._source?.unenrolled_at!,
6767
unenrollment_started_at: hit._source?.unenrollment_started_at,
68+
audit_unenrolled_reason: hit._source?.audit_unenrolled_reason!,
6869
upgraded_at: hit._source?.upgraded_at,
6970
upgrade_started_at: hit._source?.upgrade_started_at,
7071
upgrade_details: hit._source?.upgrade_details,
@@ -106,7 +107,6 @@ export function searchHitToAgent(
106107
} else {
107108
agent.status = hit.fields.status[0];
108109
}
109-
110110
return agent;
111111
}
112112

x-pack/platform/plugins/shared/fleet/server/types/rest_spec/agent.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ export const AgentResponseSchema = schema.object({
135135
enrolled_at: schema.string(),
136136
unenrolled_at: schema.maybe(schema.string()),
137137
unenrollment_started_at: schema.maybe(schema.string()),
138+
audit_unenrolled_reason: schema.maybe(schema.string()),
138139
upgraded_at: schema.maybe(schema.oneOf([schema.literal(null), schema.string()])),
139140
upgrade_started_at: schema.maybe(schema.oneOf([schema.literal(null), schema.string()])),
140141
upgrade_details: schema.maybe(

0 commit comments

Comments
 (0)