[Obs-AI-Assistant] Audit log level (#217645)

part of [[Meta] Audit log level in observability
plugins](https://github.com/elastic/observability-dev/issues/4373)
This commit is contained in:
Arturo Lidueña 2025-04-14 13:06:45 +02:00 committed by GitHub
parent 92556a37a7
commit 8dc8e931b7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 25 additions and 29 deletions

View file

@ -82,7 +82,7 @@ export async function getDatasetInfo({
});
return { indices, fields, stats };
} catch (e) {
resources.logger.error(`Error getting relevant field names: ${e.message}`);
resources.logger.warn(`Error getting relevant field names: ${e.message}`);
return { indices, fields: [] };
}
}

View file

@ -411,26 +411,24 @@ export class ObservabilityAIAssistantClient {
return throwError(() => error);
}),
tap((event) => {
if (this.dependencies.logger.isLevelEnabled('debug')) {
switch (event.type) {
case StreamingChatResponseEventType.MessageAdd:
this.dependencies.logger.debug(
() => `Added message: ${JSON.stringify(event.message)}`
);
break;
switch (event.type) {
case StreamingChatResponseEventType.MessageAdd:
this.dependencies.logger.debug(
() => `Added message: ${JSON.stringify(event.message)}`
);
break;
case StreamingChatResponseEventType.ConversationCreate:
this.dependencies.logger.debug(
() => `Created conversation: ${JSON.stringify(event.conversation)}`
);
break;
case StreamingChatResponseEventType.ConversationCreate:
this.dependencies.logger.debug(
() => `Created conversation: ${JSON.stringify(event.conversation)}`
);
break;
case StreamingChatResponseEventType.ConversationUpdate:
this.dependencies.logger.debug(
() => `Updated conversation: ${JSON.stringify(event.conversation)}`
);
break;
}
case StreamingChatResponseEventType.ConversationUpdate:
this.dependencies.logger.debug(
() => `Updated conversation: ${JSON.stringify(event.conversation)}`
);
break;
}
}),
shareReplay()
@ -513,10 +511,7 @@ export class ObservabilityAIAssistantClient {
apmInstrumentation(name),
failOnNonExistingFunctionCall({ functions }),
tap((event) => {
if (
event.type === StreamingChatResponseEventType.ChatCompletionChunk &&
this.dependencies.logger.isLevelEnabled('trace')
) {
if (event.type === StreamingChatResponseEventType.ChatCompletionChunk) {
this.dependencies.logger.trace(`Received chunk: ${JSON.stringify(event.message)}`);
}
}),

View file

@ -53,7 +53,7 @@ export async function createInferenceEndpoint({
}
);
} catch (e) {
logger.debug(
logger.error(
`Failed to create inference endpoint "${AI_ASSISTANT_KB_INFERENCE_ID}": ${e.message}`
);
throw e;
@ -132,7 +132,7 @@ export async function getKbModelStatus({
model_id: endpoint.service_settings?.model_id,
});
} catch (error) {
logger.debug(`Failed to get model stats: ${error.message}`);
logger.error(`Failed to get model stats: ${error.message}`);
return { enabled, errorMessage: error.message, kbState: KnowledgeBaseState.ERROR };
}

View file

@ -179,7 +179,7 @@ export class KnowledgeBaseService {
core: this.dependencies.core,
logger: this.dependencies.logger,
}).catch((error) => {
this.dependencies.logger.debug('Error getting data from search indices');
this.dependencies.logger.error('Error getting data from search indices');
this.dependencies.logger.debug(error);
return [];
}),
@ -438,7 +438,7 @@ export class KnowledgeBaseService {
this.dependencies.logger.debug(`Entry added to knowledge base`);
} catch (error) {
this.dependencies.logger.debug(`Failed to add entry to knowledge base ${error}`);
this.dependencies.logger.error(`Failed to add entry to knowledge base ${error}`);
if (isInferenceEndpointMissingOrUnavailable(error)) {
throwKnowledgeBaseNotReady(error.body);
}

View file

@ -82,6 +82,7 @@ async function reIndexKnowledgeBase({
logger.info('Re-indexing knowledge base completed successfully');
return true;
} catch (error) {
logger.error(`Failed to re-index knowledge base: ${error.message}`);
throw new Error(`Failed to re-index knowledge base: ${error.message}`);
}
}

View file

@ -31,7 +31,7 @@ export async function updateExistingIndexAssets({
});
if (!hasKbIndex && !hasConversationIndex) {
logger.debug('Index assets do not exist. Aborting updating index assets');
logger.warn('Index assets do not exist. Aborting updating index assets');
return;
}

View file

@ -44,7 +44,7 @@ export async function populateMissingSemanticTextFieldMigration({
});
if (!hasKbIndex) {
logger.debug('Knowledge base index does not exist. Aborting updating index assets');
logger.warn('Knowledge base index does not exist. Aborting updating index assets');
return;
}