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

[Logs UI] Versioning for Logs related APIs #158710

Merged
merged 28 commits into from
Jun 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
17ca696
feat(logs-ui): version log views apis
May 31, 2023
0d5abcd
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine May 31, 2023
576e92b
fix(logs-ui): type
May 31, 2023
f41db76
Merge branch '157324-version-logs-http-routes' of github.com:tonyghia…
May 31, 2023
1a635bc
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine May 31, 2023
2ddb131
feat(logs-ui): version log entries apis
May 31, 2023
067de21
Merge branch '157324-version-logs-http-routes' of github.com:tonyghia…
May 31, 2023
e970186
feat(logs-ui): version log alerts apis
May 31, 2023
cb39582
fix(logs-ui): type import
May 31, 2023
0461a96
feat(logs-ui): version log analysis apis
Jun 1, 2023
4fe027c
fix(logs-ui): broken type
Jun 1, 2023
4460817
Merge branch 'main' into 157324-version-logs-http-routes
tonyghiani Jun 1, 2023
104f1f1
feat(logs-ui): explicitly set api version
Jun 1, 2023
c34e3ac
Merge branch 'main' into 157324-version-logs-http-routes
tonyghiani Jun 8, 2023
1ff02d1
Merge branch 'main' into 157324-version-logs-http-routes
tonyghiani Jun 8, 2023
240dfbe
Merge branch 'main' into 157324-version-logs-http-routes
tonyghiani Jun 8, 2023
44208f3
fix(logs-shared): versioning mandatory
Jun 8, 2023
c3bdcf9
Merge branch '157324-version-logs-http-routes' of github.com:tonyghia…
Jun 8, 2023
09c50cc
Merge branch 'main' into 157324-version-logs-http-routes
tonyghiani Jun 8, 2023
a9335f0
fix(logs-shared): add missing api version
Jun 8, 2023
c3c1a9e
fix(logs-shared): add missing version
Jun 8, 2023
4556618
fix(logs-shared): add missing version
Jun 8, 2023
bfbae30
fix(infra): broken test
Jun 8, 2023
615d6ba
Merge branch 'main' into 157324-version-logs-http-routes
tonyghiani Jun 8, 2023
94eb7b6
Merge branch '157324-version-logs-http-routes' of github.com:tonyghia…
Jun 8, 2023
e94e257
fix(infra): remove only test
Jun 8, 2023
78b771b
fix(test): re-enable tests
Jun 8, 2023
61507c8
fix(test): broken infra test
Jun 8, 2023
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
8 changes: 5 additions & 3 deletions x-pack/plugins/infra/common/http_api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,9 @@
* 2.0.
*/

export * from './log_analysis';
export * from './metadata_api';
export * from './log_entries';
export * from './metrics_explorer';
export * from './metrics_api';
export * from './log_alerts';
export * from './snapshot_api';
export * from './host_details';
export * from './infra';
Expand All @@ -20,4 +17,9 @@ export * from './infra';
*/
export * from './latest';
export * as inventoryViewsV1 from './inventory_views/v1';
export * as logAlertsV1 from './log_alerts/v1';
export * as logAnalysisResultsV1 from './log_analysis/results/v1';
export * as logAnalysisValidationV1 from './log_analysis/validation/v1';
export * as logEntriesV1 from './log_entries/v1';
export * as logViewsV1 from './log_views/v1';
export * as metricsExplorerViewsV1 from './metrics_explorer_views/v1';
5 changes: 5 additions & 0 deletions x-pack/plugins/infra/common/http_api/latest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,9 @@
*/

export * from './inventory_views/v1';
export * from './log_alerts/v1';
export * from './log_analysis/results/v1';
export * from './log_analysis/validation/v1';
export * from './log_entries/v1';
export * from './log_views/v1';
export * from './metrics_explorer_views/v1';
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import {
timeUnitRT,
timeSizeRT,
groupByRT,
} from '../../alerting/logs/log_threshold/types';
import { persistedLogViewReferenceRT } from '../../log_views';
} from '../../../alerting/logs/log_threshold/types';
import { persistedLogViewReferenceRT } from '../../../log_views';

export const LOG_ALERTS_CHART_PREVIEW_DATA_PATH = '/api/infra/log_alerts/chart_preview_data';

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

import * as rt from 'io-ts';

