Skip to content

Commit

Permalink
[core.metrics] Add support for multiple processes in ops metrics & st…
Browse files Browse the repository at this point in the history
…ats API; deprecate process field (#109820) (#112108)

Co-authored-by: Kibana Machine <[email protected]>

Co-authored-by: Ahmad Bamieh <[email protected]>
  • Loading branch information
kibanamachine and Bamieh authored Sep 14, 2021
1 parent 3f17c9e commit 28b32b0
Show file tree
Hide file tree
Showing 60 changed files with 846 additions and 405 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ import { i18n } from '@kbn/i18n';

async function getDeprecations({ esClient, savedObjectsClient }: GetDeprecationsContext): Promise<DeprecationsDetails[]> {
const deprecations: DeprecationsDetails[] = [];

// Example of an api correctiveAction
const count = await getFooCount(savedObjectsClient);
if (count > 0) {
deprecations.push({
Expand All @@ -42,12 +40,12 @@ async function getDeprecations({ esClient, savedObjectsClient }: GetDeprecations
level: 'warning',
correctiveActions: {
manualSteps: [
i18n.translate('xpack.foo.deprecations.manualStepOneMessage', {
defaultMessage: 'Navigate to the Kibana Dashboard and click "Create dashboard".',
}),
i18n.translate('xpack.foo.deprecations.manualStepTwoMessage', {
defaultMessage: 'Select Foo from the "New Visualization" window.',
}),
i18n.translate('xpack.foo.deprecations.manualStepOneMessage', {
defaultMessage: 'Navigate to the Kibana Dashboard and click "Create dashboard".',
}),
i18n.translate('xpack.foo.deprecations.manualStepTwoMessage', {
defaultMessage: 'Select Foo from the "New Visualization" window.',
}),
],
api: {
path: '/internal/security/users/test_dashboard_user',
Expand All @@ -68,7 +66,6 @@ async function getDeprecations({ esClient, savedObjectsClient }: GetDeprecations
},
});
}

return deprecations;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [EventLoopDelaysMonitor](./kibana-plugin-core-server.eventloopdelaysmonitor.md) &gt; [(constructor)](./kibana-plugin-core-server.eventloopdelaysmonitor._constructor_.md)

## EventLoopDelaysMonitor.(constructor)

Creating a new instance from EventLoopDelaysMonitor will automatically start tracking event loop delays.

<b>Signature:</b>

```typescript
constructor();
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [EventLoopDelaysMonitor](./kibana-plugin-core-server.eventloopdelaysmonitor.md) &gt; [collect](./kibana-plugin-core-server.eventloopdelaysmonitor.collect.md)

## EventLoopDelaysMonitor.collect() method

Collect gathers event loop delays metrics from nodejs perf\_hooks.monitorEventLoopDelay the histogram calculations start from the last time `reset` was called or this EventLoopDelaysMonitor instance was created.

<b>Signature:</b>

```typescript
collect(): IntervalHistogram;
```
<b>Returns:</b>

`IntervalHistogram`

{<!-- -->IntervalHistogram<!-- -->}

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [EventLoopDelaysMonitor](./kibana-plugin-core-server.eventloopdelaysmonitor.md)

## EventLoopDelaysMonitor class

<b>Signature:</b>

```typescript
export declare class EventLoopDelaysMonitor
```

## Constructors

| Constructor | Modifiers | Description |
| --- | --- | --- |
| [(constructor)()](./kibana-plugin-core-server.eventloopdelaysmonitor._constructor_.md) | | Creating a new instance from EventLoopDelaysMonitor will automatically start tracking event loop delays. |

## Methods

| Method | Modifiers | Description |
| --- | --- | --- |
| [collect()](./kibana-plugin-core-server.eventloopdelaysmonitor.collect.md) | | Collect gathers event loop delays metrics from nodejs perf\_hooks.monitorEventLoopDelay the histogram calculations start from the last time <code>reset</code> was called or this EventLoopDelaysMonitor instance was created. |
| [reset()](./kibana-plugin-core-server.eventloopdelaysmonitor.reset.md) | | Resets the collected histogram data. |
| [stop()](./kibana-plugin-core-server.eventloopdelaysmonitor.stop.md) | | Disables updating the interval timer for collecting new data points. |

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [EventLoopDelaysMonitor](./kibana-plugin-core-server.eventloopdelaysmonitor.md) &gt; [reset](./kibana-plugin-core-server.eventloopdelaysmonitor.reset.md)

## EventLoopDelaysMonitor.reset() method

Resets the collected histogram data.

<b>Signature:</b>

```typescript
reset(): void;
```
<b>Returns:</b>

`void`

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [EventLoopDelaysMonitor](./kibana-plugin-core-server.eventloopdelaysmonitor.md) &gt; [stop](./kibana-plugin-core-server.eventloopdelaysmonitor.stop.md)

## EventLoopDelaysMonitor.stop() method

Disables updating the interval timer for collecting new data points.

<b>Signature:</b>

```typescript
stop(): void;
```
<b>Returns:</b>

`void`

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [IntervalHistogram](./kibana-plugin-core-server.intervalhistogram.md) &gt; [exceeds](./kibana-plugin-core-server.intervalhistogram.exceeds.md)

## IntervalHistogram.exceeds property

<b>Signature:</b>

```typescript
exceeds: number;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [IntervalHistogram](./kibana-plugin-core-server.intervalhistogram.md) &gt; [fromTimestamp](./kibana-plugin-core-server.intervalhistogram.fromtimestamp.md)

## IntervalHistogram.fromTimestamp property

<b>Signature:</b>

```typescript
fromTimestamp: string;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [IntervalHistogram](./kibana-plugin-core-server.intervalhistogram.md) &gt; [lastUpdatedAt](./kibana-plugin-core-server.intervalhistogram.lastupdatedat.md)

## IntervalHistogram.lastUpdatedAt property

<b>Signature:</b>

```typescript
lastUpdatedAt: string;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [IntervalHistogram](./kibana-plugin-core-server.intervalhistogram.md) &gt; [max](./kibana-plugin-core-server.intervalhistogram.max.md)

## IntervalHistogram.max property

<b>Signature:</b>

```typescript
max: number;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [IntervalHistogram](./kibana-plugin-core-server.intervalhistogram.md)

## IntervalHistogram interface

an IntervalHistogram object that samples and reports the event loop delay over time. The delays will be reported in nanoseconds.

<b>Signature:</b>

```typescript
export interface IntervalHistogram
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [exceeds](./kibana-plugin-core-server.intervalhistogram.exceeds.md) | <code>number</code> | |
| [fromTimestamp](./kibana-plugin-core-server.intervalhistogram.fromtimestamp.md) | <code>string</code> | |
| [lastUpdatedAt](./kibana-plugin-core-server.intervalhistogram.lastupdatedat.md) | <code>string</code> | |
| [max](./kibana-plugin-core-server.intervalhistogram.max.md) | <code>number</code> | |
| [mean](./kibana-plugin-core-server.intervalhistogram.mean.md) | <code>number</code> | |
| [min](./kibana-plugin-core-server.intervalhistogram.min.md) | <code>number</code> | |
| [percentiles](./kibana-plugin-core-server.intervalhistogram.percentiles.md) | <code>{</code><br/><code> 50: number;</code><br/><code> 75: number;</code><br/><code> 95: number;</code><br/><code> 99: number;</code><br/><code> }</code> | |
| [stddev](./kibana-plugin-core-server.intervalhistogram.stddev.md) | <code>number</code> | |

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [IntervalHistogram](./kibana-plugin-core-server.intervalhistogram.md) &gt; [mean](./kibana-plugin-core-server.intervalhistogram.mean.md)

## IntervalHistogram.mean property

<b>Signature:</b>

```typescript
mean: number;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [IntervalHistogram](./kibana-plugin-core-server.intervalhistogram.md) &gt; [min](./kibana-plugin-core-server.intervalhistogram.min.md)

## IntervalHistogram.min property

<b>Signature:</b>

```typescript
min: number;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [IntervalHistogram](./kibana-plugin-core-server.intervalhistogram.md) &gt; [percentiles](./kibana-plugin-core-server.intervalhistogram.percentiles.md)

## IntervalHistogram.percentiles property

<b>Signature:</b>

```typescript
percentiles: {
50: number;
75: number;
95: number;
99: number;
};
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [IntervalHistogram](./kibana-plugin-core-server.intervalhistogram.md) &gt; [stddev](./kibana-plugin-core-server.intervalhistogram.stddev.md)

## IntervalHistogram.stddev property

<b>Signature:</b>

```typescript
stddev: number;
```
2 changes: 2 additions & 0 deletions docs/development/core/server/kibana-plugin-core-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ The plugin integrates with the core system via lifecycle events: `setup`<!-- -->
| [BasePath](./kibana-plugin-core-server.basepath.md) | Access or manipulate the Kibana base path |
| [CspConfig](./kibana-plugin-core-server.cspconfig.md) | CSP configuration for use in Kibana. |
| [ElasticsearchConfig](./kibana-plugin-core-server.elasticsearchconfig.md) | Wrapper of config schema. |
| [EventLoopDelaysMonitor](./kibana-plugin-core-server.eventloopdelaysmonitor.md) | |
| [KibanaRequest](./kibana-plugin-core-server.kibanarequest.md) | Kibana specific abstraction for an incoming request. |
| [RouteValidationError](./kibana-plugin-core-server.routevalidationerror.md) | Error to return when the validation is not successful. |
| [SavedObjectsClient](./kibana-plugin-core-server.savedobjectsclient.md) | |
Expand Down Expand Up @@ -97,6 +98,7 @@ The plugin integrates with the core system via lifecycle events: `setup`<!-- -->
| [IExternalUrlPolicy](./kibana-plugin-core-server.iexternalurlpolicy.md) | A policy describing whether access to an external destination is allowed. |
| [IKibanaResponse](./kibana-plugin-core-server.ikibanaresponse.md) | A response data object, expected to returned as a result of [RequestHandler](./kibana-plugin-core-server.requesthandler.md) execution |
| [IKibanaSocket](./kibana-plugin-core-server.ikibanasocket.md) | A tiny abstraction for TCP socket. |
| [IntervalHistogram](./kibana-plugin-core-server.intervalhistogram.md) | an IntervalHistogram object that samples and reports the event loop delay over time. The delays will be reported in nanoseconds. |
| [IRenderOptions](./kibana-plugin-core-server.irenderoptions.md) | |
| [IRouter](./kibana-plugin-core-server.irouter.md) | Registers route handlers for specified resource path and method. See [RouteConfig](./kibana-plugin-core-server.routeconfig.md) and [RequestHandler](./kibana-plugin-core-server.requesthandler.md) for more information about arguments to route registrations. |
| [ISavedObjectsPointInTimeFinder](./kibana-plugin-core-server.isavedobjectspointintimefinder.md) | |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ export interface OpsMetrics
| [collected\_at](./kibana-plugin-core-server.opsmetrics.collected_at.md) | <code>Date</code> | Time metrics were recorded at. |
| [concurrent\_connections](./kibana-plugin-core-server.opsmetrics.concurrent_connections.md) | <code>OpsServerMetrics['concurrent_connections']</code> | number of current concurrent connections to the server |
| [os](./kibana-plugin-core-server.opsmetrics.os.md) | <code>OpsOsMetrics</code> | OS related metrics |
| [process](./kibana-plugin-core-server.opsmetrics.process.md) | <code>OpsProcessMetrics</code> | Process related metrics |
| [process](./kibana-plugin-core-server.opsmetrics.process.md) | <code>OpsProcessMetrics</code> | Process related metrics. Deprecated in favor of processes field. |
| [processes](./kibana-plugin-core-server.opsmetrics.processes.md) | <code>OpsProcessMetrics[]</code> | Process related metrics. Reports an array of objects for each kibana pid. |
| [requests](./kibana-plugin-core-server.opsmetrics.requests.md) | <code>OpsServerMetrics['requests']</code> | server requests stats |
| [response\_times](./kibana-plugin-core-server.opsmetrics.response_times.md) | <code>OpsServerMetrics['response_times']</code> | server response time stats |

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@

## OpsMetrics.process property

Process related metrics
> Warning: This API is now obsolete.
>
>
Process related metrics. Deprecated in favor of processes field.

<b>Signature:</b>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [OpsMetrics](./kibana-plugin-core-server.opsmetrics.md) &gt; [processes](./kibana-plugin-core-server.opsmetrics.processes.md)

## OpsMetrics.processes property

Process related metrics. Reports an array of objects for each kibana pid.

<b>Signature:</b>

```typescript
processes: OpsProcessMetrics[];
```
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## OpsProcessMetrics.event\_loop\_delay property

node event loop delay
mean event loop delay since last collection

<b>Signature:</b>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [OpsProcessMetrics](./kibana-plugin-core-server.opsprocessmetrics.md) &gt; [event\_loop\_delay\_histogram](./kibana-plugin-core-server.opsprocessmetrics.event_loop_delay_histogram.md)

## OpsProcessMetrics.event\_loop\_delay\_histogram property

node event loop delay histogram since last collection

<b>Signature:</b>

```typescript
event_loop_delay_histogram: IntervalHistogram;
```
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ export interface OpsProcessMetrics

| Property | Type | Description |
| --- | --- | --- |
| [event\_loop\_delay](./kibana-plugin-core-server.opsprocessmetrics.event_loop_delay.md) | <code>number</code> | node event loop delay |
| [event\_loop\_delay\_histogram](./kibana-plugin-core-server.opsprocessmetrics.event_loop_delay_histogram.md) | <code>IntervalHistogram</code> | node event loop delay histogram since last collection |
| [event\_loop\_delay](./kibana-plugin-core-server.opsprocessmetrics.event_loop_delay.md) | <code>number</code> | mean event loop delay since last collection |
| [memory](./kibana-plugin-core-server.opsprocessmetrics.memory.md) | <code>{</code><br/><code> heap: {</code><br/><code> total_in_bytes: number;</code><br/><code> used_in_bytes: number;</code><br/><code> size_limit: number;</code><br/><code> };</code><br/><code> resident_set_size_in_bytes: number;</code><br/><code> }</code> | process memory usage |
| [pid](./kibana-plugin-core-server.opsprocessmetrics.pid.md) | <code>number</code> | pid of the kibana process |
| [uptime\_in\_millis](./kibana-plugin-core-server.opsprocessmetrics.uptime_in_millis.md) | <code>number</code> | uptime of the kibana process |
Expand Down
20 changes: 19 additions & 1 deletion src/core/public/core_app/status/lib/load_status.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import { StatusResponse } from '../../../../types/status';
import { httpServiceMock } from '../../../http/http_service.mock';
import { notificationServiceMock } from '../../../notifications/notifications_service.mock';
import { mocked } from '../../../../server/metrics/event_loop_delays/event_loop_delays_monitor.mocks';
import { loadStatus } from './load_status';

const mockedResponse: StatusResponse = {
Expand Down Expand Up @@ -61,6 +62,7 @@ const mockedResponse: StatusResponse = {
},
},
process: {
pid: 1,
memory: {
heap: {
size_limit: 1000000,
Expand All @@ -70,9 +72,25 @@ const mockedResponse: StatusResponse = {
resident_set_size_in_bytes: 1,
},
event_loop_delay: 1,
pid: 1,
event_loop_delay_histogram: mocked.createHistogram(),
uptime_in_millis: 1,
},
processes: [
{
pid: 1,
memory: {
heap: {
size_limit: 1000000,
used_in_bytes: 100,
total_in_bytes: 0,
},
resident_set_size_in_bytes: 1,
},
event_loop_delay: 1,
event_loop_delay_histogram: mocked.createHistogram(),
uptime_in_millis: 1,
},
],
response_times: {
avg_in_millis: 4000,
max_in_millis: 8000,
Expand Down
1 change: 0 additions & 1 deletion src/core/server/deprecations/deprecations_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import { SavedObjectsClientContract } from '../saved_objects/types';
* const deprecations: DeprecationsDetails[] = [];
* const count = await getFooCount(savedObjectsClient);
* if (count > 0) {
* // Example of a manual correctiveAction
* deprecations.push({
* title: i18n.translate('xpack.foo.deprecations.title', {
* defaultMessage: `Foo's are deprecated`
Expand Down
Loading

0 comments on commit 28b32b0

Please sign in to comment.