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

[Obs AI Assistant] Move alert context from apm to obs api #182243

Merged
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 1 addition & 1 deletion x-pack/plugins/observability_solution/apm/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import { createApmSourceMapIndexTemplate } from './routes/source_maps/create_apm
import { addApiKeysToEveryPackagePolicyIfMissing } from './routes/fleet/api_keys/add_api_keys_to_policies_if_missing';
import { apmTutorialCustomIntegration } from '../common/tutorial/tutorials';
import { registerAssistantFunctions } from './assistant_functions';
import { getAlertDetailsContextHandler } from './routes/assistant_functions/get_observability_alert_details_context/get_alert_details_context_handler';
import { getAlertDetailsContextHandler } from './routes/assistant_functions/get_observability_alert_details_context';

export class APMPlugin
implements Plugin<APMPluginSetup, void, APMPluginSetupDependencies, APMPluginStartDependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* 2.0.
*/

import moment from 'moment';
import { LatencyAggregationType } from '../../../../common/latency_aggregation_types';
import { APMEventClient } from '../../../lib/helpers/create_es_client/create_apm_event_client';
import { ApmTimeseriesType, getApmTimeseries, TimeseriesChangePoint } from '../get_apm_timeseries';
Expand All @@ -18,14 +17,16 @@ export interface ChangePointGrouping {

export async function getServiceChangePoints({
apmEventClient,
alertStartedAt,
start,
end,
serviceName,
serviceEnvironment,
transactionType,
transactionName,
}: {
apmEventClient: APMEventClient;
alertStartedAt: string;
start: string;
end: string;
serviceName: string | undefined;
serviceEnvironment: string | undefined;
transactionType: string | undefined;
Expand All @@ -38,8 +39,8 @@ export async function getServiceChangePoints({
const res = await getApmTimeseries({
apmEventClient,
arguments: {
start: moment(alertStartedAt).subtract(12, 'hours').toISOString(),
end: alertStartedAt,
start,
end,
stats: [
{
title: 'Latency',
Expand Down Expand Up @@ -95,12 +96,14 @@ export async function getServiceChangePoints({

export async function getExitSpanChangePoints({
apmEventClient,
alertStartedAt,
start,
end,
serviceName,
serviceEnvironment,
}: {
apmEventClient: APMEventClient;
alertStartedAt: string;
start: string;
end: string;
serviceName: string | undefined;
serviceEnvironment: string | undefined;
}): Promise<ChangePointGrouping[]> {
Expand All @@ -111,8 +114,8 @@ export async function getExitSpanChangePoints({
const res = await getApmTimeseries({
apmEventClient,
arguments: {
start: moment(alertStartedAt).subtract(30, 'minute').toISOString(),
end: alertStartedAt,
start,
end,
stats: [
{
title: 'Exit span latency',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@ import {
} from '../../../../common/es_fields/apm';
import { getTypedSearch } from '../../../utils/create_typed_es_client';

export type LogCategories =
| Array<{
errorCategory: string;
docCount: number;
sampleMessage: string;
}>
| undefined;
export interface LogCategory {
errorCategory: string;
docCount: number;
sampleMessage: string;
}

export async function getLogCategories({
esClient,
Expand All @@ -40,7 +38,7 @@ export async function getLogCategories({
'container.id'?: string;
'kubernetes.pod.name'?: string;
};
}): Promise<LogCategories> {
}): Promise<LogCategory[] | undefined> {
const start = datemath.parse(args.start)?.valueOf()!;
const end = datemath.parse(args.end)?.valueOf()!;

Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { rangeQuery, typedSearch } from '@kbn/observability-plugin/server/utils/
import * as t from 'io-ts';
import moment from 'moment';
import { ESSearchRequest } from '@kbn/es-types';
import { observabilityAlertDetailsContextRt } from '@kbn/observability-plugin/server/services';
import { alertDetailsContextRt } from '@kbn/observability-plugin/server/services';
import { ApmDocumentType } from '../../../../common/document_type';
import {
APMEventClient,
Expand All @@ -26,7 +26,7 @@ export async function getContainerIdFromSignals({
coreContext,
apmEventClient,
}: {
query: t.TypeOf<typeof observabilityAlertDetailsContextRt>;
query: t.TypeOf<typeof alertDetailsContextRt>;
esClient: ElasticsearchClient;
coreContext: Pick<CoreRequestHandlerContext, 'uiSettings'>;
apmEventClient: APMEventClient;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { rangeQuery, termQuery, typedSearch } from '@kbn/observability-plugin/se
import * as t from 'io-ts';
import moment from 'moment';
import { ESSearchRequest } from '@kbn/es-types';
import { observabilityAlertDetailsContextRt } from '@kbn/observability-plugin/server/services';
import { alertDetailsContextRt } from '@kbn/observability-plugin/server/services';
import { ApmDocumentType } from '../../../../common/document_type';
import {
APMEventClient,
Expand All @@ -26,7 +26,7 @@ export async function getServiceNameFromSignals({
coreContext,
apmEventClient,
}: {
query: t.TypeOf<typeof observabilityAlertDetailsContextRt>;
query: t.TypeOf<typeof alertDetailsContextRt>;
esClient: ElasticsearchClient;
coreContext: Pick<CoreRequestHandlerContext, 'uiSettings'>;
apmEventClient: APMEventClient;
Expand Down
Loading