Skip to content

Commit

Permalink
[Metrics UI] Remove TSVB dependency from Metrics Explorer APIs (#74804)
Browse files Browse the repository at this point in the history
* [Metrics UI] Remove TSVB dependency from Metrics Explorer APIs

* Update x-pack/plugins/infra/public/pages/metrics/metrics_explorer/components/chart_title.tsx

Co-authored-by: Zacqary Adam Xeper <[email protected]>

* Update x-pack/plugins/infra/server/lib/metrics/lib/calculate_bucket_size/calculate_auto.ts

Co-authored-by: Zacqary Adam Xeper <[email protected]>

* Update x-pack/plugins/infra/server/lib/metrics/lib/calculate_bucket_size/calculate_auto.ts

Co-authored-by: Zacqary Adam Xeper <[email protected]>

* Update x-pack/plugins/infra/server/lib/metrics/lib/convert_histogram_buckets_to_timeseries.ts

Co-authored-by: Zacqary Adam Xeper <[email protected]>

* Update x-pack/plugins/infra/server/lib/metrics/lib/convert_histogram_buckets_to_timeseries.ts

Co-authored-by: Zacqary Adam Xeper <[email protected]>

* Update x-pack/plugins/infra/server/routes/metrics_explorer/lib/find_interval_for_metrics.ts

Co-authored-by: Zacqary Adam Xeper <[email protected]>

* Fixing some names, changing some units

* Reverting TSVB calculate_auto; fixing names in infra

* Fixing translation names

* Fixing typo

Co-authored-by: Zacqary Adam Xeper <[email protected]>

Co-authored-by: Zacqary Adam Xeper <[email protected]>
  • Loading branch information
simianhacker and Zacqary authored Aug 14, 2020
1 parent 24c2e0a commit 1632391
Show file tree
Hide file tree
Showing 80 changed files with 2,190 additions and 534 deletions.
3 changes: 3 additions & 0 deletions x-pack/plugins/infra/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@
*/

export const DEFAULT_SOURCE_ID = 'default';
export const METRICS_INDEX_PATTERN = 'metrics-*,metricbeat-*';
export const LOGS_INDEX_PATTERN = 'logs-*,filebeat-*,kibana_sample_data_logs*';
export const TIMESTAMP_FIELD = '@timestamp';
1 change: 1 addition & 0 deletions x-pack/plugins/infra/common/http_api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ export * from './log_analysis';
export * from './metadata_api';
export * from './log_entries';
export * from './metrics_explorer';
export * from './metrics_api';
97 changes: 97 additions & 0 deletions x-pack/plugins/infra/common/http_api/metrics_api.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import * as rt from 'io-ts';
import { MetricsUIAggregationRT } from '../inventory_models/types';
import { afterKeyObjectRT } from './metrics_explorer';

export const MetricsAPITimerangeRT = rt.type({
field: rt.string,
from: rt.number,
to: rt.number,
interval: rt.string,
});

const groupByRT = rt.union([rt.string, rt.null, rt.undefined]);

export const MetricsAPIMetricRT = rt.type({
id: rt.string,
aggregations: MetricsUIAggregationRT,
});

export const MetricsAPIRequestRT = rt.intersection([
rt.type({
timerange: MetricsAPITimerangeRT,
indexPattern: rt.string,
metrics: rt.array(MetricsAPIMetricRT),
}),
rt.partial({
groupBy: rt.array(groupByRT),
afterKey: rt.union([rt.null, afterKeyObjectRT]),
limit: rt.union([rt.number, rt.null, rt.undefined]),
filters: rt.array(rt.object),
forceInterval: rt.boolean,
dropLastBucket: rt.boolean,
alignDataToEnd: rt.boolean,
}),
]);

export const MetricsAPIPageInfoRT = rt.type({
afterKey: rt.union([rt.null, afterKeyObjectRT, rt.undefined]),
interval: rt.number,
});

export const MetricsAPIColumnTypeRT = rt.keyof({
date: null,
number: null,
string: null,
});

export const MetricsAPIColumnRT = rt.type({
name: rt.string,
type: MetricsAPIColumnTypeRT,
});

export const MetricsAPIRowRT = rt.intersection([
rt.type({
timestamp: rt.number,
}),
rt.record(rt.string, rt.union([rt.string, rt.number, rt.null, rt.undefined])),
]);

export const MetricsAPISeriesRT = rt.intersection([
rt.type({
id: rt.string,
columns: rt.array(MetricsAPIColumnRT),
rows: rt.array(MetricsAPIRowRT),
}),
rt.partial({
keys: rt.array(rt.string),
}),
]);

export const MetricsAPIResponseRT = rt.type({
series: rt.array(MetricsAPISeriesRT),
info: MetricsAPIPageInfoRT,
});

export type MetricsAPITimerange = rt.TypeOf<typeof MetricsAPITimerangeRT>;

export type MetricsAPIColumnType = rt.TypeOf<typeof MetricsAPIColumnTypeRT>;

export type MetricsAPIMetric = rt.TypeOf<typeof MetricsAPIMetricRT>;

export type MetricsAPIPageInfo = rt.TypeOf<typeof MetricsAPIPageInfoRT>;

export type MetricsAPIColumn = rt.TypeOf<typeof MetricsAPIColumnRT>;

export type MetricsAPIRow = rt.TypeOf<typeof MetricsAPIRowRT>;

export type MetricsAPISeries = rt.TypeOf<typeof MetricsAPISeriesRT>;

export type MetricsAPIRequest = rt.TypeOf<typeof MetricsAPIRequestRT>;

export type MetricsAPIResponse = rt.TypeOf<typeof MetricsAPIResponseRT>;
2 changes: 2 additions & 0 deletions x-pack/plugins/infra/common/http_api/metrics_explorer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ export const metricsExplorerResponseRT = rt.type({
pageInfo: metricsExplorerPageInfoRT,
});

export type AfterKey = rt.TypeOf<typeof afterKeyObjectRT>;

export type MetricsExplorerAggregation = rt.TypeOf<typeof metricsExplorerAggregationRT>;

export type MetricsExplorerColumnType = rt.TypeOf<typeof metricsExplorerColumnTypeRT>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { SnapshotModel } from '../../../types';
import { MetricsUIAggregation } from '../../../types';

export const cpu: SnapshotModel = {
export const cpu: MetricsUIAggregation = {
cpu_avg: {
avg: {
field: 'aws.ec2.cpu.total.pct',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { SnapshotModel } from '../../../types';
import { MetricsUIAggregation } from '../../../types';

export const diskIOReadBytes: SnapshotModel = {
export const diskIOReadBytes: MetricsUIAggregation = {
diskIOReadBytes: {
avg: {
field: 'aws.ec2.diskio.read.bytes_per_sec',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { SnapshotModel } from '../../../types';
import { MetricsUIAggregation } from '../../../types';

export const diskIOWriteBytes: SnapshotModel = {
export const diskIOWriteBytes: MetricsUIAggregation = {
diskIOWriteBytes: {
avg: {
field: 'aws.ec2.diskio.write.bytes_per_sec',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { SnapshotModel } from '../../../types';
import { MetricsUIAggregation } from '../../../types';

export const rx: SnapshotModel = {
export const rx: MetricsUIAggregation = {
rx: {
avg: {
field: 'aws.ec2.network.in.bytes_per_sec',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { SnapshotModel } from '../../../types';
import { MetricsUIAggregation } from '../../../types';

export const tx: SnapshotModel = {
export const tx: MetricsUIAggregation = {
tx: {
avg: {
field: 'aws.ec2.network.in.bytes_per_sec',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { SnapshotModel } from '../../../types';
import { MetricsUIAggregation } from '../../../types';

export const cpu: SnapshotModel = {
export const cpu: MetricsUIAggregation = {
cpu_avg: {
avg: {
field: 'aws.rds.cpu.total.pct',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { SnapshotModel } from '../../../types';
import { MetricsUIAggregation } from '../../../types';

export const rdsActiveTransactions: SnapshotModel = {
export const rdsActiveTransactions: MetricsUIAggregation = {
rdsActiveTransactions: {
avg: {
field: 'aws.rds.transactions.active',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { SnapshotModel } from '../../../types';
import { MetricsUIAggregation } from '../../../types';

export const rdsConnections: SnapshotModel = {
export const rdsConnections: MetricsUIAggregation = {
rdsConnections: {
avg: {
field: 'aws.rds.database_connections',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { SnapshotModel } from '../../../types';
import { MetricsUIAggregation } from '../../../types';

export const rdsLatency: SnapshotModel = {
export const rdsLatency: MetricsUIAggregation = {
rdsLatency: {
avg: {
field: 'aws.rds.latency.dml',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { SnapshotModel } from '../../../types';
import { MetricsUIAggregation } from '../../../types';

export const rdsQueriesExecuted: SnapshotModel = {
export const rdsQueriesExecuted: MetricsUIAggregation = {
rdsQueriesExecuted: {
avg: {
field: 'aws.rds.queries',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { SnapshotModel } from '../../../types';
import { MetricsUIAggregation } from '../../../types';

export const s3BucketSize: SnapshotModel = {
export const s3BucketSize: MetricsUIAggregation = {
s3BucketSize: {
max: {
field: 'aws.s3_daily_storage.bucket.size.bytes',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { SnapshotModel } from '../../../types';
import { MetricsUIAggregation } from '../../../types';

export const s3DownloadBytes: SnapshotModel = {
export const s3DownloadBytes: MetricsUIAggregation = {
s3DownloadBytes: {
max: {
field: 'aws.s3_request.downloaded.bytes',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { SnapshotModel } from '../../../types';
import { MetricsUIAggregation } from '../../../types';

export const s3NumberOfObjects: SnapshotModel = {
export const s3NumberOfObjects: MetricsUIAggregation = {
s3NumberOfObjects: {
max: {
field: 'aws.s3_daily_storage.number_of_objects',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { SnapshotModel } from '../../../types';
import { MetricsUIAggregation } from '../../../types';

export const s3TotalRequests: SnapshotModel = {
export const s3TotalRequests: MetricsUIAggregation = {
s3TotalRequests: {
max: {
field: 'aws.s3_request.requests.total',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { SnapshotModel } from '../../../types';
import { MetricsUIAggregation } from '../../../types';

export const s3UploadBytes: SnapshotModel = {
export const s3UploadBytes: MetricsUIAggregation = {
s3UploadBytes: {
max: {
field: 'aws.s3_request.uploaded.bytes',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { SnapshotModel } from '../../../types';
import { MetricsUIAggregation } from '../../../types';

export const sqsMessagesDelayed: SnapshotModel = {
export const sqsMessagesDelayed: MetricsUIAggregation = {
sqsMessagesDelayed: {
max: {
field: 'aws.sqs.messages.delayed',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { SnapshotModel } from '../../../types';
import { MetricsUIAggregation } from '../../../types';

export const sqsMessagesEmpty: SnapshotModel = {
export const sqsMessagesEmpty: MetricsUIAggregation = {
sqsMessagesEmpty: {
max: {
field: 'aws.sqs.messages.not_visible',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { SnapshotModel } from '../../../types';
import { MetricsUIAggregation } from '../../../types';

export const sqsMessagesSent: SnapshotModel = {
export const sqsMessagesSent: MetricsUIAggregation = {
sqsMessagesSent: {
max: {
field: 'aws.sqs.messages.sent',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { SnapshotModel } from '../../../types';
import { MetricsUIAggregation } from '../../../types';

export const sqsMessagesVisible: SnapshotModel = {
export const sqsMessagesVisible: MetricsUIAggregation = {
sqsMessagesVisible: {
avg: {
field: 'aws.sqs.messages.visible',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { SnapshotModel } from '../../../types';
import { MetricsUIAggregation } from '../../../types';

export const sqsOldestMessage: SnapshotModel = {
export const sqsOldestMessage: MetricsUIAggregation = {
sqsOldestMessage: {
max: {
field: 'aws.sqs.oldest_message_age.sec',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { SnapshotModel } from '../../../types';
import { MetricsUIAggregation } from '../../../types';

export const cpu: SnapshotModel = {
export const cpu: MetricsUIAggregation = {
cpu: {
avg: {
field: 'docker.cpu.total.pct',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { SnapshotModel } from '../../../types';
import { MetricsUIAggregation } from '../../../types';

export const memory: SnapshotModel = { memory: { avg: { field: 'docker.memory.usage.pct' } } };
export const memory: MetricsUIAggregation = {
memory: { avg: { field: 'docker.memory.usage.pct' } },
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { SnapshotModel } from '../../../types';
import { MetricsUIAggregation } from '../../../types';

export const cpu: SnapshotModel = {
export const cpu: MetricsUIAggregation = {
cpu_user: {
avg: {
field: 'system.cpu.user.pct',
Expand Down
Loading

0 comments on commit 1632391

Please sign in to comment.