kibana/x-pack/plugins/apm
Walter Rafelsberger 5e2c22cef9
[ML] Latency correlations: Fix "Failed to build correlative_value after last required field arrived" error. (#107040)
The wrong percentiles variable was used to derive ranges, it needs to use tempPercentiles instead. With certain data this would lead to ranges, expectations and percentiles to have different lengths.
2021-07-29 01:25:04 +02:00
..
.storybook Storybook EUI theme decorator (#103582) 2021-07-09 08:54:48 -05:00
common [APM] Backends inventory & overview page routes (#106223) 2021-07-21 09:28:52 -04:00
dev_docs [APM] Typed client-side routing (#104274) 2021-07-15 11:30:59 +02:00
e2e [User Experience App] Use filters shared component (#101459) 2021-06-17 19:19:16 +02:00
ftr_e2e [APM] Update ES archive for tests (#106837) 2021-07-27 14:16:03 -04:00
public [APM] Fix data streams docs link url (#105651) (#106954) 2021-07-28 15:21:01 +02:00
scripts [APM] Update ES archive for tests (#106837) 2021-07-27 14:16:03 -04:00
server [ML] Latency correlations: Fix "Failed to build correlative_value after last required field arrived" error. (#107040) 2021-07-29 01:25:04 +02:00
typings [APM] Add “Analyze Data” button (#103485) 2021-06-30 10:20:31 +02:00
.prettierrc
CONTRIBUTING.md
jest.config.js Storybook EUI theme decorator (#103582) 2021-07-09 08:54:48 -05:00
kibana.json [APM] Make fleet plugin dependency optional (#104967) 2021-07-09 13:46:52 -04:00
readme.md [APM] Update ESLint and tsc commands in APM readme (#101207) 2021-06-04 05:27:11 -04:00
tsconfig.json [APM] Syncs agent config settings to APM Fleet policies (#100744) 2021-06-08 18:52:49 -04:00

Documentation for APM UI developers

Local environment setup

Kibana

git clone git@github.com:elastic/kibana.git
cd kibana/
yarn kbn bootstrap
yarn start --no-base-path

APM Server, Elasticsearch and data

To access an elasticsearch instance that has live data you have two options:

A. Connect to Elasticsearch on Cloud (internal devs only)

Find the credentials for the cluster here

B. Start Elastic Stack and APM data generators

git clone git@github.com:elastic/apm-integration-testing.git
cd apm-integration-testing/
./scripts/compose.py start master --all --no-kibana

Docker Compose is required

Testing

Cypress tests

node x-pack/plugins/apm/scripts/ftr_e2e/cypress_run.js

Starts Kibana (:5701), APM Server (:8201) and Elasticsearch (:9201). Ingests sample data into Elasticsearch via APM Server and runs the Cypress tests

Jest tests

Note: Run the following commands from kibana/x-pack/plugins/apm.

Run

npx jest --watch

Update snapshots

npx jest --updateSnapshot

Coverage

HTML coverage report can be found in target/coverage/jest after tests have run.

open target/coverage/jest/index.html

Functional tests

Start server

node scripts/functional_tests_server --config x-pack/test/functional/config.js

Run tests

node scripts/functional_test_runner --config x-pack/test/functional/config.js --grep='APM specs'

APM tests are located in x-pack/test/functional/apps/apm. For debugging access Elasticsearch on http://localhost:9220` (elastic/changeme)

API integration tests

API tests are separated in two suites:

  • a basic license test suite
  • a trial license test suite (the equivalent of gold+)

This requires separate test servers and test runners.

Basic

# Start server
node scripts/functional_tests_server --config x-pack/test/apm_api_integration/basic/config.ts

# Run tests
node scripts/functional_test_runner --config x-pack/test/apm_api_integration/basic/config.ts

The API tests for "basic" are located in x-pack/test/apm_api_integration/basic/tests.

Trial

# Start server
node scripts/functional_tests_server --config x-pack/test/apm_api_integration/trial/config.ts

# Run tests
node scripts/functional_test_runner --config x-pack/test/apm_api_integration/trial/config.ts

The API tests for "trial" are located in x-pack/test/apm_api_integration/trial/tests.

API Test tips

  • For debugging access Elasticsearch on http://localhost:9220` (elastic/changeme)
  • To update snapshots append --updateSnapshots to the functional_test_runner command

Linting

Note: Run the following commands from kibana/.

Typescript

node scripts/type_check.js --project x-pack/plugins/apm/tsconfig.json

Prettier

yarn prettier  "./x-pack/plugins/apm/**/*.{tsx,ts,js}" --write

ESLint

node scripts/eslint.js x-pack/legacy/plugins/apm

Setup default APM users

APM behaves differently depending on which the role and permissions a logged in user has. For testing purposes APM uses 3 custom users:

apm_read_user: Apps: read. Indices: read (apm-*)

apm_write_user: Apps: read/write. Indices: read (apm-*)

kibana_write_user Apps: read/write. Indices: None

To create the users with the correct roles run the following script:

node x-pack/plugins/apm/scripts/setup-kibana-security.js --role-suffix <github-username-or-something-unique>

The users will be created with the password specified in kibana.dev.yml for elasticsearch.password

Debugging Elasticsearch queries

All APM api endpoints accept _inspect=true as a query param that will result in the underlying ES query being outputted in the Kibana backend process.

Example: /api/apm/services/my_service?_inspect=true

Storybook

Start the Storybook development environment with yarn storybook apm. All files with a .stories.tsx extension will be loaded. You can access the development environment at http://localhost:9001.

Experimental features settings

To set up a flagged feature, add the name of the feature key (apm:myFeature) to commmon/ui_settings_keys.ts and the feature parameters to server/ui_settings.ts.

Test for the feature like:

import { myFeatureEnabled } from '../ui_settings_keys';
if (core.uiSettings.get(myFeatureEnabled)) {
  doStuff();
}

Settings can be managed in Kibana under Stack Management > Advanced Settings > Observability.

Further resources