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

[Infra] Replace MetricsUIAggregation in favor of estypes.AggregationsAggregate #190495

Merged
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
Expand Up @@ -6,7 +6,7 @@
*/

import * as rt from 'io-ts';
import { MetricsAPISeriesRT, MetricsAPIRow } from '../metrics_api';
import { MetricsAPISeriesRT, type MetricsAPIRow } from '@kbn/metrics-data-access-plugin/common';

const AggValueRT = rt.type({
value: rt.number,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

export * from './metadata_api';
export * from './metrics_explorer';
export * from './metrics_api';
export * from './snapshot_api';
export * from './host_details';
export * from './infra';
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { createLiteralValueFromUndefinedRT } from '@kbn/io-ts-utils';
import * as rt from 'io-ts';
import { SnapshotMetricTypeRT, ItemTypeRT } from '@kbn/metrics-data-access-plugin/common';
import { MetricsAPISeriesRT } from './metrics_api';
import { MetricsAPISeriesRT } from '@kbn/metrics-data-access-plugin/common';

export const SnapshotNodePathRT = rt.intersection([
rt.type({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import {
initGetLogAnalysisIdFormatsRoute,
} from './routes/log_analysis';
import { initMetadataRoute } from './routes/metadata';
import { initMetricsAPIRoute } from './routes/metrics_api';
import { initMetricsSourceConfigurationRoutes } from './routes/metrics_sources';
import { initNodeDetailsRoute } from './routes/node_details';
import { initOverviewRoute } from './routes/overview';
Expand Down Expand Up @@ -54,7 +53,6 @@ export const registerRoutes = (libs: InfraBackendLibs) => {
initValidateLogAnalysisIndicesRoute(libs);
initGetLogEntryExamplesRoute(libs);
initMetricsExplorerViewRoutes(libs);
initMetricsAPIRoute(libs);
initMetadataRoute(libs);
initInventoryMetaRoute(libs);
initInventoryViewRoutes(libs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,15 @@
import { has } from 'lodash';
import {
MetricsUIAggregation,
MetricsUIAggregationRT,
ESSumBucketAggRT,
ESTermsWithAggregationRT,
ESDerivativeAggRT,
ESBasicMetricAggRT,
ESTermsWithAggregationRT,
} from '@kbn/metrics-data-access-plugin/common';
import { SnapshotCustomMetricInput } from '../../../../../common/http_api';

export const isMetricRate = (metric: MetricsUIAggregation | undefined): boolean => {
if (!MetricsUIAggregationRT.is(metric)) {
if (!metric) {
return false;
}
const values = Object.values(metric);
Expand All @@ -32,7 +31,7 @@ export const isCustomMetricRate = (customMetric: SnapshotCustomMetricInput) => {
};

export const isInterfaceRateAgg = (metric: MetricsUIAggregation | undefined) => {
if (!MetricsUIAggregationRT.is(metric)) {
if (!metric) {
return false;
}
const values = Object.values(metric);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
*/

import { decodeOrThrow } from '@kbn/io-ts-utils';
import type { MetricsAPIResponse, MetricsAPIRequest } from '@kbn/metrics-data-access-plugin/common';
import { TIMESTAMP_FIELD } from '../../../common/constants';
import { MetricsAPIRequest, MetricsAPIResponse } from '../../../common/http_api';
import {
ESSearchClient,
CompositeResponseRT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import moment from 'moment';
import { MetricsAPITimerange } from '../../../../../common/http_api';
import type { MetricsAPITimerange } from '@kbn/metrics-data-access-plugin/common';
import { calculateAuto } from './calculate_auto';
import {
getUnitValue,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { MetricsAPITimerange } from '../../../../common/http_api';
import type { MetricsAPITimerange } from '@kbn/metrics-data-access-plugin/common';
import { calculateBucketSize } from './calculate_bucket_size';

export const calculateDateHistogramOffset = (timerange: MetricsAPITimerange): string => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
*/

import { isArray, isNumber } from 'lodash';
import { MetricsAPIRequest } from '../../../../common/http_api';
import { ESSearchClient } from '../types';
import type { MetricsAPIRequest } from '@kbn/metrics-data-access-plugin/common';
import { calculateMetricInterval } from '../../../utils/calculate_metric_interval';
import type { ESSearchClient } from '../types';

export const calculatedInterval = async (search: ESSearchClient, options: MetricsAPIRequest) => {
const useModuleInterval =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
* 2.0.
*/

import { MetricsAPIRequest } from '../../../../common/http_api';
import moment from 'moment';
import { convertBucketsToMetricsApiSeries } from './convert_buckets_to_metrics_series';
import type { MetricsAPIRequest } from '@kbn/metrics-data-access-plugin/common';

const keys = ['example-0'];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@

import { get, values, first } from 'lodash';
import * as rt from 'io-ts';
import {
import type {
MetricsAPIRequest,
MetricsAPISeries,
MetricsAPIColumn,
MetricsAPIRow,
} from '../../../../common/http_api/metrics_api';
} from '@kbn/metrics-data-access-plugin/common';
import {
Bucket,
BasicMetricValueRT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
* 2.0.
*/

import type { MetricsAPIRequest } from '@kbn/metrics-data-access-plugin/common';
import { createAggregations, createCompositeAggregations } from './create_aggregations';
import moment from 'moment';
import { MetricsAPIRequest } from '../../../../common/http_api';

const options: MetricsAPIRequest = {
timerange: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
import { AggregationOptionsByType } from '@kbn/es-types';

import Boom from '@hapi/boom';
import { type MetricsAPIRequest } from '@kbn/metrics-data-access-plugin/common';
import { afterKeyObjectRT } from '../../../../common/http_api';
import { TIMESTAMP_FIELD } from '../../../../common/constants';
import { MetricsAPIRequest } from '../../../../common/http_api/metrics_api';
import { calculateDateHistogramOffset } from './calculate_date_histogram_offset';
import { createMetricsAggregations } from './create_metrics_aggregations';
import { calculateBucketSize } from './calculate_bucket_size';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
* 2.0.
*/

import { MetricsAPIRequest } from '../../../../common/http_api';
import moment from 'moment';
import { createMetricsAggregations } from './create_metrics_aggregations';
import type { MetricsAPIRequest } from '@kbn/metrics-data-access-plugin/common';

const options: MetricsAPIRequest = {
timerange: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
* 2.0.
*/

import { MetricsUIAggregation } from '@kbn/metrics-data-access-plugin/common';
import { MetricsAPIRequest } from '../../../../common/http_api/metrics_api';
import type { MetricsUIAggregation } from '@kbn/metrics-data-access-plugin/common';
import type { MetricsAPIRequest } from '@kbn/metrics-data-access-plugin/common';

export const createMetricsAggregations = (options: MetricsAPIRequest): MetricsUIAggregation => {
const { metrics } = options;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@
*/

import { get, last, first, isArray } from 'lodash';
import { findInventoryFields } from '@kbn/metrics-data-access-plugin/common';
import {
SnapshotRequest,
SnapshotNodePath,
SnapshotNode,
MetricsAPISeries,
MetricsAPIRow,
} from '../../../../common/http_api';
type MetricsAPIRow,
type MetricsAPISeries,
findInventoryFields,
} from '@kbn/metrics-data-access-plugin/common';
import { SnapshotRequest, SnapshotNodePath, SnapshotNode } from '../../../../common/http_api';
import { META_KEY } from './constants';

export const isIPv4 = (subject: string) => /^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$/.test(subject);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
*/

import { uniq } from 'lodash';
import { MetricsUIAggregation, ESBasicMetricAggRT } from '@kbn/metrics-data-access-plugin/common';
import { MetricsAPITimerange } from '../../../../common/http_api';
import {
type MetricsUIAggregation,
ESBasicMetricAggRT,
type MetricsAPITimerange,
} from '@kbn/metrics-data-access-plugin/common';
import { ESSearchClient } from '../../../lib/metrics/types';
import { calculateMetricInterval } from '../../../utils/calculate_metric_interval';
import { getMetricsAggregations, InfraSnapshotRequestOptions } from './get_metrics_aggregations';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@

import { i18n } from '@kbn/i18n';
import { JsonObject } from '@kbn/utility-types';
import {
import type {
InventoryItemType,
MetricsUIAggregation,
MetricsUIAggregationRT,
} from '@kbn/metrics-data-access-plugin/common';
import { findInventoryModel } from '@kbn/metrics-data-access-plugin/common';
import { networkTraffic } from '@kbn/metrics-data-access-plugin/common';
Expand Down Expand Up @@ -54,7 +53,7 @@ export const getMetricsAggregations = (
const { metrics } = options;
return metrics.reduce((aggs, metric, index) => {
const aggregation = metricToAggregation(options.nodeType, metric, index);
if (!MetricsUIAggregationRT.is(aggregation)) {
if (!aggregation) {
throw new Error(
i18n.translate('xpack.infra.snapshot.missingSnapshotMetricError', {
defaultMessage: 'The aggregation for {metric} for {nodeType} is not available.',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { MetricsAPIRequest, MetricsAPIResponse } from '../../../../common/http_api';
import type { MetricsAPIResponse, MetricsAPIRequest } from '@kbn/metrics-data-access-plugin/common';
import { ESSearchClient } from '../../../lib/metrics/types';
import { query } from '../../../lib/metrics';

Expand Down
Loading