Skip to content

Commit

Permalink
fix default handling
Browse files Browse the repository at this point in the history
  • Loading branch information
iwysiu committed Feb 5, 2025
1 parent 6e63499 commit f6f11a3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
3 changes: 2 additions & 1 deletion pkg/opensearch/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ func NewClient(ctx context.Context, ds *backend.DataSourceInstanceSettings, http
}

logLevelField := jsonData.Get("logLevelField").MustString()
logMessageField := jsonData.Get("logMessageField").MustString()
// logMessageField defaults to "_source"
logMessageField := jsonData.Get("logMessageField").MustString("_source")

db, err := jsonData.Get("database").String()
if err != nil {
Expand Down
5 changes: 2 additions & 3 deletions pkg/opensearch/response_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -487,9 +487,8 @@ func processLogsResponse(res *client.SearchResponse, configuredFields client.Con
flattened = flatten(hit["_source"].(map[string]interface{}), maxFlattenDepth)
sourceMarshalled, err := json.Marshal(flattened)
if err != nil {
queryRes.Error = err
queryRes.ErrorSource = backend.ErrorSourcePlugin
return queryRes
errResp := errorsource.Response(errorsource.PluginError(err, false))
return errResp
}
sourceString = string(sourceMarshalled)
}
Expand Down

0 comments on commit f6f11a3

Please sign in to comment.