Commit graph

27 commits

Author SHA1 Message Date
Kibana Machine
47824556cf
[8.8] Profiling: symbolization created on user opt-in (#156089) (#156449)
# Backport

This will backport the following commits from `main` to `8.8`:
- [Profiling: symbolization created on user opt-in
(#156089)](https://github.com/elastic/kibana/pull/156089)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Francesco
Gualazzi","email":"inge4pres@users.noreply.github.com"},"sourceCommit":{"committedDate":"2023-05-02T18:24:54Z","message":"Profiling:
symbolization created on user opt-in (#156089)\n\nSigned-off-by:
inge4pres <francesco.gualazzi@elastic.co>\r\n\r\n##
Summary\r\n\r\nInclude the creation of symbolizer package policy in the
setup initiated\r\nby users when they opt-in Universal
Profiling.\r\n\r\n### Checklist\r\n\r\n-
[X]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas
added for features that require explanation or tutorials\r\n- [X] [Unit
or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n\r\n### For
maintainers\r\n\r\n- [ ] This was checked for breaking API changes and
was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n###
Related issues or PRs\r\n*
https://github.com/elastic/kibana/pull/155642\r\n*
https://github.com/elastic/kibana/pull/150885\r\n\r\n---------\r\n\r\nSigned-off-by:
inge4pres <francesco.gualazzi@elastic.co>\r\nCo-authored-by:
kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\r\nCo-authored-by: Jen
Huang
<its.jenetic@gmail.com>","sha":"d4f6cf703da8022aeedfabca6ff7689faf67e071","branchLabelMapping":{"^v8.9.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","auto-backport","ci:build-cloud-image","8.8
candidate","v8.8.0","v8.9.0"],"number":156089,"url":"https://github.com/elastic/kibana/pull/156089","mergeCommit":{"message":"Profiling:
symbolization created on user opt-in (#156089)\n\nSigned-off-by:
inge4pres <francesco.gualazzi@elastic.co>\r\n\r\n##
Summary\r\n\r\nInclude the creation of symbolizer package policy in the
setup initiated\r\nby users when they opt-in Universal
Profiling.\r\n\r\n### Checklist\r\n\r\n-
[X]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas
added for features that require explanation or tutorials\r\n- [X] [Unit
or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n\r\n### For
maintainers\r\n\r\n- [ ] This was checked for breaking API changes and
was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n###
Related issues or PRs\r\n*
https://github.com/elastic/kibana/pull/155642\r\n*
https://github.com/elastic/kibana/pull/150885\r\n\r\n---------\r\n\r\nSigned-off-by:
inge4pres <francesco.gualazzi@elastic.co>\r\nCo-authored-by:
kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\r\nCo-authored-by: Jen
Huang
<its.jenetic@gmail.com>","sha":"d4f6cf703da8022aeedfabca6ff7689faf67e071"}},"sourceBranch":"main","suggestedTargetBranches":["8.8"],"targetPullRequestStates":[{"branch":"8.8","label":"v8.8.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"main","label":"v8.9.0","labelRegex":"^v8.9.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/156089","number":156089,"mergeCommit":{"message":"Profiling:
symbolization created on user opt-in (#156089)\n\nSigned-off-by:
inge4pres <francesco.gualazzi@elastic.co>\r\n\r\n##
Summary\r\n\r\nInclude the creation of symbolizer package policy in the
setup initiated\r\nby users when they opt-in Universal
Profiling.\r\n\r\n### Checklist\r\n\r\n-
[X]\r\n[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)\r\nwas
added for features that require explanation or tutorials\r\n- [X] [Unit
or
functional\r\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\r\nwere
updated or added to match the most common scenarios\r\n\r\n### For
maintainers\r\n\r\n- [ ] This was checked for breaking API changes and
was
[labeled\r\nappropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\r\n\r\n###
Related issues or PRs\r\n*
https://github.com/elastic/kibana/pull/155642\r\n*
https://github.com/elastic/kibana/pull/150885\r\n\r\n---------\r\n\r\nSigned-off-by:
inge4pres <francesco.gualazzi@elastic.co>\r\nCo-authored-by:
kibanamachine
<42973632+kibanamachine@users.noreply.github.com>\r\nCo-authored-by: Jen
Huang
<its.jenetic@gmail.com>","sha":"d4f6cf703da8022aeedfabca6ff7689faf67e071"}}]}]
BACKPORT-->

Co-authored-by: Francesco Gualazzi <inge4pres@users.noreply.github.com>
2023-05-02 15:02:20 -07:00
Daniel Mitterdorfer
4e8e6cd2f7
[Profiling] Avoid duplicate mapping of host ips (#155353)
Previously we had mapped host ips as keywords as well as ips in order to
work around #140266. This has been fixed with #154111 so we can rely on
the IP field and remove the duplicate.

Relates #154111
Relates #140266
2023-04-20 12:42:14 +02:00
Cauê Marcondes
2f001a2f8d
[Profiling] Space-specific feature privileges (#154734) 2023-04-11 20:35:48 -04:00
Cauê Marcondes
2e5bee37ba
[Profiling] Using json to create indices (#153064)
Read the ES mappings from JSON files instead of having them hard-coded as JS/TS.

We currently need the same mappings in the another repository in JSON format.
Using JSON files in both places eases automated comparison to detect diversions.
---------

Co-authored-by: Tim Rühsen <tim.ruehsen@gmx.de>
2023-03-10 02:41:51 -07:00
Tim Rühsen
1ab5aed539
[Profiling] Add indices for private symbols to the 1-click setup (#153046)
Add setup/creation of indices `profiling-symbols-private` and
`profiling-returnpads-private`.
2023-03-09 12:46:47 -07:00
Daniel Mitterdorfer
e97f488a1a
[Profiling] Fine-tune mappings (#152799)
With this commit we avoid storing doc values for
`stackframe.function.name` to save disk space as doc values are not
needed due to our access pattern. We also sort stack traces by stack
frame ids to improve disk layout.
2023-03-07 04:53:58 -07:00
Dario Gieselaar
807b402f0b
[Profling] Single-click setup from Kibana (#148959)
Co-authored-by: inge4pres <francesco.gualazzi@elastic.co>
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Tim Rühsen <tim.ruehsen@gmx.de>
Co-authored-by: Francesco Gualazzi <inge4pres@users.noreply.github.com>
Closes https://github.com/elastic/prodfiler/issues/2884
2023-02-07 06:10:30 -07:00
Joseph Crail
b42bb18119
[Profiling] Prepare for inline stackframes (#150401)
This PR adds initial support for initial stackframes as described in
elastic/prodfiler#2918.

It also adds tests and a minor refactor to account for the removal of
synthetic source from stackframes (see elastic/prodfiler#2850).

For stackframes, the profiling stack is composed of multiple write paths
into Elasticsearch and multiple read paths out of Elasticsearch:
* there are three services that can write into Elasticsearch (`APM
agent`, `pf-elastic-collector`, and `pf-elastic-symbolizer`).
* there are also two ways to read from Elasticsearch (the profiling
plugin in Elasticsearch, and a combination of `search` and `mget`
calls).

This PR was written to handle all permutations of these paths. For those
reviewers that wish to try the PR, please keep this in mind. I also
wrote tests to handle these permutations.

Note: Future PRs will add full support for inline stackframes. At this
time, we only read the first inlined stackframe since the UI does not
support inline stackframes.

---------

Co-authored-by: Tim Rühsen <tim.ruhsen@elastic.co>
2023-02-07 05:22:59 -07:00
Tim Rühsen
14af4a1643
Fix handling the stackframes response from the ES plugin (#150205)
## Summary
Flamegraph and TopN Functions don't display currently.
The reason is a missing backwards compatibility in the handling/parsing
of stackframes.
This is  quick fix to avoid blocking other PRs.

See https://github.com/elastic/prodfiler/issues/2951

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2023-02-02 17:13:03 -08:00
Tim Rühsen
62e0d0ebb8
Remove unused/obsolete source type field from frames metadata (#150013)
## Summary
We don't use the source type for frames, but parse it from the query
response.

In the near future, we remove this field completely from the
`profiling-stackframes` index, because we have no reliable way to
determine the type of source code for a frame of type 'native' or
'kernel'.
For interpreted languages we have this information stored in the
`profiling-stacktraces` index.
2023-02-02 20:34:42 +01:00
Joseph Crail
a58aaeb6a8
[Profiling] Retrieve profiling data via Elasticsearch plugin (#147152)
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Dario Gieselaar <dario.gieselaar@elastic.co>
2023-01-10 09:21:01 -07:00
Dario Gieselaar
313537c178
[Profiling] Configurable ES client (#144533) 2022-12-07 08:36:13 -07:00
Joseph Crail
642ab74cfc
[Profiling] Add APIs to clear frame and executable caches (#145499)
This PR adds two endpoints to clear each respective cache:

* `DELETE {BASE_KIBANA_PATH}/api/profiling/v1/cache/executables`
* `DELETE {BASE_KIBANA_PATH}/api/profiling/v1/cache/stackframes`

Related to https://github.com/elastic/prodfiler/issues/2759

#### Design choices

1. The `DELETE` method was chosen instead of `PUT` or `POST` since the
given semantics of `DELETE` matches the expected behavior for the
related issue.
2. Each endpoint will remove all items from the respective cache. A
separate API for each cache allows us to selectively clear the necessary
cache without the downsides of a catch-all endpoint to clear all caches.
This gives us the flexibility to add more endpoints if needed. Given the
tradeoff between complexity now or later, it was decided to implement
general invalidation now with the option to invalidate specific items
later.
3. The RESTful design allows us to clear specific items later (e.g.
`DELETE {BASE_KIBANA_PATH}/api/profiling/v1/cache/executables/{ID}`
could clear only executable `ID` from the cache).
4. Each endpoint returns an empty payload on success. However, the
Kibana logs reflect the actions taken and how many cache items were
affected.
5. The stacktrace cache was ignored since it was not affected by symbols
written to Elasticsearch.
6. Each endpoint is not directly accessible from UI since it is expected
that the endpoints will be called outside of Kibana. However, the
endpoints can be called manually from the browser's console.
2022-11-17 11:04:58 +01:00
Joseph Crail
1fdf4a6453
[Profiling] Add TTL to cached frames and executables (#144292)
* Add TTL to cached frames and executables

* Fix misspelled constant
2022-11-04 20:50:57 -07:00
Joseph Crail
a4b20e6e89
[Profiling] Improve performance when decoding stacktraces (#143084)
* Derive address and file ID from base64 encoding

This skips the intermediate deserialization step to a buffer object.

* Move run-length encoding methods

* Decode run-length directly from base64 encoding

This skips the intermediate deserialization step to a buffer object.

* Minor refactor

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2022-10-24 16:24:31 -07:00
Joseph Crail
35e8170a5a
[Profiling] Check caches before querying (#143089)
* Add LRU cache for stackframes

* Add LRU cache for executables

* Remove splitting mgets into chunks

* Move LRU cache for stacktraces before query

* Summarize cache and query results

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2022-10-17 14:24:14 -07:00
Dario Gieselaar
7ed94ad679
[Profiling] Add span for decoding stacktraces (#143054) 2022-10-11 15:25:39 +02:00
Dario Gieselaar
c05190e516
[Profiling] Auto-abort requests (#142750) 2022-10-06 09:17:14 +02:00
Joseph Crail
c888aca9b4
[Profiling] Move additional flamegraph calculations into UI (#142415)
* Remove total and sampled traces from API

* Remove Samples array from flamegraph API

These values are redundant with CountInclusive so could be removed
without issue.

* Remove totalCount and eventsIndex

These values are no longer needed.

* Remove samples from callee tree

* Refactor columnar view model into separate file

* Add more lazy-loaded flamegraph calculations

* Fix spacing in frame label

* Remove frame information API

* Improve test coverage

* Fix type error

* Replace fnv-plus with custom 64-bit FNV1-a

* Add exceptions for linting errors

* Add workaround for frame type truncation bug

* Replace prior workaround for truncation bug

This fix supercedes the prior workaround and addresses the truncation at
its source.

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2022-10-05 06:10:38 -07:00
Joseph Crail
924c7f912a
[Profiling] Simplify query post-processing and flamegraph response (#141729)
* Replace non-null assertion with nullish coalescing

* Remove createFrameGroup

* Remove callers

* Use adjacency list representation for tree

* Move frame type map outside function

* Inline frame group name

* Replace FrameGroupID with ID

* Create columnar view model in client
2022-09-26 10:27:06 -07:00
Joseph Crail
d4c17b8f61
Fix one-by-error for run-length encoding (#141555)
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2022-09-23 04:09:41 -07:00
Joseph Crail
d8901857aa
[Profiling] Reduce CPU usage for flamegraph and TopN function (#141017)
* Add instrumentation for flamegraph

I inlined the construction of the flamegraph into the respective route
so that we could add fine-grained instrumentation. We now use APM and
console logging to understand how long flamegraph construction takes.

* Remove unnecessary Set usage

* Remove superfluous clone

This was likely added when we needed to avoid infinite recursion when
serializing to JSON. This no longer has a useful function.

* Pass in pre-calculated frame group info

I noticed that we were creating frame group info multiple times so I
added it as a parameter for the intermediate node.

* Sort callees in one place

Callees should be sorted first by samples decreasing and then by frame
groups. Combining the two sorts makes the post-processing clearer to
future readers and/or maintainers.

* Capitalize fields in preparation of merging

* Align both node data structures

* Pass metadata instead of copying fields

* Refactor frame label method

* Use pre-calculated array length

* Use pre-allocated array

* Refactor intermediate node

* Remove intermediate node structure

* Move if statement out of for loop

* Fix comments

* Sort sibling nodes by frame group ID

* Calculate graph size during creation

* Add missing groupStackFrameMetadataByStackTrace

* Fix formatting

* Fix generated callee source

* Fix creation of frame group

* Fix test

* Remove filter for relevant traces

* Stop passing frame group

* Create root node inside createCallerCalleeGraph

* Fix timestamps

* Remove frame group comparator

* Add instrumentation for topN functions

* Allow for missing stacktraces

* Use Date.now instead
2022-09-22 09:37:45 -07:00
Joseph Crail
cea17e3dbe
Replace log execution latency (#141341) 2022-09-22 11:44:10 +02:00
Pierre Gayvallet
9579ea7235
Move src/core/types/elasticsearch to @kbn/es-types (#140522)
* create empty package

* move types to packages

* [CI] Auto-commit changed files from 'node scripts/generate codeowners'

* start fixing imports

* fix more imports

* fix inline import

* add apm-ui as owners

* [CI] Auto-commit changed files from 'node scripts/generate codeowners'

* fix new usages

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2022-09-20 10:32:13 +02:00
Dario Gieselaar
c522506519
[Profiling] Show host.name or host.ip when available (#140941) 2022-09-19 06:53:41 -07:00
Dario Gieselaar
fabdee3dde
[Profiling] Use 'Universal Profiling' everywhere (#140906) 2022-09-19 02:21:14 -07:00
Dario Gieselaar
b66cf585ca
[Profiling] Add Profiling application (#140722)
Co-authored-by: Joseph Crail <jbcrail@gmail.com>
Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: Dario Gieselaar <dario.gieselaar@elastic.co>
Co-authored-by: Joseph Crail <joseph.crail@elastic.co>
Co-authored-by: Stephanie Boomsma <stephanieboomsma@optimyze.cloud>
Co-authored-by: inge4pres <fgualazzi@gmail.com>
Co-authored-by: inge4pres <francesco.gualazzi@elastic.co>
Co-authored-by: Francesco Gualazzi <inge4pres@users.noreply.github.com>
Co-authored-by: Tim Rühsen <tim.ruhsen@elastic.co>
Co-authored-by: Tim Rühsen <tim.ruehsen@gmx.de>
2022-09-15 19:24:41 +02:00