diff --git a/etc/provisioning/dashboards/Default/default.json b/etc/provisioning/dashboards/Default/default.json index 9aace85..8338abe 100644 --- a/etc/provisioning/dashboards/Default/default.json +++ b/etc/provisioning/dashboards/Default/default.json @@ -477,6 +477,83 @@ ], "title": "Timeseries Rate Metrics", "type": "timeseries" + }, + { + "datasource": { + "type": "fiskaly-surrealdb-datasource", + "uid": "fiskaly-surrealdb-datasource" + }, + "description": "use LET statement of surreal to search into body ", + "fieldConfig": { + "defaults": { + "color": { + "mode": "thresholds" + }, + "custom": { + "align": "auto", + "cellOptions": { + "type": "auto" + }, + "inspect": false + }, + "mappings": [], + "thresholds": { + "mode": "absolute", + "steps": [ + { + "color": "green", + "value": null + }, + { + "color": "red", + "value": 80 + } + ] + } + }, + "overrides": [] + }, + "gridPos": { + "h": 8, + "w": 12, + "x": 0, + "y": 28 + }, + "id": 6, + "options": { + "cellHeight": "sm", + "footer": { + "countRows": false, + "fields": "", + "reducer": [ + "sum" + ], + "show": false + }, + "showHeader": true + }, + "pluginVersion": "11.1.3", + "targets": [ + { + "datasource": { + "type": "fiskaly-surrealdb-datasource", + "uid": "fiskaly-surrealdb-datasource" + }, + "group": false, + "mode": "raw", + "rate": false, + "rateFunctions": [ + "count" + ], + "rateInterval": "", + "rateZero": true, + "refId": "A", + "requery": true, + "surql": "let $body=\"it\";\nselect * from timeseries where body ~ $body;" + } + ], + "title": "search in body", + "type": "table" } ], "refresh": "", diff --git a/pkg/plugin/datasource.go b/pkg/plugin/datasource.go index 9812d1f..38a703c 100644 --- a/pkg/plugin/datasource.go +++ b/pkg/plugin/datasource.go @@ -597,7 +597,7 @@ func (r *Datasource) query(query string) (queryResponseData, error) { // log.DefaultLogger.Info(fmt.Sprintf("arrResp: %s", arrResp)) - dataMap, ok := array[0].(map[string]interface{}) + dataMap, ok := array[len(array)-1].(map[string]interface{}) if ok == false || isArray == false { return undefined, fmt.Errorf("invalid queryResponse array type") }