CloudWatch Logs: Support Log Anomalies query type (#113067)

This commit is contained in:
Ida Štambuk
2025-10-29 18:47:33 +01:00
committed by GitHub
parent de88abafdd
commit 30bd4e7dba
19 changed files with 1080 additions and 35 deletions
+15 -4
View File
@@ -36,7 +36,7 @@ const (
headerFromAlert = "FromAlert"
defaultRegion = "default"
logsQueryMode = "Logs"
queryModeLogs = "Logs"
// QueryTypes
annotationQuery = "annotationQuery"
logAction = "logAction"
@@ -45,7 +45,8 @@ const (
type DataQueryJson struct {
dataquery.CloudWatchAnnotationQuery
Type string `json:"type,omitempty"`
Type string `json:"type,omitempty"`
LogsMode dataquery.LogsMode `json:"logsMode,omitempty"`
}
type DataSource struct {
@@ -147,12 +148,22 @@ func (ds *DataSource) QueryData(ctx context.Context, req *backend.QueryDataReque
if model.QueryMode != "" {
queryMode = string(model.QueryMode)
}
fromPublicDashboard := model.Type == "" && queryMode == logsQueryMode
isSyncLogQuery := ((fromAlert || fromExpression) && queryMode == logsQueryMode) || fromPublicDashboard
fromPublicDashboard := model.Type == ""
isLogInsightsQuery := queryMode == queryModeLogs && (model.LogsMode == "" || model.LogsMode == dataquery.LogsModeInsights)
isSyncLogQuery := isLogInsightsQuery && ((fromAlert || fromExpression) || fromPublicDashboard)
if isSyncLogQuery {
return executeSyncLogQuery(ctx, ds, req)
}
isLogsAnomaliesQuery := model.QueryMode == dataquery.CloudWatchQueryModeLogs && model.LogsMode == dataquery.LogsModeAnomalies
if isLogsAnomaliesQuery {
return executeLogAnomaliesQuery(ctx, ds, req)
}
var result *backend.QueryDataResponse
switch model.Type {
case annotationQuery: