Skip to content

[APM] Add elasticsearch queries to api response#95146

Merged
sorenlouv merged 1 commit intoelastic:masterfrom
sorenlouv:add-apm-debug-mode-setting
Mar 29, 2021
Merged

[APM] Add elasticsearch queries to api response#95146
sorenlouv merged 1 commit intoelastic:masterfrom
sorenlouv:add-apm-debug-mode-setting

Conversation

@sorenlouv
Copy link
Copy Markdown
Contributor

@sorenlouv sorenlouv commented Mar 23, 2021

This PR appends elasticsearch queries to the response to allow the end user to inspect them.

Noteworthy changes:

  • _debug=true query param has been renamed to _inspect=true. In addition to logging elasticsearch queries in the node process, they will also be send to the client as part of the api response. Only queries authenticated as the end user will be send to the client due to security concerns.
  • API's must return an object. Arrays and primitive return types (string, number, null, undefined) is no longer allowed.
  • sessionStorage.set('apm_debug', 'true') has been replaced with a setting in Kibana Advanced Settings

Debug mode is disabled by default but can be enabled in Advanced Settings
image

When debug mode is enabled a callout will make the user aware of this
image

When debug mode all API requests will contain _debugQueries
image

@sorenlouv sorenlouv requested a review from a team March 23, 2021 11:56
@sorenlouv sorenlouv requested a review from a team as a code owner March 23, 2021 11:56
@botelastic botelastic bot added Team:APM - DEPRECATED Use Team:obs-ux-infra_services. Team:Uptime - DEPRECATED Synthetics & RUM sub-team of Application Observability labels Mar 23, 2021
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/apm-ui (Team:apm)

@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/uptime (Team:uptime)

@sorenlouv sorenlouv added v7.13.0 v8.0.0 release_note:skip Skip the PR/issue when compiling release notes auto-backport Deprecated - use backport:version if exact versions are needed labels Mar 23, 2021
@sorenlouv sorenlouv changed the title [APM] Add debug queries to api response [APM] Add elasticsearch queries to api response Mar 23, 2021
Copy link
Copy Markdown
Contributor

@smith smith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works!

I think if you're adding an advanced setting you'll also need to add the field in src/plugins/kibana_usage_collection/server/collectors/management/schema.ts and src/plugins/kibana_usage_collection/server/collectors/management/types.ts and run the telemetry script.

@shahzad31
Copy link
Copy Markdown
Contributor

Can we please make this observability wide setting?

We have the same kind of debug mode in uptime. Consolidating UI setting observability wide will make lot of sense. WDYT?

@sorenlouv
Copy link
Copy Markdown
Contributor Author

Can we please make this observability wide setting?

It's already in the Observability section of Advanced Settings. I can move the settings implementation out of the APM app if that's what you mean? And then each app can choose whether they want to implement the feature. Sounds ok?

@sorenlouv sorenlouv requested review from a team as code owners March 23, 2021 23:36
@sorenlouv sorenlouv force-pushed the add-apm-debug-mode-setting branch from edba126 to 85c8480 Compare March 23, 2021 23:51
Copy link
Copy Markdown
Contributor

@dgieselaar dgieselaar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be feasible to add an API test to verify that it doesn't leak data from calls made as the internal user?

@shahzad31
Copy link
Copy Markdown
Contributor

Can we please make this observability wide setting?

It's already in the Observability section of Advanced Settings. I can move the settings implementation out of the APM app if that's what you mean? And then each app can choose whether they want to implement the feature. Sounds ok?

I also meant in terms of UI setting name, instead of saying APMDebug queries, we can say Observability Debug queries.

That way i don't want to add another checkbox there with Uptime Debug queries or User Experience debug quries.

@shahzad31
Copy link
Copy Markdown
Contributor

does this still logs to kibana logs?

@sorenlouv
Copy link
Copy Markdown
Contributor Author

I also meant in terms of UI setting name, instead of saying APMDebug queries, we can say Observability Debug queries.

That way i don't want to add another checkbox there with Uptime Debug queries or User Experience debug quries.

Makes sense. I've updated the setting description to not mention APM.

does this still logs to kibana logs?

Yes, nothing changes there.

@sorenlouv
Copy link
Copy Markdown
Contributor Author

Would it be feasible to add an API test to verify that it doesn't leak data from calls made as the internal user?
@dgieselaar

