Skip to content

Commit

Permalink
Add core metrics service (#58623)
Browse files Browse the repository at this point in the history
* create base service and collectors

* wire the service into server, add mock

* add collector tests

* add main collector test

* export metric types from server

* add service and server tests

* updates generated doc

* improve doc

* nits and comments

* add disconnected requests test
  • Loading branch information
pgayvallet authored Mar 3, 2020
1 parent 166716a commit 64ffae3
Show file tree
Hide file tree
Showing 53 changed files with 1,790 additions and 1 deletion.
5 changes: 5 additions & 0 deletions docs/development/core/server/kibana-plugin-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,16 @@ The plugin integrates with the core system via lifecycle events: `setup`<!-- -->
| [Logger](./kibana-plugin-server.logger.md) | Logger exposes all the necessary methods to log any type of information and this is the interface used by the logging consumers including plugins. |
| [LoggerFactory](./kibana-plugin-server.loggerfactory.md) | The single purpose of <code>LoggerFactory</code> interface is to define a way to retrieve a context-based logger instance. |
| [LogMeta](./kibana-plugin-server.logmeta.md) | Contextual metadata |
| [MetricsServiceSetup](./kibana-plugin-server.metricsservicesetup.md) | APIs to retrieves metrics gathered and exposed by the core platform. |
| [OnPostAuthToolkit](./kibana-plugin-server.onpostauthtoolkit.md) | A tool set defining an outcome of OnPostAuth interceptor for incoming request. |
| [OnPreAuthToolkit](./kibana-plugin-server.onpreauthtoolkit.md) | A tool set defining an outcome of OnPreAuth interceptor for incoming request. |
| [OnPreResponseExtensions](./kibana-plugin-server.onpreresponseextensions.md) | Additional data to extend a response. |
| [OnPreResponseInfo](./kibana-plugin-server.onpreresponseinfo.md) | Response status code. |
| [OnPreResponseToolkit](./kibana-plugin-server.onpreresponsetoolkit.md) | A tool set defining an outcome of OnPreAuth interceptor for incoming request. |
| [OpsMetrics](./kibana-plugin-server.opsmetrics.md) | Regroups metrics gathered by all the collectors. This contains metrics about the os/runtime, the kibana process and the http server. |
| [OpsOsMetrics](./kibana-plugin-server.opsosmetrics.md) | OS related metrics |
| [OpsProcessMetrics](./kibana-plugin-server.opsprocessmetrics.md) | Process related metrics |
| [OpsServerMetrics](./kibana-plugin-server.opsservermetrics.md) | server related metrics |
| [PackageInfo](./kibana-plugin-server.packageinfo.md) | |
| [Plugin](./kibana-plugin-server.plugin.md) | The interface that should be returned by a <code>PluginInitializer</code>. |
| [PluginConfigDescriptor](./kibana-plugin-server.pluginconfigdescriptor.md) | Describes a plugin configuration properties. |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [MetricsServiceSetup](./kibana-plugin-server.metricsservicesetup.md) &gt; [getOpsMetrics$](./kibana-plugin-server.metricsservicesetup.getopsmetrics_.md)

## MetricsServiceSetup.getOpsMetrics$ property

Retrieve an observable emitting the [OpsMetrics](./kibana-plugin-server.opsmetrics.md) gathered. The observable will emit an initial value during core's `start` phase, and a new value every fixed interval of time, based on the `opts.interval` configuration property.

<b>Signature:</b>

```typescript
getOpsMetrics$: () => Observable<OpsMetrics>;
```

## Example


```ts
core.metrics.getOpsMetrics$().subscribe(metrics => {
// do something with the metrics
})

```

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

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [MetricsServiceSetup](./kibana-plugin-server.metricsservicesetup.md)

## MetricsServiceSetup interface

APIs to retrieves metrics gathered and exposed by the core platform.

<b>Signature:</b>

```typescript
export interface MetricsServiceSetup
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [getOpsMetrics$](./kibana-plugin-server.metricsservicesetup.getopsmetrics_.md) | <code>() =&gt; Observable&lt;OpsMetrics&gt;</code> | Retrieve an observable emitting the [OpsMetrics](./kibana-plugin-server.opsmetrics.md) gathered. The observable will emit an initial value during core's <code>start</code> phase, and a new value every fixed interval of time, based on the <code>opts.interval</code> configuration property. |

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-server](./kibana-plugin-server.md) &gt; [OpsMetrics](./kibana-plugin-server.opsmetrics.md) &gt; [concurrent\_connections](./kibana-plugin-server.opsmetrics.concurrent_connections.md)

## OpsMetrics.concurrent\_connections property

number of current concurrent connections to the server

<b>Signature:</b>

```typescript
concurrent_connections: OpsServerMetrics['concurrent_connections'];
```
24 changes: 24 additions & 0 deletions docs/development/core/server/kibana-plugin-server.opsmetrics.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

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

## OpsMetrics interface

Regroups metrics gathered by all the collectors. This contains metrics about the os/runtime, the kibana process and the http server.

<b>Signature:</b>

```typescript
export interface OpsMetrics
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [concurrent\_connections](./kibana-plugin-server.opsmetrics.concurrent_connections.md) | <code>OpsServerMetrics['concurrent_connections']</code> | number of current concurrent connections to the server |
| [os](./kibana-plugin-server.opsmetrics.os.md) | <code>OpsOsMetrics</code> | OS related metrics |
| [process](./kibana-plugin-server.opsmetrics.process.md) | <code>OpsProcessMetrics</code> | Process related metrics |
| [requests](./kibana-plugin-server.opsmetrics.requests.md) | <code>OpsServerMetrics['requests']</code> | server requests stats |
| [response\_times](./kibana-plugin-server.opsmetrics.response_times.md) | <code>OpsServerMetrics['response_times']</code> | server response time stats |

13 changes: 13 additions & 0 deletions docs/development/core/server/kibana-plugin-server.opsmetrics.os.md
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-server](./kibana-plugin-server.md) &gt; [OpsMetrics](./kibana-plugin-server.opsmetrics.md) &gt; [os](./kibana-plugin-server.opsmetrics.os.md)

