diff --git a/cmd/profilecli/main.go b/cmd/profilecli/main.go index 9f293f8032..d0fe5d3e5a 100644 --- a/cmd/profilecli/main.go +++ b/cmd/profilecli/main.go @@ -59,8 +59,8 @@ func main() { blocksQueryCmd := blocksCmd.Command("query", "Query on local/remote blocks.") blocksQuerySeriesCmd := blocksQueryCmd.Command("series", "Request series labels on local/remote blocks.") blocksQuerySeriesParams := addBlocksQuerySeriesParams(blocksQuerySeriesCmd) - blocksQueryMergeCmd := blocksQueryCmd.Command("merge", "Request merged profile on local/remote block.") - blocksQueryMergeParams := addBlocksQueryMergeParams(blocksQueryMergeCmd) + blocksQueryProfileCmd := blocksQueryCmd.Command("profile", "Request merged profile on local/remote block.").Alias("merge") + blocksQueryProfileParams := addBlocksQueryProfileParams(blocksQueryProfileCmd) parquetCmd := adminCmd.Command("parquet", "Operate on a Parquet file.") parquetInspectCmd := parquetCmd.Command("inspect", "Inspect a parquet file's structure.") @@ -71,9 +71,9 @@ func main() { tsdbSeriesFiles := tsdbSeriesCmd.Arg("file", "tsdb file path").Required().ExistingFiles() queryCmd := app.Command("query", "Query profile store.") - queryMergeCmd := queryCmd.Command("merge", "Request merged profile.") - queryMergeOutput := queryMergeCmd.Flag("output", "How to output the result, examples: console, raw, pprof=./my.pprof").Default("console").String() - queryMergeParams := addQueryMergeParams(queryMergeCmd) + queryProfileCmd := queryCmd.Command("profile", "Request merged profile.").Alias("merge") + queryProfileOutput := queryProfileCmd.Flag("output", "How to output the result, examples: console, raw, pprof=./my.pprof").Default("console").String() + queryProfileParams := addQueryProfileParams(queryProfileCmd) queryGoPGOCmd := queryCmd.Command("go-pgo", "Request profile for Go PGO.") queryGoPGOOutput := queryGoPGOCmd.Flag("output", "How to output the result, examples: console, raw, pprof=./my.pprof").Default("pprof=./default.pgo").String() queryGoPGOParams := addQueryGoPGOParams(queryGoPGOCmd) @@ -125,8 +125,8 @@ func main() { os.Exit(checkError(err)) } } - case queryMergeCmd.FullCommand(): - if err := queryMerge(ctx, queryMergeParams, *queryMergeOutput); err != nil { + case queryProfileCmd.FullCommand(): + if err := queryProfile(ctx, queryProfileParams, *queryProfileOutput); err != nil { os.Exit(checkError(err)) } case queryGoPGOCmd.FullCommand(): @@ -142,8 +142,8 @@ func main() { if err := blocksQuerySeries(ctx, blocksQuerySeriesParams); err != nil { os.Exit(checkError(err)) } - case blocksQueryMergeCmd.FullCommand(): - if err := blocksQueryMerge(ctx, blocksQueryMergeParams); err != nil { + case blocksQueryProfileCmd.FullCommand(): + if err := blocksQueryProfile(ctx, blocksQueryProfileParams); err != nil { os.Exit(checkError(err)) } diff --git a/cmd/profilecli/query-blocks.go b/cmd/profilecli/query-blocks.go index ecdb74c95b..982478cf2e 100644 --- a/cmd/profilecli/query-blocks.go +++ b/cmd/profilecli/query-blocks.go @@ -27,7 +27,7 @@ type blocksQueryParams struct { Query string } -type blocksQueryMergeParams struct { +type blocksQueryProfileParams struct { *blocksQueryParams Output string ProfileType string @@ -49,8 +49,8 @@ func addBlocksQueryParams(queryCmd commander) *blocksQueryParams { return params } -func addBlocksQueryMergeParams(queryCmd commander) *blocksQueryMergeParams { - params := new(blocksQueryMergeParams) +func addBlocksQueryProfileParams(queryCmd commander) *blocksQueryProfileParams { + params := new(blocksQueryProfileParams) params.blocksQueryParams = addBlocksQueryParams(queryCmd) queryCmd.Flag("output", "How to output the result, examples: console, raw, pprof=./my.pprof").Default("console").StringVar(¶ms.Output) queryCmd.Flag("profile-type", "Profile type to query.").Default("process_cpu:cpu:nanoseconds:cpu:nanoseconds").StringVar(¶ms.ProfileType) @@ -65,12 +65,12 @@ func addBlocksQuerySeriesParams(queryCmd commander) *blocksQuerySeriesParams { return params } -func blocksQueryMerge(ctx context.Context, params *blocksQueryMergeParams) error { - level.Info(logger).Log("msg", "blocks query merge", "blockIds", fmt.Sprintf("%v", params.BlockIds), "path", +func blocksQueryProfile(ctx context.Context, params *blocksQueryProfileParams) error { + level.Info(logger).Log("msg", "blocks query profile", "blockIds", fmt.Sprintf("%v", params.BlockIds), "path", cfg.blocks.path, "bucketName", params.BucketName, "tenantId", params.TenantID, "query", params.Query, "type", params.ProfileType) if len(params.BlockIds) > 1 { - return errors.New("query merge is limited to a single block") + return errors.New("query profile is limited to a single block") } profileType, err := model.ParseProfileTypeSelector(params.ProfileType) diff --git a/cmd/profilecli/query.go b/cmd/profilecli/query.go index c892da30f3..f8b01efafa 100644 --- a/cmd/profilecli/query.go +++ b/cmd/profilecli/query.go @@ -90,21 +90,21 @@ func addQueryParams(queryCmd commander) *queryParams { return params } -type queryMergeParams struct { +type queryProfileParams struct { *queryParams ProfileType string StacktraceSelector []string } -func addQueryMergeParams(queryCmd commander) *queryMergeParams { - params := new(queryMergeParams) +func addQueryProfileParams(queryCmd commander) *queryProfileParams { + params := new(queryProfileParams) params.queryParams = addQueryParams(queryCmd) queryCmd.Flag("profile-type", "Profile type to query.").Default("process_cpu:cpu:nanoseconds:cpu:nanoseconds").StringVar(¶ms.ProfileType) queryCmd.Flag("stacktrace-selector", "Only query locations with those symbols. Provide multiple times starting with the root").StringsVar(¶ms.StacktraceSelector) return params } -func queryMerge(ctx context.Context, params *queryMergeParams, outputFlag string) (err error) { +func queryProfile(ctx context.Context, params *queryProfileParams, outputFlag string) (err error) { from, to, err := params.parseFromTo() if err != nil { return err @@ -145,14 +145,14 @@ func selectMergeProfile(ctx context.Context, client *phlareClient, outputFlag st } type queryGoPGOParams struct { - *queryMergeParams + *queryProfileParams KeepLocations uint32 AggregateCallees bool } func addQueryGoPGOParams(queryCmd commander) *queryGoPGOParams { params := new(queryGoPGOParams) - params.queryMergeParams = addQueryMergeParams(queryCmd) + params.queryProfileParams = addQueryProfileParams(queryCmd) queryCmd.Flag("keep-locations", "Number of leaf locations to keep.").Default("5").Uint32Var(¶ms.KeepLocations) queryCmd.Flag("aggregate-callees", "Aggregate samples for the same callee by ignoring the line numbers in the leaf locations.").Default("true").BoolVar(¶ms.AggregateCallees) return params diff --git a/docs/sources/view-and-analyze-profile-data/profile-cli.md b/docs/sources/view-and-analyze-profile-data/profile-cli.md index 440be9f9a1..1b1dcbbebd 100644 --- a/docs/sources/view-and-analyze-profile-data/profile-cli.md +++ b/docs/sources/view-and-analyze-profile-data/profile-cli.md @@ -224,11 +224,11 @@ You can narrow the results down with the `--query` flag. See `profilecli help qu ### Reading a raw profile from a Pyroscope server -You can use the `profilecli query merge` command to retrieve a merged (aggregated) profile from a Pyroscope server. +You can use the `profilecli query profile` command to retrieve a merged (aggregated) profile from a Pyroscope server. The command merges all samples found in the profile store for the specified query and time range. By default it looks for samples within the last hour, though this can be controlled with the `--from` and `--to` flags. The source data can be narrowed down with the `--query` flag in the same way as with the `series` command. -#### Query merge steps +#### Query profile steps 1. Specify optional flags. @@ -236,7 +236,7 @@ By default it looks for samples within the last hour, though this can be control - You can provide a custom time range using the `--from` and `--to` flags, for example, `--from="now-3h" --to="now"`. - You can specify the profile type via the `--profile-type` flag. The available profile types are listed in the output of the `profilecli query series` command. -2. Construct and execute the Query Merge command. +2. Construct and execute the `query profile` command. - Here's a basic command template: ```bash @@ -244,7 +244,7 @@ By default it looks for samples within the last hour, though this can be control export PROFILECLI_USERNAME= export PROFILECLI_PASSWORD= - profilecli query merge \ + profilecli query profile \ --profile-type= \ --query='{=""' \ --from="" --to="" @@ -256,7 +256,7 @@ By default it looks for samples within the last hour, though this can be control export PROFILECLI_USERNAME=my_username export PROFILECLI_PASSWORD=my_password - profilecli query merge \ + profilecli query profile \ --profile-type=memory:inuse_space:bytes:space:bytes \ --query='{service_name="my_application_name"}' \ --from="now-1h" --to="now" @@ -278,7 +278,7 @@ By default it looks for samples within the last hour, though this can be control ### Exporting a profile for Go PGO You can use the `profilecli query go-pgo` command to retrieve an aggregated profile from a Pyroscope server for use with Go PGO. -Profiles retrieved with `profilecli query merge` include all samples found in the profile store, resulting in a large profile size. +Profiles retrieved with `profilecli query profile` include all samples found in the profile store, resulting in a large profile size. The profile size may cause issues with network transfer and slow down the PGO process. In contrast, profiles retrieved with `profilecli query go-pgo` include only the information used in Go PGO, making them significantly smaller and more efficient to handle. By default, it looks for samples within the last hour, though this can be controlled with the `--from` and `--to` flags. The source data can be narrowed down with the `--query` flag in the same way as with the `query` command.