CloudWatch Logs: Support Log Anomalies query type (#113067)
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user