Skip to content

Commit baea492

Browse files
Add documentation for the elastic-agent diagnostics pprof commands (#1284)
* Add documentation for the elastic-agent diagnostics pprof commands Add command reference docs for gathering pprof data with the elastic-agent diagnostics collect and diagnostics pprof commands. Add secrtion to troubleshooting guide for gathering pprof data into archive. * Apply suggestions from code review Co-authored-by: DeDe Morton <dede.morton@elastic.co> * rename monitoring.pprof to monitoring.pprof.enabled * set example to false Co-authored-by: DeDe Morton <dede.morton@elastic.co>
1 parent 03da39d commit baea492

3 files changed

Lines changed: 55 additions & 5 deletions

File tree

docs/en/ingest-management/commands.asciidoc

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ Note that *credentials are not redacted* in the archive; they may appear in plai
3939

4040
This command is intended for debugging purposes only. The output format and structure of the archive produced by `collect` may change between releases.
4141

42+
If `pprof` is specified, it gathers specific `pprof` data from the {agent} or one of the specified underlying {beats}, and displays to `stdout`.
43+
By default it gathers a 30s profile of the {agent}.
44+
4245
[discrete]
4346
=== Synopsis
4447

@@ -47,8 +50,19 @@ This command is intended for debugging purposes only. The output format and stru
4750
elastic-agent diagnostics [--help] [--output <string>] [global-flags]
4851
elastic-agent diagnostics collect [--output <string>]
4952
[--file <string>]
53+
[--pprof]
54+
[--pprof-duration <string>]
55+
[--timeout <string>]
5056
[--help]
5157
[global-flags]
58+
elastic-agent diagnostics pprof [--file <string>]
59+
[--pprof-type <string]
60+
[--pprof-duration <string>]
61+
[--timeout <string>]
62+
[--pprof-application <string>]
63+
[--pprof-route-key <string>]
64+
[--help]
65+
[global-flags]
5266
----
5367

5468
[discrete]
@@ -59,8 +73,31 @@ Output format. If using `collect`, specify `json` or `yaml` (the default).
5973
Otherwise specify `json`, `yaml`, or `human` (the default).
6074

6175
`--file`::
62-
Output archive name for the `collect` option.
63-
Defaults to `elastic-agent-diagnostics-<timestamp>.zip` where the timestamp is the current time in UTC.
76+
When running `collect`, specifies the output archive name. Defaults to `elastic-agent-diagnostics-<timestamp>.zip`, where the timestamp is the current time in UTC.
77+
+
78+
When running `pprof`, specifies the output file name. Defaults to `stdout`.
79+
80+
`--pprof`::
81+
Gather `pprof` data when running `collect` (default `false`).
82+
83+
`--pprof-duration <string>`::
84+
The length for the `trace` and `profile` data that's collected when gathering `pprof` data.
85+
Must be a string that can be parsed as a `time.Duration` value (default: `30s`).
86+
87+
`--timeout <string>`::
88+
The timeout value for the `diagnostics collect` or `diagnostics pprof` command.
89+
Should be longer then `pprof-duration` as the command needs to gather and process the data.
90+
Must be a string that can be parsed as a `time.Duration` value (default: `30s + pprof-duration`).
91+
92+
`--pprof-type <string>`::
93+
The pprof data to gather, one of: `allocs`, `block`, `cmdline`, `goroutine`, `heap`, `mutex`, `profile`, `threadcreate`, or `trace` (default: `profile`).
94+
95+
`--pprof-application <string>`::
96+
The application name to gather `pprof` data from (default `elastic-agent`).
97+
98+
`--pprof-route-key <string>`::
99+
The route key (output destination) associated with the application to gather `pprof` data from (default `default`).
100+
Note that this setting is ignored in the case where `pprof-application=elastic-agent`.
64101

65102
`--help`::
66103
Show help for the `diagnostics` command.

docs/en/ingest-management/elastic-agent/configuration/elastic-agent-monitoring.asciidoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ agent.monitoring:
2323
metrics: true
2424
# exposes /debug/pprof/ endpoints for Elastic Agent and Beats
2525
# enable these endpoints if the monitoring endpoint is set to localhost
26-
pprof: false
26+
pprof.enabled: false
2727
# specifies output to be used
2828
use_output: monitoring
2929
----
@@ -37,7 +37,7 @@ To enable monitoring, set `agent.monitoring.enabled` to `true`. Also set the
3737
collected. If neither setting is specified, monitoring is turned off. Set
3838
`use_output` to specify the output to which monitoring events are sent.
3939

40-
The `agent.monitoring.pprof` option controls whether the {agent} and {beats} expose the
40+
The `agent.monitoring.pprof.enabled` option controls whether the {agent} and {beats} expose the
4141
`/debug/pprof/` endpoints with the monitoring endpoints. It is set to `false`
4242
by default. Data produced by these endpoints can be useful for debugging but present a
4343
security risk. It is recommended that this option remains `false` if the monitoring endpoint

docs/en/ingest-management/troubleshooting/troubleshooting.asciidoc

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,9 +253,22 @@ This archive collects the following information:
253253

254254
Note that the diagnostics bundle is intended for debugging purposes only, its structure may change between releases.
255255

256-
IMPORTANT: The configration files in the archive may have credentials in *plain text*.
256+
IMPORTANT: The configuration files in the archive may have credentials in *plain text*.
257257
These will need to be manually redacted before the archive is shared.
258258

259+
The diagnostics command is also able to collect `pprof` data in the archive if the `--pprof` flag is passed:
260+
261+
[source,shell]
262+
----
263+
elastic-agent diagnostics collect --pprof
264+
----
265+
266+
By default this command takes a little more than 30s to run because it collects 30s trace and profile information from the {agent} and all underlying {beats}.
267+
To change the duration of the trace and profile data, set the `--pprof-duration` flag.
268+
269+
To set the timeout value for the collection command, use the `--timeout` flag. The timeout defaults to 30s + `pprof-duration`.
270+
Use this flag to increase the timeout if the diagnostics command times out before creating the archive.
271+
259272
[discrete]
260273
[[not-installing-no-logs-in-terminal]]
261274
== Some problems occur so early that insufficient logging is available

0 commit comments

Comments
 (0)