## OpsMetrics.os property

OS related metrics

<b>Signature:</b>

```typescript
os: OpsOsMetrics;
```
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-server](./kibana-plugin-server.md) &gt; [OpsMetrics](./kibana-plugin-server.opsmetrics.md) &gt; [process](./kibana-plugin-server.opsmetrics.process.md)

## OpsMetrics.process property

Process related metrics

<b>Signature:</b>

```typescript
process: OpsProcessMetrics;
```
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-server](./kibana-plugin-server.md) &gt; [OpsMetrics](./kibana-plugin-server.opsmetrics.md) &gt; [requests](./kibana-plugin-server.opsmetrics.requests.md)

## OpsMetrics.requests property

server requests stats

<b>Signature:</b>

```typescript
requests: OpsServerMetrics['requests'];
```
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-server](./kibana-plugin-server.md) &gt; [OpsMetrics](./kibana-plugin-server.opsmetrics.md) &gt; [response\_times](./kibana-plugin-server.opsmetrics.response_times.md)

## OpsMetrics.response\_times property

server response time stats

<b>Signature:</b>

```typescript
response_times: OpsServerMetrics['response_times'];
```
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-server](./kibana-plugin-server.md) &gt; [OpsOsMetrics](./kibana-plugin-server.opsosmetrics.md) &gt; [distro](./kibana-plugin-server.opsosmetrics.distro.md)

## OpsOsMetrics.distro property

The os distrib. Only present for linux platforms

<b>Signature:</b>

```typescript
distro?: string;
```
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-server](./kibana-plugin-server.md) &gt; [OpsOsMetrics](./kibana-plugin-server.opsosmetrics.md) &gt; [distroRelease](./kibana-plugin-server.opsosmetrics.distrorelease.md)

## OpsOsMetrics.distroRelease property

The os distrib release, prefixed by the os distrib. Only present for linux platforms

<b>Signature:</b>

```typescript
distroRelease?: string;
```
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-server](./kibana-plugin-server.md) &gt; [OpsOsMetrics](./kibana-plugin-server.opsosmetrics.md) &gt; [load](./kibana-plugin-server.opsosmetrics.load.md)

## OpsOsMetrics.load property

cpu load metrics

<b>Signature:</b>

```typescript
load: {
'1m': number;
'5m': number;
'15m': number;
};
```
26 changes: 26 additions & 0 deletions docs/development/core/server/kibana-plugin-server.opsosmetrics.md
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-server](./kibana-plugin-server.md) &gt; [OpsOsMetrics](./kibana-plugin-server.opsosmetrics.md)

## OpsOsMetrics interface

OS related metrics

<b>Signature:</b>

