Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

export interface CustomBranding {
/**
* Custom replacement for the Elastic logo in the top lef *
* */
logo?: string;
/**
* Custom replacement for favicon in SVG format
*/
faviconSVG?: string;
/**
* Custom page title
*/
pageTitle?: string;
/**
* Custom replacement for Elastic Mark
* @link packages/core/chrome/core-chrome-browser-internal/src/ui/header/elastic_mark.tsx
*/
customizedLogo?: string;
/**
* Custom replacement for favicon in PNG format
*/
faviconPNG?: string;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
Object.defineProperty(exports, '__esModule', { value: true });
11 changes: 11 additions & 0 deletions src/plugins/usage_collection/common/types/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

export * as v1Stats from './stats';
export * as v1UiCounters from './ui_counters';
export * as v1UsageCounters from './usage_counters';
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
/*
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Overall this makes sense, it is giving us the full types of the endpoint and we will be able to detect when our response changes👌🏻

Nit: I would name this file "core_metrics" then add a doc comment explaining this starts as a duplicate of the core ops metrics.

* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

/**
* an IntervalHistogram object that samples and reports the event loop delay over time.
* The delays will be reported in milliseconds.
*
* @public
*/
export interface IntervalHistogram {
// The first timestamp the interval timer kicked in for collecting data points.
fromTimestamp: string;
// Last timestamp the interval timer kicked in for collecting data points.
lastUpdatedAt: string;
// The minimum recorded event loop delay.
min: number;
// The maximum recorded event loop delay.
max: number;
// The mean of the recorded event loop delays.
mean: number;
// The number of times the event loop delay exceeded the maximum 1 hour event loop delay threshold.
exceeds: number;
// The standard deviation of the recorded event loop delays.
stddev: number;
// An object detailing the accumulated percentile distribution.
percentiles: {
// 50th percentile of delays of the collected data points.
50: number;
// 75th percentile of delays of the collected data points.
75: number;
// 95th percentile of delays of the collected data points.
95: number;
// 99th percentile of delays of the collected data points.
99: number;
};
}

/**
* Protocol(s) used by the Elasticsearch Client
* @public
*/

export type ElasticsearchClientProtocol = 'none' | 'http' | 'https' | 'mixed';

/**
* Metrics related to the elasticsearch clients
* @public
*/
export interface ElasticsearchClientsMetrics {
/** Total number of active sockets (all nodes, all connections) */
totalActiveSockets: number;
/** Total number of available sockets (alive but idle, all nodes, all connections) */
totalIdleSockets: number;
/** Total number of queued requests (all nodes, all connections) */
totalQueuedRequests: number;
}

/**
* Process related metrics
* @public
*/
export interface OpsProcessMetrics {
/** pid of the kibana process */
pid: number;
/** process memory usage */
memory: {
/** heap memory usage */
heap: {
/** total heap available */
total_in_bytes: number;
/** used heap */
used_in_bytes: number;
/** v8 heap size limit */
size_limit: number;
};
/** node rss */
resident_set_size_in_bytes: number;
};
/** mean event loop delay since last collection*/
event_loop_delay: number;
/** node event loop delay histogram since last collection */
event_loop_delay_histogram: IntervalHistogram;
/** uptime of the kibana process */
uptime_in_millis: number;
}

/**
* OS related metrics
* @public
*/
export interface OpsOsMetrics {
/** The os platform */
platform: NodeJS.Platform;
/** The os platform release, prefixed by the platform name */
platformRelease: string;
/** The os distrib. Only present for linux platforms */
distro?: string;
/** The os distrib release, prefixed by the os distrib. Only present for linux platforms */
distroRelease?: string;
/** cpu load metrics */
load: {
/** load for last minute */
'1m': number;
/** load for last 5 minutes */
'5m': number;
/** load for last 15 minutes */
'15m': number;
};
/** system memory usage metrics */
memory: {
/** total memory available */
total_in_bytes: number;
/** current free memory */
free_in_bytes: number;
/** current used memory */
used_in_bytes: number;
};
/** the OS uptime */
uptime_in_millis: number;

/** cpu accounting metrics, undefined when not running in a cgroup */
cpuacct?: {
/** name of this process's cgroup */
control_group: string;
/** cpu time used by this process's cgroup */
usage_nanos: number;
};

/** cpu cgroup metrics, undefined when not running in a cgroup */
cpu?: {
/** name of this process's cgroup */
control_group: string;
/** the length of the cfs period */
cfs_period_micros: number;
/** total available run-time within a cfs period */
cfs_quota_micros: number;
/** current stats on the cfs periods */
stat: {
/** number of cfs periods that elapsed */
number_of_elapsed_periods: number;
/** number of times the cgroup has been throttled */
number_of_times_throttled: number;
/** total amount of time the cgroup has been throttled for */
time_throttled_nanos: number;
};
};
}

/**
* server related metrics
* @public
*/
export interface OpsServerMetrics {
/** server response time stats */
response_times: {
/** average response time */
avg_in_millis: number;
/** maximum response time */
max_in_millis: number;
};
/** server requests stats */
requests: {
/** number of disconnected requests since startup */
disconnects: number;
/** total number of requests handled since startup */
total: number;
/** number of request handled per response status code */
statusCodes: Record<number, number>;
};
/** number of current concurrent connections to the server */
concurrent_connections: number;
}

/**
* Regroups metrics gathered by all the collectors.
* This contains metrics about the os/runtime, the kibana process and the http server.
*
* @public
*/
export interface OpsMetrics {
/** Time metrics were recorded at. */
collected_at: Date;
/**
* Metrics related to the elasticsearch client
*/
elasticsearch_client: ElasticsearchClientsMetrics;
/**
* Process related metrics.
* @remarks processes field preferred
*/
process: OpsProcessMetrics;
/** Process related metrics. Reports an array of objects for each kibana pid.*/
processes: OpsProcessMetrics[];
/** OS related metrics */
os: OpsOsMetrics;
/** server response time stats */
response_times: OpsServerMetrics['response_times'];
/** server requests stats */
requests: OpsServerMetrics['requests'];
/** number of current concurrent connections to the server */
concurrent_connections: OpsServerMetrics['concurrent_connections'];
}
10 changes: 10 additions & 0 deletions src/plugins/usage_collection/common/types/stats/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

export * as v1 from './v1';
export * from './latest';
9 changes: 9 additions & 0 deletions src/plugins/usage_collection/common/types/stats/latest.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
export * as OpsMetricsCopy from './core_metrics_duplicated';
export * from './v1';
77 changes: 77 additions & 0 deletions src/plugins/usage_collection/common/types/stats/v1.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import * as OpsMetricsCopy from './core_metrics_duplicated';
/** v1 types Start */

/**
* stats query v1
* @remarks exclude_usage is always interpreted as true. query param retained to prevent breaking changes to existing consumers.
*/
export interface StatsHTTPQuery {
extended?: boolean | '';
legacy?: boolean | '';
exclude_usage?: boolean | '';
}

export interface UsageObject {
kibana?: UsageObject;
xpack?: UsageObject;
[key: string]: unknown | UsageObject;
}
/**
* Extended usage stats.
* Legacy implementation used to conditionally include kibana usage metrics
* as of https://github.com/elastic/kibana/pull/151082, usage is no longer reported
* and set to an empty object to prevent breaking changes to existing consumers.
*/
export interface ExtendedStats {
[key: string]: unknown;
clusterUuid?: string; // camel case if legacy === true
cluster_uuid?: string; // snake_case if legacy === false
}
/**
* OpsMetrics: aliased from a duplicate of core's OpsMetrics types
* @remarks the alternative to creating a local copy of the OpsMetrics types is to declare them as `unknown` and assume validation happens elsewhere.
* The disadvantage is that any changes made to the original OpsMetrics will be passed through without needing to update the API types.
*/
export type LastOpsMetrics = OpsMetricsCopy.OpsMetrics;

/** explicitly typed stats for kibana */
export interface KibanaStats {
// kibana
kibana: {
uuid: string;
name: string;
index: string;
host: string;
locale: string;
transport_address: string;
version: string;
snapshot: boolean;
status: string;
};
}
/** Stats response body */
export type StatsHTTPBodyTyped = LastOpsMetrics | KibanaStats | ExtendedStats;

/**
* unused, for demonstration purposes only.
* alternative generic type for api response body
*/
export interface LastOpsMetricsUnknown {
[key: string]: unknown;
}

/**
* unused, for demonstration purposes only.
* alternative generic type for api response body
*/
export interface StatsHTTPBodyUnknown {
[key: string]: unknown;
}
10 changes: 10 additions & 0 deletions src/plugins/usage_collection/common/types/ui_counters/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

export * as v1 from './v1';
export * from './latest';
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

export * as v1 from './v1';
Loading