Skip to content

Commit

Permalink
Merge branch 'main' into 209-meter-request-bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
ersin-erdal authored Aug 26, 2024
2 parents 56c8e95 + 486df8c commit c6fe41a
Show file tree
Hide file tree
Showing 472 changed files with 10,058 additions and 7,071 deletions.
1 change: 1 addition & 0 deletions .buildkite/ftr_platform_stateful_configs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ enabled:
- x-pack/test/functional/config.firefox.js
- x-pack/test/functional/config.upgrade_assistant.ts
- x-pack/test/functional_cloud/config.ts
- x-pack/test/functional_solution_sidenav/config.ts
- x-pack/test/kubernetes_security/basic/config.ts
- x-pack/test/licensing_plugin/config.public.ts
- x-pack/test/licensing_plugin/config.ts
Expand Down
5 changes: 5 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,7 @@ examples/guided_onboarding_example @elastic/appex-sharedux
src/plugins/guided_onboarding @elastic/appex-sharedux
packages/kbn-handlebars @elastic/kibana-security
packages/kbn-hapi-mocks @elastic/kibana-core
test/plugin_functional/plugins/hardening @elastic/kibana-security
packages/kbn-health-gateway-server @elastic/kibana-core
examples/hello_world @elastic/kibana-core
src/plugins/home @elastic/kibana-core
Expand Down Expand Up @@ -1351,7 +1352,9 @@ x-pack/plugins/cloud_integrations/cloud_full_story/server/config.ts @elastic/kib
/packages/kbn-std/src/parse_next_url.ts @elastic/kibana-core @elastic/kibana-security
/test/interactive_setup_api_integration/ @elastic/kibana-security
/test/interactive_setup_functional/ @elastic/kibana-security
/test/plugin_functional/plugins/hardening @elastic/kibana-security
/test/plugin_functional/test_suites/core_plugins/rendering.ts @elastic/kibana-security
/test/plugin_functional/test_suites/hardening @elastic/kibana-security
/x-pack/test/accessibility/apps/group1/login_page.ts @elastic/kibana-security
/x-pack/test/accessibility/apps/group1/roles.ts @elastic/kibana-security
/x-pack/test/accessibility/apps/group1/spaces.ts @elastic/kibana-security
Expand Down Expand Up @@ -1762,6 +1765,8 @@ x-pack/plugins/observability_solution/observability_shared/public/components/pro

# Shared UX
packages/react @elastic/appex-sharedux
test/functional/page_objects/solution_navigation.ts @elastic/appex-sharedux
/x-pack/test_serverless/functional/page_objects/svl_common_navigation.ts @elastic/appex-sharedux

# OpenAPI spec files
/x-pack/plugins/fleet/common/openapi @elastic/platform-docs
Expand Down
5 changes: 5 additions & 0 deletions config/serverless.security.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,3 +106,8 @@ xpack.ml.compatibleModuleType: 'security'

# Disable the embedded Dev Console
console.ui.embeddedEnabled: false