import { persistedLogViewReferenceRT } from '../../../log_views';
import { timeRangeRT, routeTimingMetadataRT } from '../../shared';
import { persistedLogViewReferenceRT } from '../../../../log_views';
import { timeRangeRT, routeTimingMetadataRT } from '../../../shared';
import {
logEntryAnomalyRT,
logEntryAnomalyDatasetsRT,
anomaliesSortRT,
paginationRT,
paginationCursorRT,
} from '../../../log_analysis';
} from '../../../../log_analysis';

export const LOG_ANALYSIS_GET_LOG_ENTRY_ANOMALIES_PATH =
'/api/infra/log_analysis/results/log_entry_anomalies';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
*/

import * as rt from 'io-ts';
import { persistedLogViewReferenceRT } from '../../../log_views';
import { persistedLogViewReferenceRT } from '../../../../log_views';

import {
badRequestErrorRT,
forbiddenErrorRT,
timeRangeRT,
routeTimingMetadataRT,
} from '../../shared';
} from '../../../shared';

export const LOG_ANALYSIS_GET_LOG_ENTRY_ANOMALIES_DATASETS_PATH =
'/api/infra/log_analysis/results/log_entry_anomalies_datasets';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@

import * as rt from 'io-ts';

import { persistedLogViewReferenceRT } from '../../../log_views';
import { persistedLogViewReferenceRT } from '../../../../log_views';
import {
badRequestErrorRT,
forbiddenErrorRT,
timeRangeRT,
routeTimingMetadataRT,
} from '../../shared';
} from '../../../shared';

import { logEntryCategoryRT, categoriesSortRT } from '../../../log_analysis';
import { logEntryCategoryRT, categoriesSortRT } from '../../../../log_analysis';

export const LOG_ANALYSIS_GET_LOG_ENTRY_CATEGORIES_PATH =
'/api/infra/log_analysis/results/log_entry_categories';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import {
forbiddenErrorRT,
timeRangeRT,
routeTimingMetadataRT,
} from '../../shared';
import { persistedLogViewReferenceRT } from '../../../log_views';
} from '../../../shared';
import { persistedLogViewReferenceRT } from '../../../../log_views';
export const LOG_ANALYSIS_GET_LOG_ENTRY_CATEGORY_DATASETS_PATH =
'/api/infra/log_analysis/results/log_entry_category_datasets';

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

import * as rt from 'io-ts';

import { timeRangeRT, routeTimingMetadataRT } from '../../shared';
import { timeRangeRT, routeTimingMetadataRT } from '../../../shared';

export const LOG_ANALYSIS_GET_LATEST_LOG_ENTRY_CATEGORY_DATASETS_STATS_PATH =
'/api/infra/log_analysis/results/latest_log_entry_category_datasets_stats';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@

import * as rt from 'io-ts';

import { persistedLogViewReferenceRT } from '../../../log_views';
import { persistedLogViewReferenceRT } from '../../../../log_views';
import {
badRequestErrorRT,
forbiddenErrorRT,
timeRangeRT,
routeTimingMetadataRT,
} from '../../shared';
import { logEntryContextRT } from '../../../log_entry';
} from '../../../shared';
import { logEntryContextRT } from '../../../../log_entry';

export const LOG_ANALYSIS_GET_LOG_ENTRY_CATEGORY_EXAMPLES_PATH =
'/api/infra/log_analysis/results/log_entry_category_examples';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@
*/

import * as rt from 'io-ts';
import { persistedLogViewReferenceRT } from '../../../log_views';
import { logEntryExampleRT } from '../../../log_analysis';
import { persistedLogViewReferenceRT } from '../../../../log_views';
import { logEntryExampleRT } from '../../../../log_analysis';
import {
badRequestErrorRT,
forbiddenErrorRT,
timeRangeRT,
routeTimingMetadataRT,
} from '../../shared';
} from '../../../shared';

export const LOG_ANALYSIS_GET_LOG_ENTRY_RATE_EXAMPLES_PATH =
'/api/infra/log_analysis/results/log_entry_examples';
Expand Down Expand Up @@ -48,7 +48,7 @@ export type GetLogEntryExamplesRequestPayload = rt.TypeOf<
* response
*/

