Describe the enhancement:
When the elastic-agent enroll or the elastic-agent uninstall commands are run the binary should send a final message to the current fleet server before enrolling with the new fleet server. The fleet server can use this command to change the status of the agent in fleet and to notify admins if an agent was unexpectedly uninstalled. Currently when the agent makes changes the Fleet server is unaware of the changes and this will result in lots of identical agents that are no longer active and the admins do not know which one is still the active agent

Describe a specific use case for the enhancement or feature:
One of the governance requirements for multiple compliance frameworks such as Fedramp or PCI is that we have to have alerting in place for when an endpoint security agent stops running. This feature would help bring Elastic Agent into compliance without the need for a separate auditbeat process to monitor for the agent removal.
This would also help keep fleet servers clean in a devops environment where agents are managed via code.
Link to RFC
https://docs.google.com/document/d/1gYbsGfvjc7NhbURwYNqEl25ouar81nZ_8bkpsi0Dc6Y/edit
### Tasks
- [x] fleet-server `/api/fleet/agents/:id/audit/unenroll` api
- [x] elastic-agent uses fleet-server's audit/unenroll api when uninstalling
- [x] feature integration tests
- [ ] fleet-ui to query for `Detached Endpoint` an show a non-offline state OR Endpoint uses `/api/fleet/agents/:id/audit/unenroll` api to update fleet
- [ ] fleet-ui FORCE_UNENROLL agent annotations
- [ ] https://github.com/elastic/observability-perf/issues/800
### Future Work
- [ ] https://github.com/elastic/kibana/issues/197731
- [ ] fleet-ui improve audit logs
- [ ] fleet-ui FORCE_UNROLL action RBAC
- [ ] Endpoint provides `verify no-tamper-protection` command
- [ ] elastic-agent check Endpoint's `verify no-tamper-protection` command before executing `enroll -f` and `upgrade` invocations and `POLLICY_REASSIGN` actions
Describe the enhancement:
When the
elastic-agent enrollor theelastic-agent uninstallcommands are run the binary should send a final message to the current fleet server before enrolling with the new fleet server. The fleet server can use this command to change the status of the agent in fleet and to notify admins if an agent was unexpectedly uninstalled. Currently when the agent makes changes the Fleet server is unaware of the changes and this will result in lots of identical agents that are no longer active and the admins do not know which one is still the active agentDescribe a specific use case for the enhancement or feature:
One of the governance requirements for multiple compliance frameworks such as Fedramp or PCI is that we have to have alerting in place for when an endpoint security agent stops running. This feature would help bring Elastic Agent into compliance without the need for a separate auditbeat process to monitor for the agent removal.
This would also help keep fleet servers clean in a devops environment where agents are managed via code.
Link to RFC
https://docs.google.com/document/d/1gYbsGfvjc7NhbURwYNqEl25ouar81nZ_8bkpsi0Dc6Y/edit