Elasticsearch: Improve backend instrumentation of QueryData calls (#74172)
* Elasticsearch: Improve backend instrumentation of QueryData calls * Add fromAlert * Fix tests, move logger and context to struct * Add instrumentation for processing response * Move log for sending request closer to sending request * Update * Fix logging, improved messages, fix printing of queries * Update log text * Fix tests * Fix lint * Update logging to follow our guidelines * Remove key-value pairs from logs that are going to be passed from instrumentation * Update pkg/tsdb/elasticsearch/elasticsearch.go
This commit is contained in:
@@ -4,9 +4,10 @@ import (
|
||||
"github.com/grafana/grafana-plugin-sdk-go/backend"
|
||||
|
||||
"github.com/grafana/grafana/pkg/components/simplejson"
|
||||
"github.com/grafana/grafana/pkg/infra/log"
|
||||
)
|
||||
|
||||
func parseQuery(tsdbQuery []backend.DataQuery) ([]*Query, error) {
|
||||
func parseQuery(tsdbQuery []backend.DataQuery, logger log.Logger) ([]*Query, error) {
|
||||
queries := make([]*Query, 0)
|
||||
for _, q := range tsdbQuery {
|
||||
model, err := simplejson.NewJson(q.JSON)
|
||||
@@ -20,10 +21,12 @@ func parseQuery(tsdbQuery []backend.DataQuery) ([]*Query, error) {
|
||||
rawQuery := model.Get("query").MustString()
|
||||
bucketAggs, err := parseBucketAggs(model)
|
||||
if err != nil {
|
||||
logger.Error("Failed to parse bucket aggs in query", "error", err, "model", string(q.JSON))
|
||||
return nil, err
|
||||
}
|
||||
metrics, err := parseMetrics(model)
|
||||
if err != nil {
|
||||
logger.Error("Failed to parse metrics in query", "error", err, "model", string(q.JSON))
|
||||
return nil, err
|
||||
}
|
||||
alias := model.Get("alias").MustString("")
|
||||
|
||||
Reference in New Issue
Block a user