export const getLogEntryExamplesSuccessReponsePayloadRT = rt.intersection([
export const getLogEntryExamplesSuccessResponsePayloadRT = rt.intersection([
rt.type({
data: rt.type({
examples: rt.array(logEntryExampleRT),
Expand All @@ -60,11 +60,11 @@ export const getLogEntryExamplesSuccessReponsePayloadRT = rt.intersection([
]);

export type GetLogEntryExamplesSuccessReponsePayload = rt.TypeOf<
typeof getLogEntryExamplesSuccessReponsePayloadRT
typeof getLogEntryExamplesSuccessResponsePayloadRT
Copy link
Contributor

Choose a reason for hiding this comment

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

Good Catch :)

>;

export const getLogEntryExamplesResponsePayloadRT = rt.union([
getLogEntryExamplesSuccessReponsePayloadRT,
getLogEntryExamplesSuccessResponsePayloadRT,
badRequestErrorRT,
forbiddenErrorRT,
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import * as rt from 'io-ts';
import { mappingRuntimeFieldRT } from '../../shared/es_request';
import { mappingRuntimeFieldRT } from '../../../shared/es_request';

export const LOG_ANALYSIS_VALIDATE_INDICES_PATH =
'/api/infra/log_analysis/validation/log_entry_rate_indices';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
*/

import * as rt from 'io-ts';
import { logEntryCursorRT, logEntryRT } from '../../log_entry';
import { logViewColumnConfigurationRT } from '../../log_views';
import { logViewReferenceRT } from '../../log_views';
import { logEntryCursorRT, logEntryRT } from '../../../log_entry';
import { logViewColumnConfigurationRT } from '../../../log_views';
import { logViewReferenceRT } from '../../../log_views';

export const LOG_ENTRIES_HIGHLIGHTS_PATH = '/api/log_entries/highlights';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import * as rt from 'io-ts';
import { logViewReferenceRT } from '../../log_views';
import { logViewReferenceRT } from '../../../log_views';

export const LOG_ENTRIES_SUMMARY_PATH = '/api/log_entries/summary';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import * as rt from 'io-ts';
import { logEntryCursorRT } from '../../log_entry';
import { logEntryCursorRT } from '../../../log_entry';
import { logEntriesSummaryRequestRT, logEntriesSummaryBucketRT } from './summary';

export const LOG_ENTRIES_SUMMARY_HIGHLIGHTS_PATH = '/api/log_entries/summary_highlights';
Expand Down
2 changes: 0 additions & 2 deletions x-pack/plugins/infra/common/http_api/log_views/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,3 @@
*/

export { getLogViewUrl, LOG_VIEW_URL } from './common';
export * from './get_log_view';
export * from './put_log_view';
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
*/

import * as rt from 'io-ts';
import { logViewRT } from '../../log_views';
import { logViewRT } from '../../../log_views';

export const getLogViewRequestParamsRT = rt.type({
// the id of the log view
logViewId: rt.string,
});

export type GetLogViewRequestParams = rt.TypeOf<typeof getLogViewRequestParamsRT>;

export const getLogViewResponsePayloadRT = rt.type({
data: logViewRT,
});
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
* 2.0.
*/

export * from './results';
export * from './validation';
export * from './get_log_view';
export * from './put_log_view';
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import * as rt from 'io-ts';
import { logViewAttributesRT, logViewRT } from '../../log_views';
import { logViewAttributesRT, logViewRT } from '../../../log_views';

export const putLogViewRequestParamsRT = rt.type({
logViewId: rt.string,
Expand All @@ -15,6 +15,7 @@ export const putLogViewRequestParamsRT = rt.type({
export const putLogViewRequestPayloadRT = rt.type({
attributes: rt.partial(logViewAttributesRT.type.props),
});

export type PutLogViewRequestPayload = rt.TypeOf<typeof putLogViewRequestPayloadRT>;

export const putLogViewResponsePayloadRT = rt.type({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ import { Color, colorTransformer } from '../../../../../common/color_palette';
import {
GetLogAlertsChartPreviewDataAlertParamsSubset,
getLogAlertsChartPreviewDataAlertParamsSubsetRT,
} from '../../../../../common/http_api/log_alerts';
} from '../../../../../common/http_api';
import { useChartPreviewData } from './hooks/use_chart_preview_data';
import { decodeOrThrow } from '../../../../../common/runtime_types';
import { useKibanaTimeZoneSetting } from '../../../../hooks/use_kibana_time_zone_setting';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@
* 2.0.
*/

import { useState, useMemo } from 'react';
import { HttpHandler } from '@kbn/core/public';
import { useKibana } from '@kbn/kibana-react-plugin/public';
import { useMemo, useState } from 'react';
import { isRatioRule } from '../../../../../../common/alerting/logs/log_threshold';
import { PersistedLogViewReference } from '../../../../../../common/log_views';
import { ExecutionTimeRange } from '../../../../../types';
import { useTrackedPromise } from '../../../../../utils/use_tracked_promise';
import {
GetLogAlertsChartPreviewDataAlertParamsSubset,
getLogAlertsChartPreviewDataRequestPayloadRT,
GetLogAlertsChartPreviewDataSuccessResponsePayload,
getLogAlertsChartPreviewDataSuccessResponsePayloadRT,
getLogAlertsChartPreviewDataRequestPayloadRT,
LOG_ALERTS_CHART_PREVIEW_DATA_PATH,
} from '../../../../../../common/http_api';
import { PersistedLogViewReference } from '../../../../../../common/log_views';
import { decodeOrThrow } from '../../../../../../common/runtime_types';
import { GetLogAlertsChartPreviewDataAlertParamsSubset } from '../../../../../../common/http_api/log_alerts';
import { ExecutionTimeRange } from '../../../../../types';
import { useTrackedPromise } from '../../../../../utils/use_tracked_promise';

interface Options {
logViewReference: PersistedLogViewReference;
Expand Down Expand Up @@ -147,6 +147,7 @@ export const callGetChartPreviewDataAPI = async (
},
})
),
version: '1',
});

return decodeOrThrow(getLogAlertsChartPreviewDataSuccessResponsePayloadRT)(response);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
ISearchOptions,
} from '@kbn/data-plugin/public';
import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public';
import { getLogViewResponsePayloadRT } from '../../../common/http_api/log_views';
import { getLogViewResponsePayloadRT } from '../../../common/http_api';
import { defaultLogViewAttributes } from '../../../common/log_views';
import {
LogEntriesSearchResponsePayload,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export const callGetLatestCategoriesDatasetsStatsAPI = async (
},
})
),
version: '1',
});

return decodeOrThrow(getLatestLogEntryCategoryDatasetsStatsSuccessResponsePayloadRT)(response);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export const callValidateDatasetsAPI = async (requestArgs: RequestArgs, fetch: H
},
})
),
version: '1',
});

