You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Refer to the [profiling types documentation]({{< relref "../ingest-and-analyze-profile-data/profiling-types" >}}) for more information and [profile-metrics.json](https://github.com/grafana/pyroscope/blob/main/public/app/constants/profile-metrics.json) for a list of valid profile types.
253
+
{{% /admonition %}}
254
+
255
+
#### `from` and `until`
256
+
257
+
The `from` and `until` parameters determine the start and end of the time period for the query.
258
+
They can be provided in absolute and relative form.
259
+
260
+
**Absolute time**
261
+
262
+
This table details the options for passing absolute values.
Relative values are always expressed as offsets from `now`.
275
+
276
+
| Option | Example |
277
+
|:---------------|:---------------------|
278
+
| 3 hours ago |`now-3h`|
279
+
| 30 minutes ago |`now-30m`|
280
+
| 2 days ago |`now-2d`|
281
+
| 1 week ago |`now-7d` or `now-1w`|
282
+
283
+
Note that a single offset has to be provided, values such as `now-3h30m` will not work.
284
+
285
+
**Validation**
286
+
287
+
The `from` and `until` parameters are subject to validation rules related to `max_query_lookback` and `max_query_length` server parameters.
288
+
You can find more details on these parameters in the [limits section]({{< relref "./reference-configuration-parameters#limits" >}}) of the server configuration docs.
289
+
290
+
- If `max_query_lookback` is configured and`from` is before `now - max_query_lookback`, `from` will be set to `now - max_query_lookback`.
291
+
- If `max_query_lookback` is configured and `until` is before `now - max_query_lookback` the query will not be executed.
292
+
- If `max_query_length` is configured and the query interval is longer than this configuration, the query will no tbe executed.
293
+
294
+
#### `format`
295
+
296
+
The format can either be:
297
+
-`json`, in which case the response will contain a JSON object
298
+
-`dot`, in which case the response will be text containing a DOT representation of the profile
299
+
300
+
See the [Query output](#query-output) section for more information on the response structure.
301
+
302
+
#### `maxNodes`
303
+
304
+
The `maxNodes` parameter truncates the number of elements in the profile response, to allow tools (for example, a frontend) to render large profiles efficiently.
305
+
This is typically used for profiles that are known to have large stack traces.
306
+
307
+
When no value is provided, the default is taken from the `max_flamegraph_nodes_default` configuration parameter.
308
+
When a value is provided, it is capped to the `max_flamegraph_nodes_max` configuration parameter.
309
+
310
+
#### `groupBy`
311
+
312
+
The `groupBy` parameter impacts the output for the time series portion of the response.
313
+
When a valid label is provided, the response contains as many series as there are label values for the given label.
314
+
315
+
{{% admonition type="note" %}}
316
+
Pyroscope supports a single label for the group by functionality.
317
+
{{% /admonition %}}
318
+
319
+
### Query output
320
+
321
+
The output of the `/pyroscope/render` endpoint is a JSON object based on the following [schema](https://github.com/grafana/pyroscope/blob/80959aeba2426f3698077fd8d2cd222d25d5a873/pkg/og/structs/flamebearer/flamebearer.go#L28-L43):
The `flamebearer` field contains data in a form suitable for rendering a flamegraph.
335
+
Data within the flamebearer is organized in separate arrays containing the profile symbols and the sample values.
336
+
337
+
#### `metadata`
338
+
339
+
The `metadata` field contains additional information that is helpful to interpret the `flamebearer` data such as the unit (nanoseconds, bytes), sample rate and more.
340
+
341
+
#### `timeline`
342
+
343
+
The `timeline` field represents the time series for the profile.
344
+
Pyroscope pre-computes the step interval (resolution) of the timeline using the query interval (`from` and `until`). The minimum step interval is 10 seconds.
345
+
346
+
The raw profile sample data is down-sampled to the step interval (resolution) using an aggregation function. Currently only `sum` is supported.
347
+
348
+
A timeline contains a start time, a list of sample values and the step interval:
349
+
350
+
```json
351
+
{
352
+
"timeline": {
353
+
"startTime": 1577836800,
354
+
"samples": [
355
+
100,
356
+
200,
357
+
400
358
+
],
359
+
"durationDelta": 10
360
+
}
361
+
}
362
+
```
363
+
364
+
#### `groups`
365
+
366
+
The `groups` field is only populated when grouping is requested by the `groupBy` query parameter.
367
+
When this is the case, the `groups` field has an entry for every label value found for the query.
When the `format` query parameter is `dot`, the endpoint responds with a [DOT format](https://en.wikipedia.org/wiki/DOT_(graph_description_language)) data representing the queried profile.
383
+
This can be used to create an alternative visualization of the profile.
384
+
385
+
### Example queries
386
+
387
+
This example queries a local Pyroscope server for a CPU profile from the `pyroscope` service for the last hour.
See [this Python script](https://github.com/grafana/pyroscope/tree/main/examples/api/query.py) for a complete example.
417
+
216
418
## Profile CLI
217
419
218
-
The `profilecli` tool can also be used to interact with the Pyroscope server API. It supports operations such as ingesting profiles, querying for existing profiles and more. Refer to the [Profile CLI]({{< relref "../ingest-and-analyze-profile-data/profile-cli" >}}) page for more information.
420
+
The `profilecli` tool can also be used to interact with the Pyroscope server API.
421
+
The tool supports operations such as ingesting profiles, querying for existing profiles, and more.
422
+
Refer to the [Profile CLI]({{< relref "../ingest-and-analyze-profile-data/profile-cli" >}}) page for more information.
0 commit comments