[v10.0.x] Elasticsearch: Fix passing of limit and datalinks to logs data frame (#68626)
* Elasticsearch: Fix passing of limit and datalinks to logs data frame (#68554)
* Elasticsearch: Fix passing of limit and datalinks to logs data frame
* Update public/app/core/logsModel.ts
Co-authored-by: François Massot <francois.massot@gmail.com>
---------
Co-authored-by: François Massot <francois.massot@gmail.com>
(cherry picked from commit dbbbc46351)
* Add missing comment
This commit is contained in:
@@ -160,7 +160,7 @@ func processLogsResponse(res *es.SearchResponse, target *Query, configuredFields
|
||||
frames := data.Frames{}
|
||||
frame := data.NewFrame("", fields...)
|
||||
setPreferredVisType(frame, data.VisTypeLogs)
|
||||
setSearchWords(frame, searchWords)
|
||||
setLogsCustomMeta(frame, searchWords, stringToIntWithDefaultValue(target.Metrics[0].Settings.Get("limit").MustString(), defaultSize))
|
||||
frames = append(frames, frame)
|
||||
|
||||
queryRes.Frames = frames
|
||||
@@ -1137,7 +1137,7 @@ func setPreferredVisType(frame *data.Frame, visType data.VisType) {
|
||||
frame.Meta.PreferredVisualization = visType
|
||||
}
|
||||
|
||||
func setSearchWords(frame *data.Frame, searchWords map[string]bool) {
|
||||
func setLogsCustomMeta(frame *data.Frame, searchWords map[string]bool, limit int) {
|
||||
i := 0
|
||||
searchWordsList := make([]string, len(searchWords))
|
||||
for searchWord := range searchWords {
|
||||
@@ -1156,6 +1156,7 @@ func setSearchWords(frame *data.Frame, searchWords map[string]bool) {
|
||||
|
||||
frame.Meta.Custom = map[string]interface{}{
|
||||
"searchWords": searchWordsList,
|
||||
"limit": limit,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ func TestProcessLogsResponse(t *testing.T) {
|
||||
logsFrame := frames[0]
|
||||
|
||||
meta := logsFrame.Meta
|
||||
require.Equal(t, map[string]interface{}{"searchWords": []string{"hello", "message"}}, meta.Custom)
|
||||
require.Equal(t, map[string]interface{}{"searchWords": []string{"hello", "message"}, "limit": 500}, meta.Custom)
|
||||
require.Equal(t, data.VisTypeLogs, string(meta.PreferredVisualization))
|
||||
|
||||
logsFieldMap := make(map[string]*data.Field)
|
||||
@@ -430,6 +430,7 @@ func TestProcessLogsResponse(t *testing.T) {
|
||||
|
||||
require.Equal(t, map[string]interface{}{
|
||||
"searchWords": []string{"hello", "message"},
|
||||
"limit": 500,
|
||||
}, customMeta)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
// 0
|
||||
// ],
|
||||
// "custom": {
|
||||
// "limit": 500,
|
||||
// "searchWords": [
|
||||
// "hello",
|
||||
// "message"
|
||||
@@ -40,6 +41,7 @@
|
||||
0
|
||||
],
|
||||
"custom": {
|
||||
"limit": 500,
|
||||
"searchWords": [
|
||||
"hello",
|
||||
"message"
|
||||
|
||||
Reference in New Issue
Block a user