return decodeOrThrow(validateLogEntryDatasetsResponsePayloadRT)(response);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const callValidateIndicesAPI = async (requestArgs: RequestArgs, fetch: Ht
// @ts-expect-error TODO: fix after elasticsearch-js bump
validationIndicesRequestPayloadRT.encode({ data: { indices, fields, runtimeMappings } })
),
version: '1',
});

return decodeOrThrow(validationIndicesResponsePayloadRT)(response);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import {
ValidateLogEntryDatasetsResponsePayload,
ValidationIndicesResponsePayload,
} from '../../../../common/http_api/log_analysis';
} from '../../../../common/http_api';
import { DatasetFilter } from '../../../../common/log_analysis';
import { DeleteJobsResponsePayload } from './api/ml_cleanup';
import { FetchJobStatusResponsePayload } from './api/ml_get_jobs_summary_api';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const fetchLogEntriesHighlights = async (
const response = await fetch(LOG_ENTRIES_HIGHLIGHTS_PATH, {
method: 'POST',
body: JSON.stringify(logEntriesHighlightsRequestRT.encode(requestArgs)),
version: '1',
});

return decodeOrThrow(logEntriesHighlightsResponseRT)(response);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const fetchLogSummaryHighlights = async (
const response = await fetch(LOG_ENTRIES_SUMMARY_HIGHLIGHTS_PATH, {
method: 'POST',
body: JSON.stringify(logEntriesSummaryHighlightsRequestRT.encode(requestArgs)),
version: '1',
});

return decodeOrThrow(logEntriesSummaryHighlightsResponseRT)(response);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export const fetchLogSummary = async (
const response = await fetch(LOG_ENTRIES_SUMMARY_PATH, {
method: 'POST',
body: JSON.stringify(logEntriesSummaryRequestRT.encode(requestArgs)),
version: '1',
});

return decodeOrThrow(logEntriesSummaryResponseRT)(response);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { HttpHandler } from '@kbn/core/public';
import {
ValidateLogEntryDatasetsResponsePayload,
ValidationIndicesResponsePayload,
} from '../../../common/http_api/log_analysis';
} from '../../../common/http_api';
import { DeleteJobsResponsePayload } from './api/ml_cleanup';
import { FetchJobStatusResponsePayload } from './api/ml_get_jobs_summary_api';
import { GetMlModuleResponsePayload } from './api/ml_get_module';
Expand Down
Loading