# mTLS cert paths for agentless-api calls
xpack.fleet.agentless.api.tls.certificate: "/mnt/elastic-internal/http-certs/tls.crt"
xpack.fleet.agentless.api.tls.key: "/mnt/elastic-internal/http-certs/tls.key"
xpack.fleet.agentless.api.tls.ca: "/mnt/elastic-internal/http-certs/ca.crt"
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,58 @@ This event will be indexed with the following structure:
}
```

#### Add custom metrics
Having `kibana:plugin_render_time` metric event is not always enough, depending on the use case you would likely need some complementary information to give some sense to the value reported by the metric (e.g. number of hosts, number of services, number of dataStreams, etc).
`kibana:plugin_render_time` metric API supports up to 9 numbered free fields that can be used to report numeric metrics that you intend to analyze. Note that they can be used for any type of numeric information you may want to report.

We could make use of these custom metrics using the following format:

```typescript
...
// Call onPageReady once the meaningful data has rendered and visible to the user
onPageReady({
key1: 'datasets',
value1: 5,
key2: 'documents',
value2: 1000,
});
...
```

where the `keys` will be the keys for the custom metrics we can later aggregate and analyze further.

An event using custom metrics will be indexed with the following structure:

```typescript
{
"_index": "backing-ebt-kibana-browser-performance-metrics-000001", // Performance metrics are stored in a dedicated simplified index (browser \ server).
"_source": {
"timestamp": "2024-08-13T11:29:58.275Z"
"event_type": "performance_metric", // All performance events share a common event type to simplify mapping
"eventName": 'kibana:plugin_render_time', // Event name as specified when reporting it
"duration": 736, // Event duration as specified when reporting it
"meta": {
"target": '/home',
},
"context": { // Context holds information identifying the deployment, version, application and page that generated the event
"version": "8.16.0-SNAPSHOT",
"cluster_name": "elasticsearch",
"pageName": "application:home:app",
"applicationId": "home",
"page": "app",
"entityId": "61c58ad0-3dd3-11e8-b2b9-5d5dc1715159",
"branch": "main",
...
},
"key1": "datasets",
"value1": 5,
"key2": "documents",
"value2": 1000,
...
},
}
```

### Development environment

The metric will be delivered to the [Telemetry Staging](https://telemetry-v2-staging.elastic.dev/) cluster, alongside with the event's context.
Expand Down
29 changes: 15 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,7 @@
"@kbn/guided-onboarding-plugin": "link:src/plugins/guided_onboarding",
"@kbn/handlebars": "link:packages/kbn-handlebars",
"@kbn/hapi-mocks": "link:packages/kbn-hapi-mocks",
"@kbn/hardening-plugin": "link:test/plugin_functional/plugins/hardening",
"@kbn/health-gateway-server": "link:packages/kbn-health-gateway-server",
"@kbn/hello-world-plugin": "link:examples/hello_world",
"@kbn/home-plugin": "link:src/plugins/home",
Expand Down Expand Up @@ -1294,10 +1295,10 @@
"@frsource/cypress-plugin-visual-regression-diff": "^3.3.10",
"@istanbuljs/nyc-config-typescript": "^1.0.2",
"@istanbuljs/schema": "^0.1.2",
"@jest/console": "^29.6.1",
"@jest/reporters": "^29.6.1",
"@jest/console": "^29.7.0",
"@jest/reporters": "^29.7.0",
"@jest/transform": "^29.6.1",
"@jest/types": "^29.6.1",
"@jest/types": "^29.6.3",
"@kayahr/text-encoding": "^1.3.0",
"@kbn/alerting-api-integration-helpers": "link:x-pack/test/alerting_api_integration/packages/helpers",
"@kbn/ambient-common-types": "link:packages/kbn-ambient-common-types",
Expand Down Expand Up @@ -1631,7 +1632,7 @@
"argsplit": "^1.0.5",
"autoprefixer": "^10.4.7",
"axe-core": "^4.10.0",
"babel-jest": "^29.6.1",
"babel-jest": "^29.7.0",
"babel-loader": "^8.2.5",
"babel-plugin-add-module-exports": "^1.0.4",
"babel-plugin-istanbul": "^6.1.1",
Expand Down Expand Up @@ -1685,7 +1686,7 @@
"eslint-plugin-react-perf": "^3.3.1",
"eslint-traverse": "^1.0.0",
"exit-hook": "^2.2.0",
"expect": "^29.6.1",
"expect": "^29.7.0",
"expose-loader": "^0.7.5",
"express": "^4.19.2",
"faker": "^5.1.0",
Expand All @@ -1704,16 +1705,16 @@
"http2-proxy": "^5.0.53",
"http2-wrapper": "^2.2.1",
"ignore": "^5.3.0",
"jest": "^29.6.1",
"jest": "^29.7.0",
"jest-canvas-mock": "^2.5.2",
"jest-cli": "^29.6.1",
"jest-config": "^29.6.1",
"jest-diff": "^29.6.1",
"jest-environment-jsdom": "^29.6.1",
"jest-matcher-utils": "^29.6.1",
"jest-mock": "^29.6.1",
"jest-runtime": "^29.6.1",
"jest-snapshot": "^29.6.1",
"jest-cli": "^29.7.0",
"jest-config": "^29.7.0",
"jest-diff": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"jest-matcher-utils": "^29.7.0",
"jest-mock": "^29.7.0",
"jest-runtime": "^29.7.0",
"jest-snapshot": "^29.7.0",
"jest-specific-snapshot": "^8.0.0",
"jest-styled-components": "7.0.3",
"jsdom": "^20.0.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import type {
} from '@kbn/core-chrome-browser';
import type { InternalHttpStart } from '@kbn/core-http-browser-internal';
import {
Subject,
BehaviorSubject,
combineLatest,
map,
Expand All @@ -32,6 +33,7 @@ import {
of,
type Observable,
type Subscription,
timer,
} from 'rxjs';
import { type Location, createLocation } from 'history';
import deepEqual from 'react-fast-compare';
Expand Down Expand Up @@ -326,20 +328,50 @@ export class ProjectNavigationService {
}

const { sideNavComponent, homePage = '' } = definition;
const homePageLink = this.navLinksService?.get(homePage);

if (sideNavComponent) {
this.setSideNavComponent(sideNavComponent);
}

if (homePageLink) {
this.setProjectHome(homePageLink.href);
}
this.waitForLink(homePage, (navLink: ChromeNavLink) => {
this.setProjectHome(navLink.href);
});

this.initNavigation(nextId, definition.navigationTree$);
});
}

/**
* This method waits for the chrome nav link to be available and then calls the callback.
* This is necessary to avoid race conditions when we register the solution navigation
* before the deep links are available (plugins can register them later).
*
* @param linkId The chrome nav link id
* @param cb The callback to call when the link is found
* @returns
*/
private waitForLink(linkId: string, cb: (chromeNavLink: ChromeNavLink) => undefined): void {
if (!this.navLinksService) return;

let navLink: ChromeNavLink | undefined = this.navLinksService.get(linkId);
if (navLink) {
cb(navLink);
return;
}

const stop$ = new Subject<void>();
const tenSeconds = timer(10000);

this.deepLinksMap$.pipe(takeUntil(tenSeconds), takeUntil(stop$)).subscribe((navLinks) => {
navLink = navLinks[linkId];

if (navLink) {
cb(navLink);
stop$.next();
}
});
}

private setProjectHome(homeHref: string) {
this.projectHome$.next(homeHref);
}
Expand Down
41 changes: 39 additions & 2 deletions packages/kbn-apm-synthtrace-client/src/lib/infra/host.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
/* eslint-disable max-classes-per-file */
import { Entity, Fields } from '../entity';
import { Serializable } from '../serializable';
import { k8sNode } from './k8s_node';
import { pod } from './pod';

interface HostDocument extends Fields {
Expand All @@ -20,17 +21,20 @@ interface HostDocument extends Fields {
'host.ip'?: string;
'host.os.name'?: string;
'host.os.version'?: string;
'host.os.platform'?: string;
'cloud.provider'?: string;
}

class Host extends Entity<HostDocument> {
cpu() {
cpu({ cpuTotalValue }: { cpuTotalValue?: number } = {}) {
return new HostMetrics({
...this.fields,
'system.cpu.total.norm.pct': 0.094,
'system.cpu.total.norm.pct': cpuTotalValue ?? 0.98,
'system.cpu.user.pct': 0.805,
'system.cpu.system.pct': 0.704,
'system.cpu.cores': 16,
'process.cpu.pct': 0.1,
'system.cpu.nice.pct': 0.1,
'metricset.period': 10000,
'metricset.name': 'cpu',
});
Expand All @@ -45,6 +49,7 @@ class Host extends Entity<HostDocument> {
'system.memory.total': 68719476736,
'system.memory.used.bytes': 39964708864,
'system.memory.used.pct': 0.582,
'process.memory.pct': 0.1,
'metricset.period': 10000,
'metricset.name': 'memory',
});
Expand Down Expand Up @@ -72,6 +77,22 @@ class Host extends Entity<HostDocument> {
});
}

core() {
return new HostMetrics({
...this.fields,
'system.core.total.pct': 0.98,
'system.core.user.pct': 0.805,
'system.core.nice.pct': 0.704,
'system.core.idle.pct': 0.1,
'system.core.iowait.pct': 0.1,
'system.core.irq.pct': 0.1,
'system.core.softirq.pct': 0.1,
'system.core.steal.pct': 0.1,
'metricset.period': 10000,
'metricset.name': 'core',
});
}

filesystem() {
return new HostMetrics({
...this.fields,
Expand All @@ -96,6 +117,10 @@ class Host extends Entity<HostDocument> {
pod(uid: string) {
return pod(uid, this.fields['host.hostname']);
}

node(podUid: string) {
return k8sNode(this.fields['host.hostname'], podUid);
}
}

export interface HostMetricsDocument extends HostDocument {
Expand All @@ -120,6 +145,17 @@ export interface HostMetricsDocument extends HostDocument {
'system.load'?: { 1: number; cores: number };
'host.network.ingress.bytes'?: number;
'host.network.egress.bytes'?: number;
'process.cpu.pct'?: number;
'process.memory.pct'?: number;
'system.core.total.pct'?: number;
'system.core.user.pct'?: number;
'system.core.nice.pct'?: number;
'system.core.idle.pct'?: number;
'system.core.iowait.pct'?: number;
'system.core.irq.pct'?: number;
'system.core.softirq.pct'?: number;
'system.core.steal.pct'?: number;
'system.cpu.nice.pct'?: number;
}

class HostMetrics extends Serializable<HostMetricsDocument> {}
Expand All @@ -132,6 +168,7 @@ export function host(name: string): Host {
'host.name': name,
'host.ip': '10.128.0.2',
'host.os.name': 'Linux',
'host.os.platform': 'ubuntu',
'host.os.version': '4.19.76-linuxkit',
'cloud.provider': 'gcp',
});
Expand Down
5 changes: 4 additions & 1 deletion packages/kbn-apm-synthtrace-client/src/lib/infra/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,21 @@ import { host, HostMetricsDocument } from './host';
import { k8sContainer, K8sContainerMetricsDocument } from './k8s_container';
import { pod, PodMetricsDocument } from './pod';
import { awsRds, AWSRdsMetricsDocument } from './aws/rds';
import { k8sNode, K8sNodeMetricsDocument } from './k8s_node';

export type InfraDocument =
| HostMetricsDocument
| PodMetricsDocument
| DockerContainerMetricsDocument
| K8sContainerMetricsDocument
| AWSRdsMetricsDocument;
| AWSRdsMetricsDocument
| K8sNodeMetricsDocument;

export const infra = {
host,
pod,
dockerContainer,
k8sContainer,
awsRds,
k8sNode,
};
Loading

0 comments on commit c6fe41a

Please sign in to comment.