Skip to content

Commit

Permalink
Improve alert summary with backend log pattern experience (#389)
Browse files Browse the repository at this point in the history
* Minor change trigger condition of alert summary API with log pattern

Signed-off-by: Songkan Tang <[email protected]>

* Minor fix to correctly catch AgentNotFoundError

Signed-off-by: Songkan Tang <[email protected]>

* Add change log

Signed-off-by: Songkan Tang <[email protected]>

---------

Signed-off-by: Songkan Tang <[email protected]>
  • Loading branch information
songkant-aws authored Jan 9, 2025
1 parent ca13184 commit 7858c95
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Optimize the response of AI agent APIs ([#373](https://github.com/opensearch-project/dashboards-assistant/pull/373), [#380](https://github.com/opensearch-project/dashboards-assistant/pull/380))
- fixed incorrect message id field used ([#378](https://github.com/opensearch-project/dashboards-assistant/pull/378))
- fix: return 404 instead of 500 for missing agent config name ([#384](https://github.com/opensearch-project/dashboards-assistant/pull/384))
- Improve alert summary with backend log pattern experience ([#389](https://github.com/opensearch-project/dashboards-assistant/pull/389))

### Infrastructure

Expand Down
8 changes: 4 additions & 4 deletions server/routes/summary_routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export function registerSummaryAssistantRoutes(
});
const assistantClient = assistantService.getScopedClient(req, context);
const agentConfigId =
req.body.index && req.body.dsl && req.body.topNLogPatternData
req.body.index && req.body.dsl
? LOG_PATTERN_SUMMARY_AGENT_CONFIG_ID
: SUMMARY_AGENT_CONFIG_ID;
try {
Expand Down Expand Up @@ -135,7 +135,7 @@ export function registerSummaryAssistantRoutes(
);
}

function detectInsightAgentId(
async function detectInsightAgentId(
insightType: string,
summaryType: string,
client: OpenSearchClient['transport']
Expand All @@ -144,9 +144,9 @@ function detectInsightAgentId(
// only get it by searching on name since it is not stored in agent config.
try {
if (insightType === 'os_insight') {
return getAgentIdByConfigName(OS_INSIGHT_AGENT_CONFIG_ID, client);
return await getAgentIdByConfigName(OS_INSIGHT_AGENT_CONFIG_ID, client);
} else if (insightType === 'user_insight' && summaryType === 'alerts') {
return searchAgent({ name: 'KB_For_Alert_Insight' }, client);
return await searchAgent({ name: 'KB_For_Alert_Insight' }, client);
}
} catch (e) {
// It only detects if the agent exists, we don't want to throw the error when not found the agent
Expand Down

0 comments on commit 7858c95

Please sign in to comment.