|
| 1 | +# elasticdiagnosticsextension |
| 2 | + |
| 3 | +`elasticdiagnosticsextension` is an internal package for peforming diagnostics and is used in conjunction with EDOT: |
| 4 | + |
| 5 | +## Features |
| 6 | + |
| 7 | +- Acts as a registrar and keeps track of common diagnostic hooks. |
| 8 | +- Collects profiles using `runtime/pprof`. |
| 9 | +- Collects internal telemetry exposed by the OTeL Collector. |
| 10 | +- Implements the `extensioncapabilities.ConfigWatcher` interface and stores the latest configuration of the running collector. |
| 11 | +- Listens for diagnostic requests and provides diagnostic data. |
| 12 | + |
| 13 | +## Design |
| 14 | + |
| 15 | +### Diagnostic hooks: |
| 16 | +- Individual beats register custom diagnostic hooks and these hooks are called when we run the elastic-agent diagnostics command. |
| 17 | +- Our extension stores these hooks and executes them everytime it gets a "diagnostics" request. |
| 18 | + |
| 19 | +### Request/Response format: |
| 20 | +- This extension runs an HTTP server and listens to new requests on `/diagnostics` path. |
| 21 | +- It doesn't expect any requets params or body. |
| 22 | +- The response format is defined in [response.go](./response.go). |
| 23 | + - `GlobalDiagnostics`: Data related to the overall process: |
| 24 | + 1. Profiles. |
| 25 | + 2. Internal telemetry. |
| 26 | + 3. latest collector configuration. |
| 27 | + - `ComponentDiagnostics`: Data from individual receivers, collected via registered diagnostic hooks. |
| 28 | + |
| 29 | +### Interaction with Elastic-Agent service in hybrid mode. |
| 30 | + |
| 31 | +- When the user triggers the diagnostic request, EDOT diagnostics are injected at two levels: |
| 32 | + 1. At top-Level: |
| 33 | + - When `DiagnosticAgent()` is called in [server.go](https://github.com/elastic/elastic-agent/blob/710c49f45433e2f136a6e41cae980c1aa37dabdd/pkg/control/v2/server/server.go#L197). |
| 34 | + - Diagnostics are captured at the global level and stored under the `edot/*` directory in the resulting ZIP archive. |
| 35 | + 2. At component-level: |
| 36 | + - When `otelMgr.PerformComponentsDiagnostics()` is called in [coordinator.go](https://github.com/elastic/elastic-agent/blob/710c49f45433e2f136a6e41cae980c1aa37dabdd/internal/pkg/agent/application/coordinator/coordinator.go#L863). |
| 37 | + - Diagnostics are added per component and stored under the `components/{comp}/*` directory in the resulting ZIP archive. |
0 commit comments