Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Metrics UI] Consolidate Inventory and Metrics Explorer APIs #71575

Closed
wants to merge 6 commits into from
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
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';
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
9 changes: 5 additions & 4 deletions x-pack/plugins/infra/common/http_api/snapshot_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const SnapshotNodeMetricOptionalRT = rt.partial({
avg: rt.union([rt.number, rt.null]),
max: rt.union([rt.number, rt.null]),
timeseries: metricsExplorerSeriesRT,
count: rt.union([rt.number, rt.null]),
});

const SnapshotNodeMetricRequiredRT = rt.type({
Expand All @@ -48,6 +49,7 @@ export const InfraTimerangeInputRT = rt.intersection([
interval: rt.string,
to: rt.number,
from: rt.number,
field: rt.string,
}),
rt.partial({
lookbackSize: rt.number,
Expand Down Expand Up @@ -100,12 +102,11 @@ export const SnapshotRequestRT = rt.intersection([
metrics: rt.array(SnapshotMetricInputRT),
groupBy: SnapshotGroupByRT,
nodeType: ItemTypeRT,
sourceId: rt.string,
nodeField: rt.string,
indexPattern: rt.string,
}),
rt.partial({
accountId: rt.string,
region: rt.string,
filterQuery: rt.union([rt.string, rt.null]),
filters: rt.array(rt.object),
includeTimeseries: rt.boolean,
overrideCompositeSize: rt.number,
}),
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
* you may not use this file except in compliance with the Elastic License.
*/

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

export const load: SnapshotModel = { load: { avg: { field: 'system.load.5' } } };
export const load: MetricsUIAggregation = { load: { avg: { field: 'system.load.5' } } };
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 logRate: SnapshotModel = {
export const logRate: MetricsUIAggregation = {
count: {
bucket_script: {
buckets_path: { count: '_count' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +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 = {
export const memory: MetricsUIAggregation = {
memory: { avg: { field: 'system.memory.actual.used.pct' } },
};
4 changes: 2 additions & 2 deletions x-pack/plugins/infra/common/inventory_models/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ const getFieldByType = (type: InventoryItemType, fields: InventoryFields) => {
}
};

export const findInventoryFields = (type: InventoryItemType, fields: InventoryFields) => {
export const findInventoryFields = (type: InventoryItemType, fields?: InventoryFields) => {
const inventoryModel = findInventoryModel(type);
if (LEGACY_TYPES.includes(type)) {
if (fields && LEGACY_TYPES.includes(type)) {
const id = getFieldByType(type, fields) || inventoryModel.fields.id;
return {
...inventoryModel.fields,
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_with_limit: {
avg: {
field: 'kubernetes.pod.cpu.usage.limit.pct',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +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 = {
export const memory: MetricsUIAggregation = {
memory: { avg: { field: 'kubernetes.pod.memory.usage.node.pct' } },
};
Loading