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

chore(slo): Migrate to server-route-repository #198726

Merged
merged 56 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
090c53d
wip: migration attempt to http core router
kdelemme Nov 1, 2024
d0a9883
Update Plugin types
kdelemme Nov 1, 2024
88fd533
Use correct plugins from dependencies
kdelemme Nov 1, 2024
861d205
Fix usage of licensing
kdelemme Nov 1, 2024
e05e672
Replace usage of custom licensing and spaces start function
kdelemme Nov 1, 2024
7ea5f27
Remove usage of custom start function
kdelemme Nov 1, 2024
6e3bbb2
Remove rac and rules specific start function
kdelemme Nov 1, 2024
2540e6f
Remove usage of leftover plugins
kdelemme Nov 1, 2024
f580480
Fix plugins and corePlugins usage
kdelemme Nov 1, 2024
377fc19
Add SLORepositoryClient to public plugin and context
kdelemme Nov 4, 2024
44273f6
Use client from use fetch slo list hook
kdelemme Nov 4, 2024
6e96060
Use client from use fetch slo definitions hook
kdelemme Nov 4, 2024
232486d
Use client from use create slo hook
kdelemme Nov 4, 2024
1b93e2b
Use client from use delete instance hook
kdelemme Nov 4, 2024
073560c
Use client from use delete slo hook
kdelemme Nov 4, 2024
708e1c2
Use client from use fetch global diagnosis hook
kdelemme Nov 4, 2024
7caf413
Use client from use fetch historical summary hook
kdelemme Nov 4, 2024
db15edf
Use client from use fetch slo burn rates hook
kdelemme Nov 4, 2024
8a94f42
Use client from use fetch slo details hook
kdelemme Nov 4, 2024
a204ad0
Use client from use fetch slo groups hook
kdelemme Nov 4, 2024
7bea57b
Use client from use fetch slo health
kdelemme Nov 4, 2024
b2f09e6
Use client from use fetch slo inspect hook
kdelemme Nov 4, 2024
6cd5ceb
Use client from use fetch preview data hook
kdelemme Nov 4, 2024
f5fe891
Use client from use reset slo hook
kdelemme Nov 4, 2024
f3d5672
Use client from use update slo hook
kdelemme Nov 4, 2024
46db725
Remove import
kdelemme Nov 4, 2024
7694fe2
Fix usage of query params
kdelemme Nov 4, 2024
3b7a5b8
Use client from use suggestion hook
kdelemme Nov 4, 2024
8a3d28f
update local hooks from slo pages
kdelemme Nov 4, 2024
7e25fd8
wip: refactor SLO public Plugin
kdelemme Nov 4, 2024
885ee36
wip: refactor SLO public plugin
kdelemme Nov 4, 2024
d81a3f2
wip: Refactor slo embeddable overview
kdelemme Nov 4, 2024
478bae0
Fix alerts embeddable deps
kdelemme Nov 4, 2024
02e5e1c
Fix error budget embeddable deps
kdelemme Nov 4, 2024
69b2183
fix burn rate embeddable
kdelemme Nov 4, 2024
bb3e780
Fix ui actions registering
kdelemme Nov 4, 2024
2de2399
fix flyout
kdelemme Nov 4, 2024
4f70c8a
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Nov 4, 2024
cc67e0f
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Nov 4, 2024
4cdca40
fix mock import
kdelemme Nov 5, 2024
65d06fc
Fix open configuration
kdelemme Nov 5, 2024
4e3270c
Move useKibana hooks into hooks folder
kdelemme Nov 5, 2024
688c62a
rename kibana_react to use_kibana
kdelemme Nov 5, 2024
1d6dbfd
Remove unused constant
kdelemme Nov 5, 2024
803c813
Add spaces to optional plugin
kdelemme Nov 5, 2024
ec0d9b6
Fix lazy loading of alerts section with missing context providers
kdelemme Nov 5, 2024
b8d0087
Merge branch 'main' into chore/migrate-to-core-http-router
kdelemme Nov 5, 2024
a4ffd0b
Fix tests mock
kdelemme Nov 5, 2024
acf22fd
Fix type
kdelemme Nov 5, 2024
9945ab4
Fix duplication of context providers
kdelemme Nov 5, 2024
f81ed59
Fix documentation response code
kdelemme Nov 6, 2024
ef1715c
[CI] Auto-commit changed files from 'make api-docs'
kibanamachine Nov 6, 2024
ab5510c
Fix test
kdelemme Nov 6, 2024
5a421e5
Handle SLO domain errors on the routes
kdelemme Nov 7, 2024
fca3bbb
Merge branch 'main' into chore/migrate-to-core-http-router
shahzad31 Nov 12, 2024
11b8a0f
Merge branch 'main' into chore/migrate-to-core-http-router
kdelemme Nov 12, 2024
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
4 changes: 2 additions & 2 deletions oas_docs/output/kibana.serverless.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36267,7 +36267,7 @@ paths:
- $ref: '#/components/parameters/SLOs_space_id'
- $ref: '#/components/parameters/SLOs_slo_id'
responses:
'204':
'200':
content:
application/json; Elastic-Api-Version=2023-10-31:
schema:
Expand Down Expand Up @@ -36311,7 +36311,7 @@ paths:
- $ref: '#/components/parameters/SLOs_space_id'
- $ref: '#/components/parameters/SLOs_slo_id'
responses:
'200':
'204':
description: Successful request
'400':
content:
Expand Down
4 changes: 2 additions & 2 deletions oas_docs/output/kibana.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40728,7 +40728,7 @@ paths:
- $ref: '#/components/parameters/SLOs_space_id'
- $ref: '#/components/parameters/SLOs_slo_id'
responses:
'204':
'200':
content:
application/json; Elastic-Api-Version=2023-10-31:
schema:
Expand Down Expand Up @@ -40772,7 +40772,7 @@ paths:
- $ref: '#/components/parameters/SLOs_space_id'
- $ref: '#/components/parameters/SLOs_slo_id'
responses:
'200':
'204':
description: Successful request
'400':
content:
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,19 @@ import { errors } from '@elastic/elasticsearch';
import Boom from '@hapi/boom';
import { RulesClientApi } from '@kbn/alerting-plugin/server/types';
import { CoreSetup, KibanaRequest, Logger, RouteRegistrar } from '@kbn/core/server';
import { DataViewsServerPluginStart } from '@kbn/data-views-plugin/server';
import { RuleDataPluginService } from '@kbn/rule-registry-plugin/server';
import {
IoTsParamsObject,
decodeRequestParams,
stripNullishRequestParameters,
parseEndpoint,
passThroughValidationObject,
stripNullishRequestParameters,
} from '@kbn/server-route-repository';
import { SpacesPluginStart } from '@kbn/spaces-plugin/server';
import axios from 'axios';
import * as t from 'io-ts';
import { DataViewsServerPluginStart } from '@kbn/data-views-plugin/server';
import { ObservabilityConfig } from '..';
import { getHTTPResponseCode, ObservabilityError } from '../errors';
import { AlertDetailsContextualInsightsService } from '../services';
import { ObservabilityRequestHandlerContext } from '../types';
import { AbstractObservabilityServerRouteRepository } from './types';
Expand Down Expand Up @@ -88,16 +87,6 @@ export function registerRoutes({ config, repository, core, logger, dependencies

return response.ok({ body: data });
} catch (error) {
if (error instanceof ObservabilityError) {
logger.error(error.message);
return response.customError({
statusCode: getHTTPResponseCode(error),
body: {
message: error.message,
},
});
}

Comment on lines -91 to -100
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was specific to SLO. Since we moved SLO outside of observability/ this handler is not use anymore

if (axios.isAxiosError(error)) {
logger.error(error);
return response.customError({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import { UnifiedSearchPublicPluginStart } from '@kbn/unified-search-plugin/publi
import { DataViewsPublicPluginStart } from '@kbn/data-views-plugin/public';
import { DataViewEditorStart } from '@kbn/data-view-editor-plugin/public';
import { LensPublicStart } from '@kbn/lens-plugin/public';
import { SloPublicStart } from '@kbn/slo-plugin/public';
import { SLOPublicStart } from '@kbn/slo-plugin/public';
import { LogsDataAccessPluginStart } from '@kbn/logs-data-access-plugin/public';
import {
ObservabilityLogsExplorerLocators,
Expand Down Expand Up @@ -53,7 +53,7 @@ export interface ObservabilityLogsExplorerStartDeps {
logsDataAccess: LogsDataAccessPluginStart;
observabilityAIAssistant?: ObservabilityAIAssistantPublicStart;
observabilityShared: ObservabilitySharedPluginStart;
slo: SloPublicStart;
slo: SLOPublicStart;
serverless?: ServerlessPluginStart;
triggersActionsUi?: TriggersAndActionsUIPublicPluginStart;
unifiedSearch?: UnifiedSearchPublicPluginStart;
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/observability_solution/slo/common/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ export const config = {
experimental: true,
},
};
export type SloConfig = TypeOf<typeof configSchema>;
export type ExperimentalFeatures = SloConfig['experimental'];
export type SLOConfig = TypeOf<typeof configSchema>;
export type ExperimentalFeatures = SLOConfig['experimental'];
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@
}
],
"responses": {
"200": {
"204": {
"description": "Successful request"
},
"400": {
Expand Down Expand Up @@ -625,7 +625,7 @@
}
],
"responses": {
"204": {
"200": {
"description": "Successful request",
"content": {
"application/json": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ paths:
- $ref: '#/components/parameters/space_id'
- $ref: '#/components/parameters/slo_id'
responses:
'200':
'204':
description: Successful request
'400':
description: Bad request
Expand Down Expand Up @@ -380,7 +380,7 @@ paths:
- $ref: '#/components/parameters/space_id'
- $ref: '#/components/parameters/slo_id'
responses:
'204':
'200':
description: Successful request
content:
application/json:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ post:
- $ref: ../components/parameters/space_id.yaml
- $ref: ../components/parameters/slo_id.yaml
responses:
'204':
'200':
description: Successful request
content:
application/json:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ post:
- $ref: ../components/parameters/space_id.yaml
- $ref: ../components/parameters/slo_id.yaml
responses:
'200':
'204':
description: Successful request
'400':
description: Bad request
Expand Down
6 changes: 3 additions & 3 deletions x-pack/plugins/observability_solution/slo/kibana.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@
"presentationUtil",
"features",
"licensing",
"usageCollection"
"usageCollection",
],
"optionalPlugins": [
"cloud",
"spaces",
"serverless",
"discover",
"observabilityAIAssistant"
"observabilityAIAssistant",
"spaces",
],
"requiredBundles": [
"controls",
Expand Down
65 changes: 34 additions & 31 deletions x-pack/plugins/observability_solution/slo/public/application.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,20 @@ import { ExperimentalFeatures } from '../common/config';
import { PluginContext } from './context/plugin_context';
import { usePluginContext } from './hooks/use_plugin_context';
import { getRoutes } from './routes/routes';
import { SloPublicPluginsStart } from './types';
import { SLORepositoryClient, SLOPublicPluginsStart } from './types';

function App() {
const { isServerless } = usePluginContext();

const routes = getRoutes(isServerless);

return (
<>
<Routes>
{Object.keys(routes).map((path) => {
const { handler, exact } = routes[path];
const Wrapper = () => {
return handler();
};
return <Route key={path} path={path} exact={exact} component={Wrapper} />;
})}
</Routes>
</>
);
interface Props {
core: CoreStart;
plugins: SLOPublicPluginsStart;
appMountParameters: AppMountParameters;
observabilityRuleTypeRegistry: ObservabilityRuleTypeRegistry;
ObservabilityPageTemplate: React.ComponentType<LazyObservabilityPageTemplateProps>;
usageCollection: UsageCollectionSetup;
isDev?: boolean;
kibanaVersion: string;
isServerless?: boolean;
experimentalFeatures: ExperimentalFeatures;
sloClient: SLORepositoryClient;
}

export const renderApp = ({
Expand All @@ -58,18 +52,8 @@ export const renderApp = ({
isServerless,
observabilityRuleTypeRegistry,
experimentalFeatures,
}: {
core: CoreStart;
plugins: SloPublicPluginsStart;
appMountParameters: AppMountParameters;
observabilityRuleTypeRegistry: ObservabilityRuleTypeRegistry;
ObservabilityPageTemplate: React.ComponentType<LazyObservabilityPageTemplateProps>;
usageCollection: UsageCollectionSetup;
isDev?: boolean;
kibanaVersion: string;
isServerless?: boolean;
experimentalFeatures: ExperimentalFeatures;
}) => {
sloClient,
}: Props) => {
const { element, history, theme$ } = appMountParameters;
const isDarkMode = core.theme.getTheme().darkMode;

Expand Down Expand Up @@ -128,6 +112,7 @@ export const renderApp = ({
ObservabilityPageTemplate,
observabilityRuleTypeRegistry,
experimentalFeatures,
sloClient,
}}
>
<Router history={history}>
Expand Down Expand Up @@ -160,3 +145,21 @@ export const renderApp = ({
ReactDOM.unmountComponentAtNode(element);
};
};

function App() {
const { isServerless } = usePluginContext();

const routes = getRoutes(isServerless);

return (
<Routes>
{Object.keys(routes).map((path) => {
const { handler, exact } = routes[path];
const Wrapper = () => {
return handler();
};
return <Route key={path} path={path} exact={exact} component={Wrapper} />;
})}
</Routes>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import React, { useRef } from 'react';
import { useAnnotations } from '@kbn/observability-plugin/public';
import { TimeBounds } from '../../pages/slo_details/types';
import { getBrushTimeBounds } from '../../utils/slo/duration';
import { useKibana } from '../../utils/kibana_react';
import { useKibana } from '../../hooks/use_kibana';
import { openInDiscover } from '../../utils/slo/get_discover_link';

export interface Props {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import React from 'react';
import { i18n } from '@kbn/i18n';
import { EuiFlexGroup, EuiFlexItem, EuiHeaderLink, EuiHeaderLinks } from '@elastic/eui';
import { HeaderMenuPortal } from '@kbn/observability-shared-plugin/public';
import { useKibana } from '../../utils/kibana_react';
import { useKibana } from '../../hooks/use_kibana';
import { usePluginContext } from '../../hooks/use_plugin_context';
import { SLOS_BASE_PATH, SLO_SETTINGS_PATH } from '../../../common/locators/paths';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import React, { useEffect } from 'react';
import { EuiFlexGroup, EuiLink } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { AlertDetailsAppSectionProps } from '@kbn/observability-plugin/public';
import { useKibana } from '../../../../utils/kibana_react';
import { useKibana } from '../../../../hooks/use_kibana';
import { useFetchSloDetails } from '../../../../hooks/use_fetch_slo_details';
import { CustomAlertDetailsPanel } from './components/custom_panels/custom_panels';
import { ErrorRatePanel } from './components/error_rate/error_rate_panel';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import type { WindowSchema } from '../../../../../../../typings';
import { TimeRange } from '../../../../../error_rate_chart/use_lens_definition';
import { BurnRateAlert, BurnRateRule } from '../../../types';
import { getActionGroupFromReason } from '../../../utils/alert';
import { useKibana } from '../../../../../../../utils/kibana_react';
import { useKibana } from '../../../../../../../hooks/use_kibana';
import { getESQueryForLogRateAnalysis } from './helpers/log_rate_analysis_query';
function getDataTimeRange(
timeRange: { gte: string; lte?: string },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { FormattedMessage } from '@kbn/i18n-react';
import { ALERT_EVALUATION_VALUE, ALERT_TIME_RANGE } from '@kbn/rule-data-utils';
import { GetSLOResponse } from '@kbn/slo-schema';
import React from 'react';
import { useKibana } from '../../../../../../utils/kibana_react';
import { useKibana } from '../../../../../../hooks/use_kibana';
import { ErrorRateChart } from '../../../../error_rate_chart';
import { TimeRange } from '../../../../error_rate_chart/use_lens_definition';
import { BurnRateAlert } from '../../types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import moment from 'moment';
import React from 'react';
import { SloTabId } from '../../../pages/slo_details/components/slo_details';
import { TimeBounds } from '../../../pages/slo_details/types';
import { useKibana } from '../../../utils/kibana_react';
import { useKibana } from '../../../hooks/use_kibana';
import { getDelayInSecondsFromSLO } from '../../../utils/slo/get_delay_in_seconds_from_slo';
import { AlertAnnotation, TimeRange, useLensDefinition } from './use_lens_definition';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { EuiButton, EuiCallOut, EuiSpacer } from '@elastic/eui';
import React from 'react';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n-react';
import { useKibana } from '../../../utils/kibana_react';
import { useKibana } from '../../../hooks/use_kibana';
import { useFetchSloDefinitions } from '../../../hooks/use_fetch_slo_definitions';
import { paths } from '../../../../common/locators/paths';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { i18n } from '@kbn/i18n';
import React, { MouseEvent } from 'react';
import { SLOWithSummaryResponse } from '@kbn/slo-schema';
import { observabilityPaths } from '@kbn/observability-plugin/common';
import { useKibana } from '../../../utils/kibana_react';
import { useKibana } from '../../../hooks/use_kibana';

export interface Props {
viewMode?: 'compact' | 'default';
Expand Down
Loading