mirror of
https://github.com/grafana/grafana.git
synced 2024-11-23 09:26:43 -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:
parent
5e38b02f94
commit
91a67ab0fb
@ -129,9 +129,6 @@ func TestQueryCloudWatchLogs(t *testing.T) {
|
||||
Fields: []*data.Field{
|
||||
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
|
||||
}
|
||||
|
||||
// When a query of the form "stats ... by ..." is made, we want to return
|
||||
// one series per group defined in the query, but due to the format
|
||||
// the query response is in, there does not seem to be a way to tell
|
||||
// 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
|
||||
groupedFrames, err := groupResponseFrame(dataframe, model.Get("statsGroups").MustStringArray())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if dataframe.Meta != nil {
|
||||
dataframe.Meta.PreferredVisualization = "logs"
|
||||
} else {
|
||||
dataframe.Meta = &data.FrameMeta{
|
||||
PreferredVisualization: "logs",
|
||||
}
|
||||
}
|
||||
|
||||
resultChan <- backend.Responses{
|
||||
query.RefID: backend.DataResponse{Frames: data.Frames{dataframe}},
|
||||
query.RefID: backend.DataResponse{Frames: groupedFrames},
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
@ -81,9 +81,6 @@ func TestQuery_DescribeLogGroups(t *testing.T) {
|
||||
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"),
|
||||
}),
|
||||
},
|
||||
Meta: &data.FrameMeta{
|
||||
PreferredVisualization: "logs",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -220,9 +214,6 @@ func TestQuery_GetLogGroupFields(t *testing.T) {
|
||||
aws.Int64(100), aws.Int64(30), aws.Int64(55),
|
||||
}),
|
||||
},
|
||||
Meta: &data.FrameMeta{
|
||||
PreferredVisualization: "logs",
|
||||
},
|
||||
}
|
||||
expFrame.RefID = refID
|
||||
assert.Equal(t, &backend.QueryDataResponse{Responses: backend.Responses{
|
||||
@ -357,7 +348,6 @@ func TestQuery_StartQuery(t *testing.T) {
|
||||
Custom: map[string]interface{}{
|
||||
"Region": "default",
|
||||
},
|
||||
PreferredVisualization: "logs",
|
||||
}
|
||||
assert.Equal(t, &backend.QueryDataResponse{Responses: backend.Responses{
|
||||
refID: {
|
||||
@ -431,9 +421,6 @@ func TestQuery_StopQuery(t *testing.T) {
|
||||
Fields: []*data.Field{
|
||||
data.NewField("success", nil, []bool{true}),
|
||||
},
|
||||
Meta: &data.FrameMeta{
|
||||
PreferredVisualization: "logs",
|
||||
},
|
||||
}
|
||||
assert.Equal(t, &backend.QueryDataResponse{Responses: backend.Responses{
|
||||
"": {
|
||||
|
Loading…
Reference in New Issue
Block a user