mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
CloudWatch/Logs: Don't group dataframes for non time series queries for non live path (#38915)
* Use the same grouping function in legacy code * Add error propagation * Fix tests * Fix tests
This commit is contained in:
@@ -129,9 +129,6 @@ func TestQueryCloudWatchLogs(t *testing.T) {
|
|||||||
Fields: []*data.Field{
|
Fields: []*data.Field{
|
||||||
data.NewField("logGroupName", nil, []*string{}),
|
data.NewField("logGroupName", nil, []*string{}),
|
||||||
},
|
},
|
||||||
Meta: &data.FrameMeta{
|
|
||||||
PreferredVisualization: "logs",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,36 +35,12 @@ func (e *cloudWatchExecutor) executeLogActions(ctx context.Context, req *backend
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// When a query of the form "stats ... by ..." is made, we want to return
|
groupedFrames, err := groupResponseFrame(dataframe, model.Get("statsGroups").MustStringArray())
|
||||||
// one series per group defined in the query, but due to the format
|
if err != nil {
|
||||||
// the query response is in, there does not seem to be a way to tell
|
return err
|
||||||
// by the response alone if/how the results should be grouped.
|
|
||||||
// Because of this, if the frontend sees that a "stats ... by ..." query is being made
|
|
||||||
// the "statsGroups" parameter is sent along with the query to the backend so that we
|
|
||||||
// can correctly group the CloudWatch logs response.
|
|
||||||
statsGroups := model.Get("statsGroups").MustStringArray()
|
|
||||||
if len(statsGroups) > 0 && len(dataframe.Fields) > 0 {
|
|
||||||
groupedFrames, err := groupResults(dataframe, statsGroups)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
resultChan <- backend.Responses{
|
|
||||||
query.RefID: backend.DataResponse{Frames: groupedFrames},
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if dataframe.Meta != nil {
|
|
||||||
dataframe.Meta.PreferredVisualization = "logs"
|
|
||||||
} else {
|
|
||||||
dataframe.Meta = &data.FrameMeta{
|
|
||||||
PreferredVisualization: "logs",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
resultChan <- backend.Responses{
|
resultChan <- backend.Responses{
|
||||||
query.RefID: backend.DataResponse{Frames: data.Frames{dataframe}},
|
query.RefID: backend.DataResponse{Frames: groupedFrames},
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -81,9 +81,6 @@ func TestQuery_DescribeLogGroups(t *testing.T) {
|
|||||||
aws.String("group_a"), aws.String("group_b"), aws.String("group_c"),
|
aws.String("group_a"), aws.String("group_b"), aws.String("group_c"),
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
Meta: &data.FrameMeta{
|
|
||||||
PreferredVisualization: "logs",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -142,9 +139,6 @@ func TestQuery_DescribeLogGroups(t *testing.T) {
|
|||||||
aws.String("group_a"), aws.String("group_b"), aws.String("group_c"),
|
aws.String("group_a"), aws.String("group_b"), aws.String("group_c"),
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
Meta: &data.FrameMeta{
|
|
||||||
PreferredVisualization: "logs",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -220,9 +214,6 @@ func TestQuery_GetLogGroupFields(t *testing.T) {
|
|||||||
aws.Int64(100), aws.Int64(30), aws.Int64(55),
|
aws.Int64(100), aws.Int64(30), aws.Int64(55),
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
Meta: &data.FrameMeta{
|
|
||||||
PreferredVisualization: "logs",
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
expFrame.RefID = refID
|
expFrame.RefID = refID
|
||||||
assert.Equal(t, &backend.QueryDataResponse{Responses: backend.Responses{
|
assert.Equal(t, &backend.QueryDataResponse{Responses: backend.Responses{
|
||||||
@@ -357,7 +348,6 @@ func TestQuery_StartQuery(t *testing.T) {
|
|||||||
Custom: map[string]interface{}{
|
Custom: map[string]interface{}{
|
||||||
"Region": "default",
|
"Region": "default",
|
||||||
},
|
},
|
||||||
PreferredVisualization: "logs",
|
|
||||||
}
|
}
|
||||||
assert.Equal(t, &backend.QueryDataResponse{Responses: backend.Responses{
|
assert.Equal(t, &backend.QueryDataResponse{Responses: backend.Responses{
|
||||||
refID: {
|
refID: {
|
||||||
@@ -431,9 +421,6 @@ func TestQuery_StopQuery(t *testing.T) {
|
|||||||
Fields: []*data.Field{
|
Fields: []*data.Field{
|
||||||
data.NewField("success", nil, []bool{true}),
|
data.NewField("success", nil, []bool{true}),
|
||||||
},
|
},
|
||||||
Meta: &data.FrameMeta{
|
|
||||||
PreferredVisualization: "logs",
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
assert.Equal(t, &backend.QueryDataResponse{Responses: backend.Responses{
|
assert.Equal(t, &backend.QueryDataResponse{Responses: backend.Responses{
|
||||||
"": {
|
"": {
|
||||||
|
|||||||
Reference in New Issue
Block a user