Good idea, will add that

Copy link
Copy Markdown
Contributor

@shahzad31 shahzad31 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Changes LGTM for UX and Uptime !!

@sorenlouv sorenlouv force-pushed the add-apm-debug-mode-setting branch 2 times, most recently from 4b7b88d to be064b6 Compare March 28, 2021 18:12
ts fixes

Fix APIs to always return objects

minor fixes

use beaker icon

update copy

move setting to observability

Rename `_debug` to `_inspect`

fix api tests

disallow empty responses

rename test

fix i18n

WIP

fix param type check

fix remaining tests

minor improvements

Fix jest

Add api test for inspect flag

Fix tsc

Fix jest tests

Fix tsc issues
@sorenlouv sorenlouv force-pushed the add-apm-debug-mode-setting branch from 152c41e to 1b9def7 Compare March 28, 2021 22:40
@sorenlouv sorenlouv merged commit 84adfe5 into elastic:master Mar 29, 2021
@sorenlouv sorenlouv deleted the add-apm-debug-mode-setting branch March 29, 2021 05:50
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Mar 29, 2021
@kibanamachine
Copy link
Copy Markdown
Contributor

💚 Backport successful

7.x / #95625

This backport PR will be merged automatically after passing CI.

kibanamachine added a commit that referenced this pull request Mar 29, 2021
Co-authored-by: Søren Louv-Jansen <sorenlouv@gmail.com>
@kibanamachine
Copy link
Copy Markdown
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
apm 1569 1570 +1

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
apm 4.2MB 4.2MB +4.7KB
observability 327.1KB 327.1KB +21.0B
uptime 879.8KB 879.8KB +2.0B
total +4.7KB

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
apm 22.1KB 22.2KB +5.0B
observability 26.0KB 26.6KB +641.0B
total +646.0B

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

axw added a commit to axw/apm-server that referenced this pull request Mar 31, 2021
In elastic/kibana#95146
the response structure for listing APM agent central
config changed. Update system tests to match.
axw added a commit to elastic/apm-server that referenced this pull request Mar 31, 2021
* tests/system: adapt to new API response

In elastic/kibana#95146
the response structure for listing APM agent central
config changed. Update system tests to match.

* tests/system: add user_agent.device.type

elastic/elasticsearch#69322
added support for extracting device types to the
user_agent ingest processors. Update approvals to
match.
mergify bot pushed a commit to elastic/apm-server that referenced this pull request Mar 31, 2021
* tests/system: adapt to new API response

In elastic/kibana#95146
the response structure for listing APM agent central
config changed. Update system tests to match.

* tests/system: add user_agent.device.type

elastic/elasticsearch#69322
added support for extracting device types to the
user_agent ingest processors. Update approvals to
match.

(cherry picked from commit 0e09aa6)
axw added a commit to elastic/apm-server that referenced this pull request Apr 1, 2021
* tests/system: fix system tests (#5037)

* tests/system: adapt to new API response

In elastic/kibana#95146
the response structure for listing APM agent central
config changed. Update system tests to match.

* tests/system: add user_agent.device.type

elastic/elasticsearch#69322
added support for extracting device types to the
user_agent ingest processors. Update approvals to
match.

(cherry picked from commit 0e09aa6)

* user_agent.device.type isn't in 7.x yet

* make update

* systemtest: revert approvals changes

Co-authored-by: Andrew Wilkins <axw@elastic.co>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
@cauemarcondes cauemarcondes self-assigned this May 6, 2021
@cauemarcondes
Copy link
Copy Markdown
Contributor

tests ok

bmorelli25 pushed a commit to bmorelli25/observability-docs that referenced this pull request Dec 18, 2023
* tests/system: adapt to new API response

In elastic/kibana#95146
the response structure for listing APM agent central
config changed. Update system tests to match.

* tests/system: add user_agent.device.type

elastic/elasticsearch#69322
added support for extracting device types to the
user_agent ingest processors. Update approvals to
match.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-backport Deprecated - use backport:version if exact versions are needed release_note:skip Skip the PR/issue when compiling release notes Team:APM - DEPRECATED Use Team:obs-ux-infra_services. Team:Uptime - DEPRECATED Synthetics & RUM sub-team of Application Observability v7.13.0 v8.0.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants