[Fleet] Add workflow for requesting and downloading agent diagnostics from Fleet UI #141074
Description
Blocked by https://github.com/elastic/security-team/issues/4661
Background
A common supportability concern with Fleet/Agent is the collection and investigation of diagnostics. Elastic Agent exposes the elastic-agent diagnostics collect
command, which outputs a .zip
containing various diagnostics information that's crucial for debugging purposes.
We'd like to expose these diagnostics files in Fleet UI to improve debug-ability and reduce support overhead when requesting these diagnostics.
There are a few components at play here
- Fleet Server's "file upload" API that will allow agents to upload their diagnostics files (or any other arbitrary files) to Kibana. Tracked in https://github.com/elastic/security-team/issues/4661 and slotted for delivery during 8.6.
- A new
UPLOAD_DIAGNOSTICS
(name not final) action type for initiating the collection -> upload of Agent diagnostics - A Fleet UI workflow for requesting diagnostics, being notified of upload completion, and viewing previously requested diagnostics (this issue)
Implementation
- API requirements
- Support creating the
REQUEST_DIAGNOSTICS
action type in the existingPOST /api/fleet/agents/<id>/action
API - Add a new API for listing the files an agent has uploaded:
GET /api/fleet/agents/<id>/uploads
- Use the Kibana File Storage HTTP API for downloading:
GET /api/files/files/<id>/blob[/<filename>]
- Support creating the
- Agent Details Page -
/agents/:id
- Add a new action to the "actions" dropdown: "Request diagnostics .zip"
- Clicking "Request diagnostics" creates a new
REQUEST_DIAGANOSTICS
action and navigates the user to a new "Diagnostics" tab on the agent details page - Diagnostics tab
- A list of diagnostics files for the current agent is displayed as a table with two columns:
File
andDate
- Each file name is prefixed with a "download" icon, and clicking the file name downloads the file using the browser's standard file download process
- Any pending uploads (e.g action is created, but not yet complete) are displayed with a filename of "Generating diagnostics" and a date corresponding to the action's creation
- Any errored uploads (e.g. action reports an error status) are displayed with a an error icon and a derived timestamp filename based on the action's creation date
- A "Request diagnostics .zip" button exists to initiate (create action) a new diagnostics upload. The table dynamically updates to include this new request.
- A list of diagnostics files for the current agent is displayed as a table with two columns:
- Agent Listing Page -
/agents
- Add a new "Request diagnostics .zip" action to each agent's action menu that creates the action record -> navigates the user to the Diagnostics tab for the selected agent as above
- Requesting diagnostics for multiple agents at once should be possible through the bulk actions menu when multiple agents are selected
- Global functionality
- When a diagnostics upload is completed, the user should be notified via a toast message. This can probably be implemented by polling for the action's status for a set amount of time after diagnostics are requested.
Demo
- Prepare recorded demo