```typescript
export interface OpsOsMetrics
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [distro](./kibana-plugin-server.opsosmetrics.distro.md) | <code>string</code> | The os distrib. Only present for linux platforms |
| [distroRelease](./kibana-plugin-server.opsosmetrics.distrorelease.md) | <code>string</code> | The os distrib release, prefixed by the os distrib. Only present for linux platforms |
| [load](./kibana-plugin-server.opsosmetrics.load.md) | <code>{</code><br/><code> '1m': number;</code><br/><code> '5m': number;</code><br/><code> '15m': number;</code><br/><code> }</code> | cpu load metrics |
| [memory](./kibana-plugin-server.opsosmetrics.memory.md) | <code>{</code><br/><code> total_in_bytes: number;</code><br/><code> free_in_bytes: number;</code><br/><code> used_in_bytes: number;</code><br/><code> }</code> | system memory usage metrics |
| [platform](./kibana-plugin-server.opsosmetrics.platform.md) | <code>NodeJS.Platform</code> | The os platform |
| [platformRelease](./kibana-plugin-server.opsosmetrics.platformrelease.md) | <code>string</code> | The os platform release, prefixed by the platform name |
| [uptime\_in\_millis](./kibana-plugin-server.opsosmetrics.uptime_in_millis.md) | <code>number</code> | the OS uptime |

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-server](./kibana-plugin-server.md) &gt; [OpsOsMetrics](./kibana-plugin-server.opsosmetrics.md) &gt; [memory](./kibana-plugin-server.opsosmetrics.memory.md)

## OpsOsMetrics.memory property

system memory usage metrics

<b>Signature:</b>

```typescript
memory: {
total_in_bytes: number;
free_in_bytes: number;
used_in_bytes: number;
};
```
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-server](./kibana-plugin-server.md) &gt; [OpsOsMetrics](./kibana-plugin-server.opsosmetrics.md) &gt; [platform](./kibana-plugin-server.opsosmetrics.platform.md)

## OpsOsMetrics.platform property

The os platform

<b>Signature:</b>

```typescript
platform: NodeJS.Platform;
```
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-server](./kibana-plugin-server.md) &gt; [OpsOsMetrics](./kibana-plugin-server.opsosmetrics.md) &gt; [platformRelease](./kibana-plugin-server.opsosmetrics.platformrelease.md)

## OpsOsMetrics.platformRelease property

The os platform release, prefixed by the platform name

<b>Signature:</b>

```typescript
platformRelease: string;
```
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-server](./kibana-plugin-server.md) &gt; [OpsOsMetrics](./kibana-plugin-server.opsosmetrics.md) &gt; [uptime\_in\_millis](./kibana-plugin-server.opsosmetrics.uptime_in_millis.md)

## OpsOsMetrics.uptime\_in\_millis property

the OS uptime

<b>Signature:</b>

```typescript
uptime_in_millis: number;
```
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-server](./kibana-plugin-server.md) &gt; [OpsProcessMetrics](./kibana-plugin-server.opsprocessmetrics.md) &gt; [event\_loop\_delay](./kibana-plugin-server.opsprocessmetrics.event_loop_delay.md)

## OpsProcessMetrics.event\_loop\_delay property

node event loop delay

<b>Signature:</b>

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

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [OpsProcessMetrics](./kibana-plugin-server.opsprocessmetrics.md)

## OpsProcessMetrics interface

Process related metrics

<b>Signature:</b>

```typescript
export interface OpsProcessMetrics
```

## Properties

| Property | Type | Description |
| --- | --- | --- |
| [event\_loop\_delay](./kibana-plugin-server.opsprocessmetrics.event_loop_delay.md) | <code>number</code> | node event loop delay |
| [memory](./kibana-plugin-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-server.opsprocessmetrics.pid.md) | <code>number</code> | pid of the kibana process |
| [uptime\_in\_millis](./kibana-plugin-server.opsprocessmetrics.uptime_in_millis.md) | <code>number</code> | uptime of the kibana process |

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

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [OpsProcessMetrics](./kibana-plugin-server.opsprocessmetrics.md) &gt; [memory](./kibana-plugin-server.opsprocessmetrics.memory.md)

## OpsProcessMetrics.memory property

process memory usage

<b>Signature:</b>

```typescript
memory: {
heap: {
total_in_bytes: number;
used_in_bytes: number;
size_limit: number;
};
resident_set_size_in_bytes: number;
};
```
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-server](./kibana-plugin-server.md) &gt; [OpsProcessMetrics](./kibana-plugin-server.opsprocessmetrics.md) &gt; [pid](./kibana-plugin-server.opsprocessmetrics.pid.md)

## OpsProcessMetrics.pid property

pid of the kibana process

<b>Signature:</b>

```typescript
pid: number;
```
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-server](./kibana-plugin-server.md) &gt; [OpsProcessMetrics](./kibana-plugin-server.opsprocessmetrics.md) &gt; [uptime\_in\_millis](./kibana-plugin-server.opsprocessmetrics.uptime_in_millis.md)

## OpsProcessMetrics.uptime\_in\_millis property

uptime of the kibana process

<b>Signature:</b>

```typescript
uptime_in_millis: number;
```
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-server](./kibana-plugin-server.md) &gt; [OpsServerMetrics](./kibana-plugin-server.opsservermetrics.md) &gt; [concurrent\_connections](./kibana-plugin-server.opsservermetrics.concurrent_connections.md)

## OpsServerMetrics.concurrent\_connections property

number of current concurrent connections to the server

<b>Signature:</b>

```typescript
concurrent_connections: number;
```
Loading

0 comments on commit 64ffae3

Please sign in to comment.