Skip to content

Commit

Permalink
[Observability AI Assistant] Use POST for get_apm_services_list (#165621
Browse files Browse the repository at this point in the history
)

Co-authored-by: Dario Gieselaar <[email protected]>
  • Loading branch information
CoenWarmer and dgieselaar authored Sep 4, 2023
1 parent ee98641 commit 300e298
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ export function registerGetApmServicesListFunction({
} as const,
},
async ({ arguments: args }, signal) => {
return callApmApi('GET /internal/apm/assistant/get_services_list', {
return callApmApi('POST /internal/apm/assistant/get_services_list', {
signal,
params: {
query: args,
body: args,
},
});
}
Expand Down
23 changes: 11 additions & 12 deletions x-pack/plugins/apm/server/routes/assistant_functions/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,27 @@ import { getApmEventClient } from '../../lib/helpers/get_apm_event_client';
import { getMlClient } from '../../lib/helpers/get_ml_client';
import { getRandomSampler } from '../../lib/helpers/get_random_sampler';
import { createApmServerRoute } from '../apm_routes/create_apm_server_route';
import { environmentRt } from '../default_api_types';
import { getServicesItems } from '../services/get_services/get_services_items';
import {
CorrelationValue,
correlationValuesRouteRt,
getApmCorrelationValues,
} from './get_apm_correlation_values';
import {
type APMDownstreamDependency,
downstreamDependenciesRouteRt,
getAssistantDownstreamDependencies,
type APMDownstreamDependency,
} from './get_apm_downstream_dependencies';
import { errorRouteRt, getApmErrorDocument } from './get_apm_error_document';
import {
getApmServiceSummary,
type ServiceSummary,
serviceSummaryRouteRt,
type ServiceSummary,
} from './get_apm_service_summary';
import {
type ApmTimeseries,
getApmTimeseries,
getApmTimeseriesRt,
type ApmTimeseries,
} from './get_apm_timeseries';

const getApmTimeSeriesRoute = createApmServerRoute({
Expand Down Expand Up @@ -204,15 +203,15 @@ interface ApmServicesListItem {
type ApmServicesListContent = ApmServicesListItem[];

const getApmServicesListRoute = createApmServerRoute({
endpoint: 'GET /internal/apm/assistant/get_services_list',
endpoint: 'POST /internal/apm/assistant/get_services_list',
params: t.type({
query: t.intersection([
body: t.intersection([
t.type({
start: t.string,
end: t.string,
}),
t.partial({
'service.environment': environmentRt.props.environment,
'service.environment': t.string,
healthStatus: t.array(
t.union([
t.literal(ServiceHealthStatus.unknown),
Expand All @@ -229,9 +228,9 @@ const getApmServicesListRoute = createApmServerRoute({
},
handler: async (resources): Promise<{ content: ApmServicesListContent }> => {
const { params } = resources;
const { query } = params;
const { body } = params;

const { healthStatus } = query;
const { healthStatus } = body;

const [apmEventClient, apmAlertsClient, mlClient, randomSampler] =
await Promise.all([
Expand All @@ -245,16 +244,16 @@ const getApmServicesListRoute = createApmServerRoute({
}),
]);

const start = datemath.parse(query.start)?.valueOf()!;
const end = datemath.parse(query.end)?.valueOf()!;
const start = datemath.parse(body.start)?.valueOf()!;
const end = datemath.parse(body.end)?.valueOf()!;

const serviceItems = await getServicesItems({
apmAlertsClient,
apmEventClient,
documentType: ApmDocumentType.TransactionMetric,
start,
end,
environment: query['service.environment'] ?? ENVIRONMENT_ALL.value,
environment: body['service.environment'] || ENVIRONMENT_ALL.value,
kuery: '',
logger: resources.logger,
randomSampler,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export async function registerFunctions({
);

if (isReady) {
description += `You can use the "summarize" functions to store new information you have learned in a knowledge database. Once you have established that you did not know the answer to a question, and the user gave you this information, it's important that you create a summarisation of what you have learned and store it in the knowledge database.
description += `You can use the "summarize" functions to store new information you have learned in a knowledge database. Once you have established that you did not know the answer to a question, and the user gave you this information, it's important that you create a summarisation of what you have learned and store it in the knowledge database. Don't create a new summarization if you see a similar summarization in the conversation, instead, update the existing one by re-using its ID.
Additionally, you can use the "recall" function to retrieve relevant information from the knowledge database.
`;
Expand Down

0 comments on commit 300e298

Please sign in to comment.