Skip to content

Commit

Permalink
log rate analysis for alert details page
Browse files Browse the repository at this point in the history
  • Loading branch information
walterra committed Jun 18, 2024
1 parent e98d7b7 commit 20a066f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export async function getApmServiceSummary({
apmAlertsClient: ApmAlertsClient;
logger: Logger;
}): Promise<ServiceSummary> {
console.log('SERVICE SUMMARY!!');
const start = datemath.parse(args.start)?.valueOf()!;
const end = datemath.parse(args.end)?.valueOf()!;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import {
} from '@kbn/observability-plugin/server/services';
import moment from 'moment';
import { isEmpty } from 'lodash';
import { fetchSimpleLogRateAnalysis } from '@kbn/aiops-log-rate-analysis/queries/fetch_simple_log_rate_analysis';
import { aiAssistantLogsIndexPattern } from '@kbn/observability-ai-assistant-plugin/server';
import { SERVICE_NAME, SPAN_DESTINATION_SERVICE_RESOURCE } from '../../../../common/es_fields/apm';
import { getApmAlertsClient } from '../../../lib/helpers/get_apm_alerts_client';
import { getApmEventClient } from '../../../lib/helpers/get_apm_event_client';
Expand Down Expand Up @@ -166,6 +168,17 @@ export const getAlertDetailsContextHandler = (
})
);

const index = await coreContext.uiSettings.client.get<string>(aiAssistantLogsIndexPattern);
const logRateAnalysisPromise = handleError(() =>
fetchSimpleLogRateAnalysis(
esClient,
index,
moment(alertStartedAt).subtract(15, 'minute').toISOString(),
moment(alertStartedAt).add(15, 'minute').toISOString(),
'@timestamp'
)
);

const apmErrorsPromise = serviceName
? handleError(() =>
getApmErrors({
Expand Down Expand Up @@ -214,6 +227,7 @@ export const getAlertDetailsContextHandler = (
serviceSummary,
downstreamDependencies,
logCategories,
logRateAnalysis,
apmErrors,
serviceChangePoints,
exitSpanChangePoints,
Expand All @@ -222,6 +236,7 @@ export const getAlertDetailsContextHandler = (
serviceSummaryPromise,
downstreamDependenciesPromise,
logCategoriesPromise,
logRateAnalysisPromise,
apmErrorsPromise,
serviceChangePointsPromise,
exitSpanChangePointsPromise,
Expand Down Expand Up @@ -254,6 +269,11 @@ export const getAlertDetailsContextHandler = (
description: `Related log events occurring shortly before the alert was triggered.`,
data: logCategoriesWithDownstreamServiceName(logCategories, downstreamDependencies),
},
{
key: 'logRateAnalysis',
description: `Significant field/value pairs in log data that contributed to changes in the log rate.`,
data: logRateAnalysis,
},
{
key: 'apmErrors',
description: `Exceptions for the service "${serviceName}". If a downstream service name is included this could be a possible root cause. If relevant please describe what the error means and what it could be caused by.`,
Expand Down

0 comments on commit 20a066f

Please sign in to comment.